Checkout Session Flow
A hosted checkout session is an approach where the payment gateway generates a secure, short-lived session URL that the merchant redirects the customer to, rather than the merchant rendering its own payment form. This model offloads PCI compliance burden from the merchant — the gateway's UI collects and tokenizes card data in an environment the merchant never touches.
A hosted checkout session is an approach where the payment gateway generates a secure, short-lived session URL that the merchant redirects the customer to, rather than the merchant rendering its own payment form. This model offloads PCI compliance burden from the merchant — the gateway's UI collects and tokenizes card data in an environment the merchant never touches.
The flow begins when the customer proceeds to payment on the merchant's website. The merchant's backend makes a server-side API call to the payment gateway to create a checkout session, passing the order details: line items, amounts, currency, success URL, and cancel URL. The gateway creates the session, assigns it a short-lived session ID and a hosted URL, and returns them to the merchant backend.
The merchant redirects the customer's browser to the hosted checkout URL. The customer sees the gateway's payment page — already branded with the merchant's logo if configured — and enters their card details. This form posts directly to the gateway's servers; the card number never reaches the merchant's systems.
The gateway tokenizes the card, applies fraud checks, potentially triggers 3D Secure Authentication, and processes the charge. On success, it redirects the customer to the merchant's success_url with the session ID as a query parameter. The merchant's success page calls the gateway API to retrieve the session object, confirms the payment status, and fulfills the order.
Simultaneously, the gateway fires a webhook to the merchant's server-side webhook endpoint — the webhook is the authoritative signal for order fulfillment, because customers may close their browser before the redirect completes. The merchant should never fulfill based solely on the redirect. See Payment Webhook Processing for the webhook handling pattern.