Guides
Accept payments with hosted checkout
Create a checkout session on your server, redirect the buyer to its url, fulfil once per session on the checkout.session.completed webhook, and check the session before showing paid.
This guide sells a $15 one-time 7-day pass. Your server creates a session, the buyer pays on ZeroPoint's page, and your webhook handler grants the pass. Read Hosted checkout first for the states and rules.
1. Listen for the event
Register your receiver for checkout.session.completed and checkout.session.expired (see Webhooks for POST /v1/webhooks and signature checks). Do this before the first sale: fulfilment happens there.
2. Create a session on your server
When the buyer presses Buy, your server (never the browser) creates the session with your secret key:
Response 200:
{"object":"checkout.session","id":"cs_01j...","livemode":false,"status":"open","payment_status":"unpaid","url":"https://HOST/pay/...","amount_total":1500,"currency":"usd","client_reference_id":"user_42","payment":null,"expires_at":1763600000}- Amounts are integer cents. The total is computed from
line_itemson our server. Idempotency-Keyis optional, as on Stripe, and recommended: use one key per purchase attempt; a retry of the same request uses the same key and gets the same session back. Without a key, each request creates a session.- Send
client_reference_idon every create, so you can find your user or order from the session and the event. {CHECKOUT_SESSION_ID}insuccess_urlis replaced with the session id.
Then redirect the buyer with a 303 to url. Do not store url in logs; it opens the payment page.
From an agent, the create_checkout_session tool does the same. It takes client_reference_id and a request_key: use a new request_key for each purchase and the same one only to retry the same call.
3. In the sandbox, pay
With no browser (scripts, agents, CI): POST /v1/test_helpers/checkout/sessions/{id}/confirm with {"card": "tok_visa", "email": "buyer@example.com"} and an Idempotency-Key, or the MCP tool confirm_checkout_session. It runs the page's own confirm and answers the session, status: complete; the webhooks are the real ones. tok_chargeDeclined answers 402 card_declined and leaves the session open. Test mode only; see sandbox, "Test card tokens".
In a browser: open url in a regular browser, type test card 4761739001010010 (any future expiry, any CVV), and pay. A browser driven by an automation tool is refused by the processor's reCAPTCHA.
To pay a second time, wait a few minutes or use another amount. The processor refuses the same card for the same amount moments after a payment as a repeat: the page shows "This looks like a repeat of a payment made moments ago. Do not pay again. Contact {merchant} about this order." ({merchant} is the merchant's display name), and the session is held (below) until a complete read of the processor's records shows no sale for that attempt. The attempt is marked unknown about 15 minutes after the payment, and the first read that can settle it runs about an hour after that, so the session usually expires, and the client_reference_id is free again, about an hour and a half after the payment. If that read cannot finish (the processor is unreachable, or its records cannot be read completely), it is tried again about six hours and twenty-four hours after the hold; after that the session waits for ZeroPoint support.
4. Fulfil on the webhook, once per session id
The success redirect proves nothing: anyone can open success_url with any id. Grant the pass only in your webhook handler:
- Verify the
ZeroPoint-Signatureheader (Webhooks). - On
checkout.session.completed, readdata.object: the session. - Record the session id as fulfilled in the same database transaction that grants the pass, and skip it if it is already there. Events can arrive twice; fulfil once per session id.
- Use
client_reference_id(or yourmetadata) to find the user.
5. Check the session on the success page
Your success page retrieves the session with your server key:
Show "paid" only when status is complete, payment_status is paid, merchant_id is yours and amount_total is what you expected. While the webhook has not arrived yet, show "Payment received, setting up your pass" and poll your own database, not ZeroPoint, for the fulfilment.
When a payment's outcome is unknown
If the processor's answer for an attempt is unknown, the session is held: status stays open with payment_status: processing, and the page refuses another card. It completes or expires once the outcome is proven by the processor's records; a hold whose records never settle it waits for ZeroPoint support. While it is held, a create with the same client_reference_id for the same merchant answers:
{"error":{"type":"conflict","code":"checkout_outcome_unknown","param":"client_reference_id","held_session_id":"cs_01j...","message":"..."}}Show the buyer "Your earlier payment is being confirmed." and do not create another session for them. Retrieve held_session_id later to see how it ended.
Cancel a session
POST /v1/checkout/sessions/{session_id}/expire (no body; an Idempotency-Key is optional) closes an open session so its link stops working. It answers 409 checkout_session_busy with Retry-After while an attempt is in flight, and 409 checkout_outcome_unknown while the session is held.
Refusals and Idempotency-Key
A refusal is kept under its Idempotency-Key for 24 hours, like any other answer. After you fix the cause (an https redirect, a live platform being enabled, a held session closing), send the request again under a new Idempotency-Key; the old key replays the old refusal. The MCP tools keep only successes, so after a fix the same request_key works.
| Code | Meaning |
|---|---|
parameter_invalid | A value breaks a rule: amount, quantity, currency, text length, expiry. |
parameter_unknown | A Stripe field this API never supports, named in param. |
parameter_unavailable | A field not available yet (see below). |
url_invalid | success_url or cancel_url is not an allowed URL. |
checkout_unavailable | Live mode is not enabled for your platform yet. |
checkout_outcome_unknown | A held session exists for this client_reference_id. |
resource_limit_exceeded, sandbox_daily_limit_exceeded | Sandbox ceilings on open and daily sessions. |
Also available
- Catalog prices: a line
{price: price_..., quantity: 1}instead ofprice_data. - Promotion codes:
allow_promotion_codes: true(or one code indiscounts) on a session with exactly one catalog price line. A code that brings the total to $0 lets the buyer complete the order with no card; the session completes withpayment_statusno_payment_required. - Subscription mode: send
mode: subscriptionwith one recurring catalogpriceto sell a plan;subscription_data.metadatais copied onto the subscription. A code that would make the first invoice $0 is refused. See Hosted checkout for its rules.
Not available yet
- Google Pay and Apple Pay on the page: card entry only.
- Tax: no tax is computed and no tax line is shown.
See also Migrate from Stripe Checkout.