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):
-
session.completed
- occurs when a session has been successfully completed. -
session.expired
- occurs when a session is expired.
("/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
A customer selects a product in the online store, and then clicks Buy.
-
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, useamount=10000
andcurrency=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 -
-
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 apaymentUrl
(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" }
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.The customer enters their card number, expiration date, and CVV/CVC, and clicks Pay.
The Payment Gateway processes the payment request.
-
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
. 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 inX-Signature
header (see Webhooks for details).