For any question, we are one click away

Contact us

Redirect integration

Redirect integration is a simple and secure process that uses the payment page on the Payment Gateway side. The main advantage of this integration method is that you don't need to collect and process card data on your website. The API is used minimally in this case, so this method does not require much development expertise.

First, you should subscribe to the following webhooks (see Webhooks for details):

Before you begin, make sure you have created an account or logged in.
sequenceDiagram participant C as Customer participant OS as Online store participant PG as Payment Gateway autonumber activate C C ->> OS: Initiate payment activate OS OS ->> PG: Create session
("/sessions" request) activate PG PG -->> OS: id, paymentUrl OS -->> C: Redirect to the payment URL C ->> PG: Enter card data PG -->> PG: Process payment PG -->> C: Redirect to the success URL deactivate C PG -->> OS: "session.completed"
webhook deactivate OS deactivate PG
  1. A customer selects a product in the online store, and then clicks Buy.

  2. The online store requests session creation by sending /sessions POST request to the Payment Gateway. The request must contain the following parameters:

    • amount - the payment amount in minor currency units. For example, to specify $100, use amount=10000 and currency=USD (10000 cents).
    • currency - code of the payment currency, according to ISO 4217.
    • successUrl - the address to which the customer will be redirected after successfull payment at Step 7.
    • failureUrl - the address to which the customer will be redirected at Step 7, if the payment fails.

    Request example:

    curl -X POST "https://dev.bpcbt.com/api2/sessions" \
    -H "X-Api-Key: 6HUXQFbeomV1zf5i8cgm5W8KfncENVEa5uh8RngB" \
    -H "X-Version: 2023-10-31" \
    -H "Content-Type: application/json" \
    -d '{
        "amount": 10000,
        "currency": "EUR",
        "successUrl": "https://mybestmerchantreturnurl.com/success",
        "failureUrl": "https://mybestmerchantreturnurl.com/failure"
    }'
    POST

    /api2/sessions

    { "amount": 10000, "currency": "EUR", "successUrl": "https://mybestmerchantreturnurl.com/success", "failureUrl": "https://mybestmerchantreturnurl.com/failure" }

  3. The Payment Gateway creates a session and sends a response to the online store server. The response contains an id (the unique identifier of the Session in the Payment Gateway) and a paymentUrl (the URL to which the online store should redirect the customer for payment at Step 4). The other fields sent in the request are also returned in the response.

    Response example:

    {
    "id": "ps_2GRSigkh7m3hqz5pMCAYCzJaXjsHgypQui6nMBss3XLVLF8gwDASHP",
    "amount": 10000,
    "created": "2024-03-28T08:26:37Z",
    "currency": "EUR",
    "customerDetails": {},
    "expiresAt": "2024-03-28T08:46:37Z",
    "failureUrl": "https://mybestmerchantreturnurl.com/failure",
    "locale": "EN",
    "merchantReferenceId": "4000",
    "metadata": {},
    "paymentData": {
        "captureMethod": "automatic"
    },
    "paymentStatus": "unpaid",
    "paymentUrl": "https://dev.bpcbt.com/payment/merchants/ecom/payment.html?mdOrder=12a19f56-50e6-74bc-a289-c93d00a9c8eb&language=en",
    "status": "open",
    "successUrl": "https://mybestmerchantreturnurl.com/success"
    }
  4. The online store redirects the customer to the URL received in the paymentUrl parameter. The redirection may be done in the same window or in a new window.

  5. The customer enters their card number, expiration date, and CVV/CVC, and clicks Pay.

  6. The Payment Gateway processes the payment request.

  7. The customer is redirected to the online store page defined in the successUrl parameter (specified at Step 2). The redirect URL will contain the ID of the session, for example: https://mybestmerchantreturnurl.com/success?sessionId=ps_aksdhauedqiuwehdiqwbdq.

  8. The online store waits for the session.completed webhook to make sure the payment was successful. You should always check the signature of the webhook in X-Signature header (see Webhooks for details).

Categories:
eCommerce API V2
Categories
Search results