Skip to Content
Docs

Add to checkout

Integrate paysafecard payments using Pay.com.js or the REST API, with testing instructions.

You can accept Paysafecard payments in three ways:

  • Universal checkout: Pay.com.js displays Paysafecard in its payment form.
  • Headless checkout: You build your own checkout UI, and Pay.com.js starts the Paysafecard payment when the customer selects it.
  • Server-to-server: You create the charge from your server and redirect the customer to Paysafecard.

Before you start, ask your account manager to enable Paysafecard for your account, then turn it on in the Pay.com dashboard.

Universal checkout

Universal checkout displays Paysafecard in its payment form when the payment session includes it.

  1. 1

    Create a payment session

    On your server, create a payment session with POST /v1/sessions/payment and include "paysafecard" in payment_method_types.

    {
      "amount": 5000,
      "currency": "eur",
      "customer_reference_id": "cust-001",
      "payment_method_types": ["card", "paysafecard"]
    }

    Amounts are in the currency's minor unit, so 5000 is €50.00. customer_reference_id is your own ID for the customer, and it's required. Return the session's client_secret to your page.

  2. 2

    Display the checkout

    On your page, initialize Pay.com.js with the client_secret and mount Universal checkout, as in Universal checkout. No method-specific configuration is required.

  3. 3

    Handle the result

    When the customer selects Paysafecard and clicks Pay, Pay.com.js opens Paysafecard in a window over your page. If the customer closes the window, Pay.com.js calls onFailure.

    When the customer finishes, Pay.com.js calls onSuccess if the payment succeeded, onPending if its result isn't final yet, or onFailure if it failed. Fulfill the order when you receive the charge.succeeded webhook event.

Headless checkout

With Headless checkout, you build your own checkout UI, and Pay.com.js starts the Paysafecard payment when the customer selects it.

  1. 1

    Create a payment session

    Create the payment session on your server as in Universal checkout, with "paysafecard" in payment_method_types, and initialize Pay.com.js with its client_secret.

  2. 2

    Check that Paysafecard is available

    Call checkout.getPaymentMethods(), and show your Paysafecard button only when the list includes it. Don't use checkout.canMakePayments() for this, because it reports only Apple Pay and Google Pay.

    const methods = await checkout.getPaymentMethods()
    const paysafecard = methods.find((method) => method.paymentMethodType === 'paysafecard')
  3. 3

    Start the payment

    When the customer selects Paysafecard, call checkout.headless() with 'paysafecard'.

    try {
      await checkout.headless('paysafecard')
    } catch (error) {
      // onFailure receives the error details too.
    }

    Pay.com.js opens Paysafecard in a window over your page. If the customer closes the window, Pay.com.js calls onFailure.

    When the customer finishes, Pay.com.js calls onSuccess if the payment succeeded, onPending if its result isn't final yet, or onFailure if it failed. Fulfill the order when you receive the charge.succeeded webhook event.

Server-to-server

From your server, a Paysafecard payment takes three steps: create the charge, create a linked authentication session to obtain the redirect URL, and redirect the customer to Paysafecard.

  1. 1

    Create the charge

    Send POST /v1/charges with source_data.type set to "paysafecard". Paysafecard requires the customer's country in source_data.billing_details.address.country.

    {
      "amount": 5000,
      "currency": "eur",
      "source_data": {
        "type": "paysafecard",
        "billing_details": {
          "address": {
            "country": "DE"
          }
        }
      },
      "customer_reference_id": "cust-001",
      "reference": "order-12345",
      "description": "Order #12345"
    }

    The charge's status is requires_authentication until the customer approves the payment.

  2. 2

    Create a linked authentication session

    Send POST /v1/sessions/authentication/linked with the charge's id as resource and the return_url to return the customer to. confirm defaults to true, so Pay.com completes the charge when the customer approves it. Each charge supports one linked authentication session.

    {
      "resource": "chrg_702172227948251136",
      "return_url": "https://your-site.com/payment/complete"
    }
  3. 3

    Redirect the customer

    Send the customer to the session's url with a full-page redirect. After they approve or cancel the payment, Paysafecard redirects them back to your return_url. Fulfill the order when you receive the charge.succeeded webhook event, and handle charge.failed as a canceled or declined payment.

Testing

Test against https://api.sandbox.pay.com/v1 with your sk-pay-com-sandbox- API key. Test transactions never move real funds. See Environments.

Sandbox behavior

In the sandbox, Pay.com opens an Alternate Payments Redirect Simulator instead of the real paysafecard PIN entry page. The simulator displays the paysafecard logo, a pre-filled Payment ID, and a Payment Status dropdown that lets you choose the outcome before submitting.

  • Pay.com.js: the simulator opens in a window over your checkout page.
  • Server-to-server integration: the simulator opens as a full-page redirect at the url returned by the linked authentication session.

In the live environment, the customer sees paysafecard's real PIN entry page instead of the simulator.

Simulator payment statuses

The simulator provides five payment statuses to test different outcomes:

Payment statusPay.com.js callbackExpected result
SUCCESSonSuccessCharge moves to succeeded. charge.succeeded webhook fires.
AUTHORIZEDonSuccessCharge moves to succeeded. Simulates a pre-authorized payment that is then captured.
CANCELonFailureCharge moves to failed. charge.failed webhook fires. Error message: "Something went wrong during paysafecard payment process".
EXPIREDonFailureCharge moves to failed. charge.failed webhook fires. Error message: "Something went wrong during paysafecard payment process".
REDIRECTEDNeitherCharge stays in requires_authentication. Simulates the customer being redirected but not completing payment.

Test scenarios

Run each scenario in the sandbox and check the charge status, the webhook, and the Pay.com.js callback.

ScenarioTest actionExpected result
Successful paymentSelect SUCCESS in the simulator and click SubmitCharge status: "succeeded". charge.succeeded webhook fires. Pay.com.js calls onSuccess.
Customer cancelsSelect CANCEL in the simulator and click SubmitCharge status: "failed". charge.failed webhook fires. Pay.com.js calls onFailure.
Expired voucherSelect EXPIRED in the simulator and click SubmitCharge status: "failed". charge.failed webhook fires. Pay.com.js calls onFailure.
Customer abandonsClose the simulator without submitting (close the window with Pay.com.js, or navigate away when you test from your server)Charge stays in requires_authentication. With Pay.com.js, closing the window calls onFailure.
Missing countryOmit billing_details.address.country from the charge requestRequest rejected immediately with 400 invalid_parameters. No charge is created.
Was this page helpful?