Skip to content

Integrate the Hosted Payment Page

Integrate Kustom Hosted Payment Page. Create an order and session, redirect customers or send a payment link, track the result and capture payment.

The Hosted Payment Page (HPP) lets customers pay on a page hosted by Kustom. Create a Checkout order and an HPP session on your server, then redirect the customer or share the payment link by e-mail, SMS or QR code. Kustom renders the checkout. See the session reference for fields and options.

Your server must be able to create a Checkout order. The purchase uses three Kustom services:

ServiceWhat it does hereBase path
CheckoutCreates the order — the cart, the totals, the callback URLs/checkout/v3
Hosted Payment PageWraps that order in a session the customer can reach/hpp/v1
Order ManagementCaptures and refunds afterwards/ordermanagement/v1

All three take the same HTTP Basic credentials. Playground is https://api.playground.kustom.co, production is https://api.kustom.co. Credentials don’t cross between them.

Choose how customers will reach the payment page:

  • E-commerce. The customer is already in a browser on a site you own, so you can redirect them.
  • Telesales or e-mail. The customer is on the phone or in their inbox. You have to send them a link.
  • Shared device. A kiosk or an in-store screen. Privacy rules mean you must not leave a session open on a shared browser, so you distribute rather than redirect.

Create the order through the Checkout API:

curl -X POST https://api.playground.kustom.co/checkout/v3/orders \
--header "Authorization: Basic <token>" \
--header "Content-Type: application/json" \
--data @order.json

See Create an order for what belongs in the body. Use the response’s order_id to create the HPP session. HPP renders the checkout; don’t render the returned html_snippet yourself.

POST /hpp/v1/sessions, pointing payment_session_url at the order you just created:

{
"payment_session_url": "https://api.playground.kustom.co/checkout/v3/orders/8cf27b55-53e8-6aba-9fb4-7c692e56ddee",
"merchant_urls": {
"success": "https://example.com/done?order_id={{order_id}}",
"back": "https://example.com/cart",
"failure": "https://example.com/declined",
"error": "https://example.com/error",
"status_update": "https://example.com/hpp-callback?session={{session_id}}&token=<your secret>"
}
}

The response gives you a session_id and a set of URLs — redirect_url for the customer, session_url for you to poll, distribution_url to send the link by e-mail or SMS and qr_code_url for a screen. The reference lists all of them, and every option you can set on the session, including branding.

Use the URLs as returned. Their structure isn’t part of the contract and Kustom changes it. Only session_id is stable enough to store.

Redirect if the customer is already in a browser you control. Send them to redirect_url, and set merchant_urls so they come back to you afterwards:

URLWhen the customer lands there
successPayment was authorized. You must show your own confirmation — Kustom’s isn’t enough on its own.
failurePayment was refused. The customer has already seen why.
backThe customer pressed Back. The session stays open, so they can return to it. Disabling it is your call.
cancelThe customer confirmed a cancellation, which moves the session to CANCELLED permanently.
errorSomething went wrong. Without this URL, errors go to failure and you can’t tell a decline from a fault.

The exit controls depend on the URLs you set:

  • Both back and cancel: both controls appear. Cancel prompts for confirmation.
  • Neither: Cancel leads to Kustom’s page.
  • Only back: Back appears.
  • Only cancel: Cancel appears if the order has options.acquiring_channel; otherwise, Back appears. Only the field’s presence matters, not its value.

A missing back falls back to cancel; a missing error falls back to failure.

merchant_urls also accepts two callback URLs: status_update (step 4) and distribution_update. The latter fires once after Kustom sends a link by e-mail or SMS, with session_id, distribution_id, method and the recipient’s contact information.

Distribute if you can’t redirect. POST to the distribution_url with an e-mail address or a phone number and Kustom sends a localized message containing the link, or display qr_code_url on a screen for the customer to scan. Both are covered in the reference. If an operator — a clerk or a telesales agent — is driving the flow by hand, use the Distribution Module rather than building your own interface on the API.

The customer may close the window before the redirect. Track session status through callbacks, with polling to recover missed updates:

  • Callbacks. Set merchant_urls.status_update when creating the session. Kustom POSTs the session on every status change.
  • Polling. GET the session_url from the create response to recover missed callbacks.

Kustom attempts each callback three times: the first send and two retries, three seconds apart. Each attempt has a three-second response deadline.

The statuses and the callback body are in the reference. The one you’re waiting for is COMPLETED.

Unless the order was created with auto_capture, no money moves until you capture it through Order Management — see Capture an order.

If the offer expires or the customer pays another way, DELETE the session. Its status becomes DISABLED permanently and the link stops working.

Why the hosted session expires before the order

Section titled “Why the hosted session expires before the order”

A session uses the earlier of the order’s expiry or 48 hours after session creation, minus a stagger of 0–59 minutes to spread expirations. Sessions on otherwise identical orders can therefore expire at different times. Use the session’s expires_at as the payment-link deadline.

Multiple sessions per order are possible but discouraged. Prefer one session per order.

Run the whole flow in Playground before you build the production path:

  1. Create an order, then a session on it. You get a session_id and a redirect_url.
  2. Open redirect_url in a browser. Your status_update endpoint receives IN_PROGRESS.
  3. Pay with Playground test data. Your endpoint receives COMPLETED, carrying the order_id.
  4. GET the session_url and confirm it agrees with the callback.
  5. DELETE a second, unused session and confirm its status is DISABLED and its link is dead.

Auto-capture. Create the order with auto_capture and money moves at authorization, with no Order Management call from you. Use it when goods are handed over immediately.

Place-order mode. A session on a Checkout order always completes with an order_id, never an authorization_token, so {{order_id}} is usable in success whatever you set. options.place_order_mode: CAPTURE_ORDER sets options.auto_capture on the order. PLACE_ORDER has no effect on a Checkout order.

Generic confirmation pages. Leave merchant_urls empty and Kustom shows its own success, failure and cancellation pages. Use your own pages in production.

The customer paid but never came back. Redirects aren’t guaranteed. Check the callback and read endpoint for the session status.

A callback never arrived. Each status change is retried independently, so a missed IN_PROGRESS doesn’t prevent a later COMPLETED. Poll session_url to recover the status. Check that your endpoint responds within three seconds, including TLS.

The customer sees “Page Not Found”. The session was disabled while they were on it. That’s what DISABLED looks like from their side.

You can’t tell declines from faults. You didn’t set error, so both went to failure. Set both URLs.

This page is also available as Markdown — append .md to its URL — and is indexed in llms.txt.