The two calls you need
1
Create a checkout session, then redirect
Server-side, call
POST /checkout/sessions and send the buyer to the url
in the response. Put your own order/cart id in metadata.2
Confirm via the order.completed webhook
When the webhook fires, verify the signature and read your id back out of
metadata to settle the matching order.1. Create a checkout session
The response is
{ "id": "cs_…", "url": "https://yourstore.pocketsflow.com/checkout?…" }.
Payment methods (no extra parameter)
Payment methods on the hosted checkout URL are the methods offered on the seller’s account: cards, wallets (Apple Pay, Google Pay), ACH, and local methods such as iDEAL that show automatically to buyers in those countries. You do not pass a payment-method field onPOST /checkout/sessions — there isn’t one. Availability still depends on
the buyer’s device, country, and what the payments partner can offer on
your account. Set 3D Secure under Settings → Checkout.
If you embed the checkout in an iframe on your own site (instead of
redirecting), include allow="payment *; publickey-credentials-get *" on that
iframe so Apple Pay and Google Pay can render. The popup script used for
inline embeds sets this for you.
2. Verify and handle the webhook
Every webhook is an HTTPPOST signed with HMAC-SHA256 over the raw body, keyed
with your endpoint’s signing secret. Verify it before trusting the payload.
Best practices
- Verify against the raw body. Don’t re-serialize the JSON before hashing.
- Be idempotent. A webhook may be re-sent; processing the same event twice must be safe (check whether the order is already paid first).
- Acknowledge fast. Return
2xxquickly and do heavy work asynchronously. - Reconcile. Treat the webhook as the source of truth; if one is missed, use
GET /ordersand match on yourmetadataid. - Keep secrets server-side. API keys and signing secrets must never reach the browser.