- Checkout
- Features
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.
Before you start
Section titled “Before you start”Your server must be able to create a Checkout order. The purchase uses three Kustom services:
| Service | What it does here | Base path |
|---|---|---|
| Checkout | Creates the order — the cart, the totals, the callback URLs | /checkout/v3 |
| Hosted Payment Page | Wraps that order in a session the customer can reach | /hpp/v1 |
| Order Management | Captures 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.
Step by step
Section titled “Step by step”1. Create the order
Section titled “1. Create the order”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.jsonSee 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.
2. Create the hosted session on top of it
Section titled “2. Create the hosted session on top of it”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.
3. Get the customer to the page
Section titled “3. Get the customer to the page”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:
| URL | When the customer lands there |
|---|---|
success | Payment was authorized. You must show your own confirmation — Kustom’s isn’t enough on its own. |
failure | Payment was refused. The customer has already seen why. |
back | The customer pressed Back. The session stays open, so they can return to it. Disabling it is your call. |
cancel | The customer confirmed a cancellation, which moves the session to CANCELLED permanently. |
error | Something 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
backandcancel: 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 hasoptions.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.
4. Read the outcome
Section titled “4. Read the outcome”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_updatewhen creating the session. KustomPOSTs the session on every status change. - Polling.
GETthesession_urlfrom 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.
5. Capture, or disable the session
Section titled “5. Capture, or disable the session”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.
Check that it works
Section titled “Check that it works”Run the whole flow in Playground before you build the production path:
- Create an order, then a session on it. You get a
session_idand aredirect_url. - Open
redirect_urlin a browser. Yourstatus_updateendpoint receivesIN_PROGRESS. - Pay with Playground test data. Your endpoint receives
COMPLETED, carrying theorder_id. GETthesession_urland confirm it agrees with the callback.DELETEa second, unused session and confirm its status isDISABLEDand its link is dead.
Variations
Section titled “Variations”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.
Troubleshooting
Section titled “Troubleshooting”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.
Related
Section titled “Related”- Session reference — every endpoint, option, status and error code
- Capture an order — moving the money after
COMPLETED - Integration models — whether HPP is the right integration model at all
- Create an order — the call step 1 makes
- In-person payments — the other way to take payment away from your website
- Checkout API reference — the order’s full schema
This page is also available as Markdown — append .md to its URL — and is indexed in llms.txt.