Use the B2B Payments API to create an XPay-hosted payment page and redirect the customer to it. This flow is suitable when the merchant does not need to render XPay Element directly in its application.
Before you begin
Configure XPay API authentication and a verified webhook endpoint. Choose merchant-controlled HTTPS success and failure URLs.
Create the payment session
Send an authenticated backend request to:
POST {{base_url}}/public/v1/payment/checkoutIf payment_methods is omitted, the hosted payment page displays the methods enabled for the merchant store. The B2B Payments API supports card, easypaisa, jazzcash, googlepay, and dqr as accepted values.
Redirect the customer
The response below is shortened:
{
"success": true,
"data": {
"_id": "xpay_pi_example",
"pi_status": "requires_payment_method",
"checkout_page_url": "https://{{xpay_checkout_host}}/?id={{checkout_id}}"
}
}Store data._id against checkout-1001, then redirect the customer to data.checkout_page_url.
B2B Payments API compared with a payment link
Use the B2B Payments API for an immediate browser redirect controlled by the merchant application. To generate a shortened URL for sharing through WhatsApp, SMS, email, or another channel, create a payment link.
Handle the result
The success and failure URLs control customer navigation. Use the verified XPay webhook and current PaymentIntent state for backend reconciliation and fulfillment.