Accept payments
Checkout Sessions
Accept payments through hosted checkout pages. Create a session server-side, then redirect your customer or embed the form.
Overview
A Checkout Session holds line items priced in one itemLocalCurrency, and redirect URLs for one purchase. The customer completes payment on a PaymentHooks-hosted page, then is redirected back to your site.
Redirect
Send customers to the session url
Iframe embed
Embed checkout inside your page
Inline render
Render the form directly in your DOM
How it works
- 1Your server creates a Checkout Session with your secret key
- 2Redirect the customer to the session url, or embed it
- 3Customer enters payment details and submits
- 4PaymentHooks processes the payment and notifies your registered webhook endpoints and, if you set one, the session webhookUrl
- 5Customer is redirected to your successUrl (or cancelUrl on failure)
Create a checkout session
Authenticate with your secret key (Authorization: Bearer phk_live_...). Whether the session runs in test or live mode follows your merchant mode setting, not the key.
curl -X POST https://paymenthooks.com/api/v1/checkout-sessions \
-H "Authorization: Bearer phk_live_..." \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order_789" \
-d '{"lineItems": [{"description": "Pro Plan", "quantity": 1, "unitPrice": 2990}], "itemLocalCurrency": "USD", "successUrl": "https://yoursite.com/success"}'One-time payment or subscription
mode decides what the customer signs up for. "payment" (the default) charges the line items once. "subscription" charges the first payment, then PaymentHooks owns the subscription: it creates it, auto-debits every renewal, handles gateway webhooks and dunning, and sends you subscription.* and invoice.* webhooks.
One-time payment
curl -X POST https://paymenthooks.com/api/v1/checkout-sessions \
-H "Authorization: Bearer phk_live_..." \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order_789" \
-d '{
"mode": "payment",
"itemLocalCurrency": "USD",
"lineItems": [{ "description": "Annual report", "quantity": 1, "unitPrice": 4900 }],
"successUrl": "https://yoursite.com/success"
}'Subscription (no catalog price needed)
Give each renewing line a recurringobject. PaymentHooks finds or creates one price per description, amount, currency and interval, so sending the same request again reuses it. The first recurring line is the subscription's price; further recurring lines become subscription items billed on every renewal; lines without recurring (a setup fee) are charged on the first payment only.
curl -X POST https://paymenthooks.com/api/v1/checkout-sessions \
-H "Authorization: Bearer phk_live_..." \
-H "Content-Type: application/json" \
-H "Idempotency-Key: signup_42" \
-d '{
"mode": "subscription",
"itemLocalCurrency": "USD",
"customerEmail": "[email protected]",
"lineItems": [
{ "description": "Pro plan", "quantity": 1, "unitPrice": 2900, "recurring": { "interval": "month" } },
{ "description": "Extra seat", "quantity": 3, "unitPrice": 500, "recurring": { "interval": "month" } },
{ "description": "Onboarding", "quantity": 1, "unitPrice": 9900 }
],
"successUrl": "https://yoursite.com/welcome"
}'| Field | Type | Required | Description |
|---|---|---|---|
| recurring.interval | string | Yes | day, week, month or year. |
| recurring.intervalCount | integer | No | Bill every N intervals, 1 to 365. Default 1. |
| recurring.startsAt | string | No | Delayed start: an ISO 8601 date (YYYY-MM-DD, midnight UTC) or date-time with a time zone, in the future and at most 3 years away (alias firstChargeAt). The line is not charged today; its subscription is created trialing and first charged on this date at unitPrice. Send a discounted first period as a separate one-time line. |
Several billing cycles and delayed starts
Recurring lines may bill on different cycles, for example a monthly item and a yearly item. The customer pays once; PaymentHooks then opens one subscription per billing cycle and renews each at its own unit price through the same authorisation. A line with recurring.startsAt is not charged today: charge its first period (for instance a discounted first year) as a one-time line, and its subscription is first charged on startsAt(Stripe's trial_end / billing_cycle_anchor).
curl -X POST https://paymenthooks.com/api/v1/checkout-sessions \
-H "Authorization: Bearer phk_live_..." \
-H "Content-Type: application/json" \
-d '{
"mode": "subscription",
"itemLocalCurrency": "USD",
"customerEmail": "[email protected]",
"lineItems": [
{ "description": "Monthly plan", "quantity": 1, "unitPrice": 500, "recurring": { "interval": "month" } },
{ "description": "Yearly item", "quantity": 1, "unitPrice": 1500, "recurring": { "interval": "year", "startsAt": "2027-11-07" } },
{ "description": "Yearly item, first year", "quantity": 1, "unitPrice": 600 },
{ "description": "Setup fee", "quantity": 1, "unitPrice": 100 }
],
"successUrl": "https://yoursite.com/welcome"
}'| Topic | Behaviour |
|---|---|
| Grouping | Recurring lines are grouped by interval, intervalCount and startsAt. Each group becomes one subscription after the single payment: its first line is the base price, the others its items. |
| One authorisation | Every subscription renews through the one payment method the customer authorises at checkout. India e-mandates (Stripe India cards, Razorpay token max_amount, Cashfree plan_max_amount, PhonePe maxAmount) are registered for the largest single renewal of any group, tax included, x 3; never for today's charge. CCAvenue standing instructions are fixed-amount, so such checkouts are refused on CCAvenue. |
| Session fields | subscriptionId is the first subscription; subscriptions[] lists every one (id, status, interval, intervalCount, startsAt, currentPeriodEnd, nextChargeAt, items) once paid. checkout.session.completed carries both (subscription, subscriptions). |
| Hosted page | The summary reads, for example: "$12.00 today, then $5.00 every month from Dec 7, 2026 and $15.00 every year from Nov 7, 2027." |
Free trials
A price's trialDaysis honoured at checkout when every recurring line shares it: the customer sees "14-day free trial, then $29.00 per month. First charge on Nov 29, 2026" and is not charged for the recurring part today.
| Topic | Behaviour |
|---|---|
| When | Every recurring line is sold from a price with the same trialDays > 0 (priceId or lineItems[].priceId). The trial is stored on each line as recurring.trialDays; those lines are not charged today. Mixed trials are refused with 422 TRIAL_MISMATCH. |
| Nothing due today | The payment method is saved without a charge: Stripe SetupIntent, or a Razorpay Rs 1 authorisation refunded at once (recorded as an authorisation, never revenue). Test Mode calls no gateway. The hosted page button reads Start free trial; API clients call POST /checkout-sessions/{id}/trial (action start, then confirm). /pay, /pi, /razorpay-order and /wallet-init answer 409 TRIAL_SETUP_REQUIRED. |
| Confirmed by the gateway | The trial starts once the gateway confirms the saved method, even if the customer closes the page before the confirm: Stripe setup_intent.succeeded and Razorpay payment.authorized / payment.captured on the connection's webhook URL start it on the server, and a check 30 minutes after the start catches a webhook that never arrived. A card that needs 3D Secure returns to the checkout, which starts the trial from Stripe's answer (action return). It starts once whichever arrives first; the Rs 1 verification is refunded once. A session that expires unused releases what the gateway holds (an unfinished SetupIntent is cancelled, an unused saved card detached). |
| One-time lines | Charged today by the same payment that takes the mandate (like a delayed start). CCAvenue is not offered: its standing instruction is fixed to today's amount. |
| Gateways offered | Only gateways that can run the session's flow are listed; if none is enabled for subscriptions the session is refused at creation with 422 TRIAL_UNSUPPORTED_GATEWAY. No gateway ever charges the recurring part early. |
| After checkout | One subscription per billing cycle, status trialing, trialStart = now, trialEndsAt = currentPeriodEnd = nextPaymentAt = now + trialDays. The first renewal, the renewal reminder, the RBI pre-debit notice and subscription_trial_ending (3 days before) are scheduled for the trial end. |
| Events and email | checkout.session.completed: payment_status no_payment_required when nothing was due, and subscriptions[].status trialing with trial_start / trial_end. customer.subscription.created: status trialing, trial_end. subscription_confirmed states the trial and the first charge date. |
Refused at create time
Invalid combinations are refused when the session is created, before any price is created or the customer sees a page.
| Code | HTTP | Meaning |
|---|---|---|
| INVALID_MODE | 400 | mode is not "payment" or "subscription" ("setup" is not supported). |
| NO_RECURRING_ITEM | 400 | Subscription mode without priceId and without any recurring line item. |
| RECURRING_IN_PAYMENT_MODE | 400 | Payment mode with a recurring line item or a top-level priceId. |
| INVALID_STARTS_AT | 400 | recurring.startsAt is not an ISO date or date-time, or not a calendar date. |
| STARTS_AT_IN_PAST | 400 | recurring.startsAt is not in the future (omit it to charge the first period now). |
| STARTS_AT_TOO_FAR | 400 | recurring.startsAt is more than 3 years away. |
| NO_AMOUNT_DUE | 400 | Every recurring line starts later and no one-time line is sent: nothing would be charged today (a free trial from the price is allowed: see Free trials). |
| TRIAL_MISMATCH | 422 | The recurring lines' prices have different trialDays (or one has a trial and another none), a trial is combined with recurring.startsAt, or a trial priceId is sent with first-charge line items. |
| TRIAL_UNSUPPORTED_GATEWAY | 422 | Live account: none of the gateways enabled for subscriptions can run the trial (nothing due: Stripe or Razorpay; with one-time lines: Stripe, Razorpay, Cashfree, PhonePe or PayPal). The message names them. |
| PRICE_NOT_FOUND | 400 | A priceId is not one of your active prices. |
| PRICE_NOT_RECURRING | 400 | The subscription's priceId is a one-time price or has no interval. |
| CURRENCY_MISMATCH | 400 | A price is in a different currency than itemLocalCurrency. |
| PRICE_AMOUNT_MISMATCH | 400 | A line with a priceId sent a unitPrice different from the price's amount (omit unitPrice). |
| CONFLICTING_PRICE | 400 | priceId and metadata.priceId differ, or recurring lines were combined with a base priceId, or a line has both priceId and recurring. |
Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| lineItems | array | Yes* | Line items. Required in payment mode. In subscription mode either recurring line items or priceId (with priceId alone, one line is built from the price). See Line items below. |
| mode | string | No | payment (default, a one-time charge) or subscription (PaymentHooks creates the subscription after the first payment and renews it). Any other value, including setup, returns 400 INVALID_MODE. |
| priceId | string | No | Subscription mode: one of your recurring prices, the subscription's base price. The line items are then the first charge as sent. Replaces metadata.priceId (still accepted). |
| itemLocalCurrency | string | Yes* | Three-letter ISO 4217 code of the amounts you send. Uppercased. Required when any line item is priced inline (unitPrice without priceId). Optional when every line item, and priceId / metadata.priceId, names one of your prices: the session then takes the prices' one currency (prices in different currencies: 400 CURRENCY_MISMATCH). There is no default; see /docs/money-and-currencies. |
| itemTaxLocalCurrencyAmount | integer | No | Tax in minor units of itemLocalCurrency (0 or more). Added to the total as-is and takes precedence over taxRate. Returned with itemTaxAmountUsdCents. |
| taxRate | number | No | Tax percentage from 0 to 100 (e.g. 18). Without itemTaxLocalCurrencyAmount, tax is computed as round(subtotal x taxRate / 100). Values outside 0-100 return 400 VALIDATION_ERROR. |
| itemConvenienceFeeLocalCurrencyAmount | integer | No | Fee in minor units of itemLocalCurrency (0 or more), added to the total. Returned with itemConvenienceFeeAmountUsdCents. |
| shippingOptions | array | No | Payment mode only: up to 5 fixed shipping rates the customer picks from on the hosted checkout (Stripe shipping_options). Each is { id?, displayName, itemLocalCurrencyAmount, taxCode?, taxBehavior? }: id is letters, digits, - and _ (default shr_1, shr_2, ...); itemLocalCurrencyAmount is in minor units of itemLocalCurrency; taxCode is tc_shipping (default) or tc_nontaxable; taxBehavior is exclusive (default, tax added) or inclusive. The first rate is preselected and in the total. Shipping is taxed at the customer's address with the goods (in the EU, UK and GST countries it follows the goods' rates pro rata; in the US each state's rule) and is never discounted by a coupon. Returned as itemShippingLocalCurrencyAmount / itemShippingAmountUsdCents (net, inside the total) and shippingRate (with taxLocalCurrencyAmount). Invalid rates, or rates on a subscription checkout, return 400 VALIDATION_ERROR. |
| shippingRateId | string | No | One of shippingOptions[].id to preselect instead of the first. An id not in shippingOptions, or one without shippingOptions, returns 400 VALIDATION_ERROR. |
| customerId | string | No | Existing customer to associate. Also used to look up the tax jurisdiction for automatic tax. The checkout prefills that customer's name and phone and does not ask for them again; the phone (stored in E.164) is shown as its country and number. |
| customerEmail | string | No | Pre-fills the email field on the hosted checkout page. |
| taxBehavior | string | No | exclusive (default): the line items are net and tax is added on top. inclusive: the line items already contain the tax; itemTaxLocalCurrencyAmount (or taxRate) is the tax inside them, carved out and never added again, so the customer pays exactly the line items. Use inclusive when your billing system has already charged tax. Any other value returns 400 VALIDATION_ERROR. |
| taxName | string | No | Label for an explicit tax on the checkout and receipt (e.g. "GST"), max 60 characters. Default "Tax". |
| customerCountry | string | No | The customer's billing country, ISO 3166-1 alpha-2 (e.g. "IN", "US"). Used for automatic tax when you send neither taxRate nor itemTaxLocalCurrencyAmount, and pre-fills the billing address on the hosted checkout. Every checkout needs a billing country before payment: when you omit it, the customer selects it on the checkout and the tax is recalculated from it. Any other value returns 400 VALIDATION_ERROR. |
| customerState | string | No | The customer's state or province, as its code ("KL", "CA", "ON") or English name. Tax in India (GST), the United States and Canada depends on it; for those countries the hosted checkout asks for it when it is missing. A state that does not belong to customerCountry returns 400 VALIDATION_ERROR. |
| customerPostalCode | string | No | The customer's postal or ZIP code, for automatic tax. It decides the US state and Canadian province, and the parts of a country taxed apart from its mainland: the Canary Islands, Ceuta and Melilla (no Spanish VAT), the Azores and Madeira (16% / 22%), the French overseas departments, Büsingen, Heligoland, Livigno and Campione. It is checked against customerCountry and stored on the billing address; every later re-tax (coupon, quantity, address change) uses it. When the merchant collects tax, the hosted checkout asks for it in the United States, Canada, Spain, Portugal, France, Germany, Italy, Finland and Greece. A malformed value, or a Canadian postal code in another province than customerState, returns 400 VALIDATION_ERROR. |
| customerTaxId | string | No | The customer's business tax ID for this sale (VAT, GST, ABN...), 3 to 64 letters and digits; without it, a tax ID on file for customerId is used (a verified one first, then the most recently added). A customer in one of your Settings > Tax reverse charge countries (other than your own) with the VAT or GST registration number of that country (registry-verified where a registry exists) is charged no tax, and the checkout, receipt and invoice state the reverse charge with the ID. When Settings > Tax asks for a customer tax ID, the checkout shows the field to every customer; it stays optional and payment is never refused for a missing tax ID. A malformed value returns 400 VALIDATION_ERROR. |
| payOnceOption | string | No | Subscription checkouts only: auto (default) offers Pay once next to Subscribe unless Settings > Subscriptions > Offer Pay once is switched off (it is on by default); on always offers the customer Pay once next to Subscribe; off never does. Pay once charges the first period like a one-time payment, saves no payment method, and creates the subscription with collectionMethod send_invoice: an invoice is emailed 7 days before each period ends, and an unpaid invoice follows your retry schedule. Any other value, or a non-auto value on a payment checkout, returns 400 VALIDATION_ERROR. |
| captureMethod | string | No | automatic (default) or manual; any other value returns 400 VALIDATION_ERROR. It is stored on the session and returned, but hosted checkout payments are always captured when they succeed: manual authorisation is not available on checkout sessions. |
| successUrl | string | No | Where the customer is sent after a successful payment. session_id and payment_id are appended as query parameters. |
| cancelUrl | string | No | Where the customer is sent after a failed or cancelled payment. |
| webhookUrl | string | No | https URL (max 2048 chars) that receives this session's events. Any other scheme, including http, returns 400 VALIDATION_ERROR. See Per-session webhooks. |
| theme | object | No | Checkout styling: primaryColor and backgroundColor (hex, e.g. #4D5AFF), fontFamily (max 200 chars), borderRadius (max 50 chars), logoUrl (http/https URL). |
| metadata | object | No | Key-value pairs stored on the session. metadata.priceId is the older way to name the subscription's price; prefer priceId. |
Line items
Each object in the lineItems array describes a product or charge.
| Field | Type | Required | Description |
|---|---|---|---|
| description | string | Yes* | Display name of the item (non-empty, trimmed). Optional with priceId (the product name is used). |
| quantity | integer | Yes | Number of units, 1 or more. On a recurring line it is the subscription item's quantity. |
| unitPrice | integer | Yes* | Price per unit in minor units of itemLocalCurrency (0 or more; positive on a recurring line). Optional with priceId: the line is charged the price's own amount (payment mode: a one-time price). |
| priceId | string | No | One of your prices: decides the line's tax and product. In subscription mode a recurring price makes the line recurring. |
| recurring | object | No | Subscription mode only: { interval, intervalCount } makes the line renew every period. PaymentHooks finds or creates the price (one per productKey and interval, or one generic product per interval without a key). Lines without recurring are charged on the first payment only. |
| adjustableQuantity | boolean | No | Default false: the customer cannot change the quantity or remove the item. Set true to show quantity +/- and remove controls on the hosted checkout page. Not supported with mode subscription. |
| productKey | string | No | Inline recurring lines: a stable key of what is sold, the same for every customer (1-64 of a-z 0-9 _ - ., e.g. hosting_3, com_domain_registration). PaymentHooks keeps one product per key and one price per key and cycle in your default currency, found first and created only when missing. A line in another currency is stored as that price's currency option at the exact line amount; a changed amount in a currency the price already sells in creates a new price version. |
| productName | string | No | With productKey: the item's name (max 255), e.g. Starter or .com domain registration. |
| productCategory | string | No | With productKey: the item's category (max 100), e.g. Web Hosting. The product is named "Web Hosting - Starter" and the price web_hosting_starter (<category>_<item>; a multi-interval cycle adds e.g. _3month; no currency or amount, because one price holds an amount per currency). These names are catalog references and are never shown to customers. A value that is not a non-empty string returns 400 VALIDATION_ERROR. |
Quantities are fixed by default, which is what invoices need. Send adjustableQuantity: true on an item to let the customer change its quantity or remove it on the checkout page; the total is recomputed on the server after each change. An attempt to change a fixed item returns 409 QUANTITY_NOT_ADJUSTABLE.
Tax and fees
itemLocalCurrencyAmount = itemSubtotalLocalCurrencyAmount - itemDiscountLocalCurrencyAmount + itemTaxLocalCurrencyAmount + itemConvenienceFeeLocalCurrencyAmount
- To charge tax you calculated yourself, send
itemTaxLocalCurrencyAmount(optionally withtaxRatefor display). An explicititemTaxLocalCurrencyAmountis always used as-is. A fee you charge on top goes initemConvenienceFeeLocalCurrencyAmount. Both are returned with their USD cents (itemTaxAmountUsdCents,itemConvenienceFeeAmountUsdCents). - To charge a percentage, send
taxRatealone (0 to 100). Tax is computed asround(subtotal × taxRate / 100)in minor units. For example, a subtotal of 2990 withtaxRate: 18gives anitemTaxLocalCurrencyAmountof 538. - If your amounts already contain tax, send
taxBehavior: "inclusive". The customer pays exactly the line items and the tax is carved out of them: withtaxRate: 18a subtotal of 11800 holds 1800 tax; an explicititemTaxLocalCurrencyAmountis the tax inside and must be less than the line-item total.taxNamesets the label shown on the checkout and receipt. - An explicit
taxRate: 0oritemTaxLocalCurrencyAmount: 0means no tax: automatic tax is not applied. - To use automatic tax, omit both
taxRateanditemTaxLocalCurrencyAmount. Automatic tax applies when auto-tax is enabled in your merchant settings, and is calculated from the customer's billing address:customerCountry(andcustomerState), the country on the customer record ofcustomerId, or the address the customer selects on the hosted checkout. Without one, the checkout asks for the billing country (and the state in India, the United States and Canada), recalculates the tax and shows the new total before the customer pays; no payment starts until it is set. - Settings > Tax decides automatic tax for every checkout, payment link, pay page, invoice and subscription. Tax calculation:
auto(your tax rates, else the built-in standard rate),manual(your tax rates only; a place without one is not taxed) ornone(nothing is calculated; only tax you send explicitly is charged). Default tax country: taxed when the customer's country is unknown. Reverse charge countries: a customer there (not your own country) with the VAT or GST registration number of that country (customerTaxId, the one on file, or entered on the checkout; other numbers such as an Australian ARN or a provincial PST number never count) is charged no tax; the checkout, receipt and invoice print "Reverse charge: VAT to be accounted for by the recipient" with the ID, and the session'smetadata.taxNoticerecords it. Ask customers for a tax ID: the checkout shows an optional business tax ID field to every customer. It is never required: a customer without one pays as usual, and invoices are issued without one. Zero-tax message: printed on the checkout, receipt and invoice when no tax is charged. - A
taxRateoutside 0 to 100, or anitemTaxLocalCurrencyAmountoritemConvenienceFeeLocalCurrencyAmountthat is not a non-negative integer, returns400 VALIDATION_ERROR.
Subscription mode with a catalog price
To subscribe the customer to a recurring price you created with POST /v1/prices, send it as priceId. The billing interval comes from that price. With line items, they are the first charge exactly as sent (for example an invoice balance); without them one line is built from the price. The price must be active, recurring and in itemLocalCurrency, otherwise the session is refused with 400 (see the table above). Older integrations that send metadata.priceId keep working.
{
"mode": "subscription",
"lineItems": [{ "description": "Pro Plan (monthly)", "quantity": 1, "unitPrice": 2990 }],
"itemLocalCurrency": "USD",
"priceId": "ph_pri_3a9e5c7b1d2f4a6c8e0b2d4f6a8c1e3b"
}What's included
On a subscription checkout the plan summary lists the product's enabled features under What's included, in the product's order: for example Priority support, 3 projects and 5,000 calls / month, then $1.00 per 1,000 calls when the price bills overage. When the product has no enabled features the section is left out. The confirmation email (subscription_confirmed) lists the same features; a plan without features gets subscription_confirmed_no_features, the same email without that section. Features are set with PUT /v1/products/{productId}/features; see What's included.
Branding
Two settings decide what the customer sees, and each has its own job:
- The business owns the order details on the checkout, receipts, invoices and emails: its name, its image (a full logo or a square icon), its brand colour and what is shown (image and business name, image only, or business name only). The session's business is the API key's business; set each one under Developers > Businesses. A value the business leaves empty comes from the Default branding card under Settings > Branding & domains.
- A custom domain owns only the page chrome when the checkout is served on it: the header logo and the browser tab icon. It never changes the order details.
- The public session (
GET /v1/checkout-sessions/:id/public) returns the resolved order details asmerchantBranding:businessName,logoUrl,logoKind(logo|icon),brandColorandlogoDisplay(logo_and_name|logo_only|name_only). themeon the create request styles one session (colours, font, corner radius) on top of the business's branding.
Endpoints & Responses
Request and response examples for each checkout session endpoint. Responses use the { data, error } envelope; some examples are abridged. itemUsdToLocalCurrencyRate is always a number; taxRate is returned as a string on the authenticated endpoints and as a number on the public endpoint.
/v1/checkout-sessionsCreate a checkout session. Returns 201. Supports the Idempotency-Key header (max 200 chars); a replay returns the stored response with X-Idempotent-Replayed: true.{
"lineItems": [
{ "description": "Pro Plan", "quantity": 1, "unitPrice": 2990 }
],
"itemLocalCurrency": "USD",
"itemTaxLocalCurrencyAmount": 538,
"itemConvenienceFeeLocalCurrencyAmount": 40,
"customerEmail": "[email protected]",
"successUrl": "https://yoursite.com/success",
"cancelUrl": "https://yoursite.com/cancel",
"webhookUrl": "https://yoursite.com/webhooks/paymenthooks",
"metadata": { "orderId": "order_789" }
}{
"data": {
"id": "ph_cks_9f2c4e1a7b3d5f6081a2b3c4d5e6f708",
"merchantId": "ph_mrc_c9f0f895fb98ab9159f51fd0297e236d",
"businessEntityId": null,
"customerId": null,
"customerEmail": "[email protected]",
"mode": "payment",
"status": "open",
"itemLocalCurrency": "USD",
"itemUsdToLocalCurrencyRate": 1,
"itemLocalCurrencyAmount": 3568,
"itemAmountUsdCents": 3568,
"itemSubtotalLocalCurrencyAmount": 2990,
"itemSubtotalAmountUsdCents": 2990,
"taxRate": "0",
"itemTaxLocalCurrencyAmount": 538,
"itemTaxAmountUsdCents": 538,
"itemDiscountLocalCurrencyAmount": 0,
"itemDiscountAmountUsdCents": 0,
"itemConvenienceFeeLocalCurrencyAmount": 40,
"itemConvenienceFeeAmountUsdCents": 40,
"couponCode": null,
"lineItems": [
{ "description": "Pro Plan", "quantity": 1, "unitPrice": 2990, "total": 2990 }
],
"paymentIntentId": null,
"successUrl": "https://yoursite.com/success",
"cancelUrl": "https://yoursite.com/cancel",
"webhookUrl": "https://yoursite.com/webhooks/paymenthooks",
"metadata": { "orderId": "order_789", "paymentMethod": null, "captureMethod": "automatic" },
"expiresAt": "2026-05-17T12:00:00.000Z",
"completedAt": null,
"createdAt": "2026-05-16T12:00:00.000Z",
"url": "https://paymenthooks.com/checkout/ph_cks_9f2c4e1a7b3d5f6081a2b3c4d5e6f708",
"captureMethod": "automatic"
},
"error": null
}/v1/checkout-sessions?page=1&pageSize=10&status=completeList sessions, newest first. Filters: status, mode. pageSize defaults to 25 (max 100). Each item is the full session plus paymentId and url.{
"data": [
{
"id": "ph_cks_9f2c4e1a7b3d5f6081a2b3c4d5e6f708",
"mode": "payment",
"status": "complete",
"itemLocalCurrency": "USD",
"itemLocalCurrencyAmount": 3568,
"itemAmountUsdCents": 3568,
"itemUsdToLocalCurrencyRate": 1,
"customerEmail": "[email protected]",
"paymentId": "ph_pay_0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f",
"url": "https://paymenthooks.com/checkout/ph_cks_9f2c4e1a7b3d5f6081a2b3c4d5e6f708",
"createdAt": "2026-05-16T12:00:00.000Z"
}
],
"meta": { "total": 85, "page": 1, "pageSize": 10 },
"error": null,
"livemode": true
}/v1/checkout-sessions/:idRetrieve a session you own (authenticated). Returns the full session record plus paymentId (the payment created when the customer paid) and url.{
"data": {
"id": "ph_cks_9f2c4e1a7b3d5f6081a2b3c4d5e6f708",
"status": "complete",
"itemLocalCurrency": "USD",
"itemLocalCurrencyAmount": 3568,
"itemAmountUsdCents": 3568,
"itemUsdToLocalCurrencyRate": 1,
"customerEmail": "[email protected]",
"paymentId": "ph_pay_0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f",
"completedAt": "2026-05-16T12:03:10.000Z",
"url": "https://paymenthooks.com/checkout/ph_cks_9f2c4e1a7b3d5f6081a2b3c4d5e6f708"
},
"error": null
}/v1/checkout-sessions/:id/publicPublic read used by the hosted checkout page (no auth). Once expiresAt has passed, an open or pending session is moved to status expired and the call returns 410 EXPIRED. Branding resolves from the business entity when linked, otherwise from the merchant. availableGateways is populated only when the merchant is in live mode.{
"data": {
"id": "ph_cks_9f2c4e1a7b3d5f6081a2b3c4d5e6f708",
"merchantId": "ph_mrc_c9f0f895fb98ab9159f51fd0297e236d",
"customerEmail": "[email protected]",
"mode": "payment",
"status": "open",
"itemLocalCurrency": "USD",
"itemUsdToLocalCurrencyRate": 1,
"itemLocalCurrencyAmount": 3568,
"itemAmountUsdCents": 3568,
"itemSubtotalLocalCurrencyAmount": 2990,
"taxRate": 0,
"itemTaxLocalCurrencyAmount": 538,
"itemConvenienceFeeLocalCurrencyAmount": 40,
"lineItems": [
{ "description": "Pro Plan", "quantity": 1, "unitPrice": 2990, "total": 2990, "metadata": {} }
],
"availableGateways": [
{ "id": "ph_gwc_71aa3e5c7b9d1f2a4c6e8b0d2f4a6c8e", "displayName": "Stripe", "catalogGatewayId": "gw_stripe", "mode": "live" }
],
"platformMode": "live",
"merchantBranding": {
"businessName": "Acme Corp",
"logoUrl": "/api/v1/brand-assets/ph_bra_9e3b7d1f5a2c6e0b4d8f2a6c0e4b8d1f?v=3f1a2c",
"logoKind": "logo",
"brandColor": "#4d5aff",
"logoDisplay": "logo_and_name"
},
"theme": null,
"metadata": { "orderId": "order_789", "paymentMethod": null, "captureMethod": "automatic" },
"preferredPaymentMethod": null,
"successUrl": "https://yoursite.com/success",
"cancelUrl": "https://yoursite.com/cancel",
"expiresAt": "2026-05-17T12:00:00.000Z",
"createdAt": "2026-05-16T12:00:00.000Z"
},
"error": null
}/v1/checkout-sessions/:id/paySubmit payment (public, called by the hosted checkout page and the SDK inline form). email is required. gatewayConnectionId selects one of availableGateways. The response transactionLocalCurrencyAmount and transactionLocalCurrency are what the gateway charged (the customer's currency, USD, or itemLocalCurrency; see Pay errors). If the merchant is in test mode, no gateway is called and the response is { paymentId, status: "success", testMode: true, redirectUrl }.{
"email": "[email protected]",
"cardNumber": "4242424242424242",
"cardExpiry": "12/28",
"cardCvc": "123",
"cardholderName": "Jane Doe",
"gatewayConnectionId": "ph_gwc_71aa3e5c7b9d1f2a4c6e8b0d2f4a6c8e"
}{
"data": {
"paymentId": "ph_pay_0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f",
"gatewayTransactionId": "ch_3Nq2x...",
"status": "success",
"transactionLocalCurrencyAmount": 3568,
"transactionLocalCurrency": "USD",
"cardLast4": "4242",
"cardBrand": "visa",
"cardholderName": "Jane Doe",
"redirectUrl": "https://yoursite.com/success?session_id=ph_cks_9f2c4e1a7b3d5f6081a2b3c4d5e6f708&payment_id=ph_pay_0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f"
},
"error": null
}Pay errors
Errors returned by POST /v1/checkout-sessions/:id/pay, as { data: null, error: { code, message } }.
| Code | HTTP | Meaning |
|---|---|---|
| NOT_FOUND | 404 | Session does not exist |
| SETUP_SESSION | 409 | The session only sets up automatic payments (mode setup); it takes no payment |
| TRIAL_SETUP_REQUIRED | 409 | A free trial with nothing due today: start it with POST /checkout-sessions/:id/trial instead |
| SESSION_ALREADY_COMPLETED | 409 | The session is already complete; it cannot be charged again |
| PAYMENT_IN_PROGRESS | 409 | Another request for this session (a charge, a Stripe or Razorpay confirmation, POST /pi or /razorpay-order) is still being processed; refused at once, nothing reaches the gateway. Read the session (or its events stream) once the other request answers. The per-session lock expires after 120 seconds |
| SESSION_MISMATCH | 400 | The Stripe PaymentIntent or Razorpay order sent to confirm the payment was not started for this session; nothing is recorded |
| BILLING_ADDRESS_REQUIRED | 422 | No billing country (and, for India, the US and Canada, state) yet; nothing is charged until the customer confirms it |
| EXPIRED | 410 | expiresAt has passed (the session status is expired); nothing is charged |
| FRAUD_BLOCKED | 402 | Blocked by fraud screening. error.details carries totalScore and the matched rules |
| VALIDATION_ERROR | 400 | email is required |
| SESSION_CLOSED | 400 | Session status is not open or pending |
| UNSUPPORTED_CURRENCY | 422 | The selected gateway accepts none of: the customer's currency, USD, the session currency |
| PRICE_CHANGED | 409 | The exchange rate moved more than 1% after the page loaded; nothing is charged. Reload the page to see the current price |
| TERMS_NOT_ACCEPTED | 400 | The merchant has policy links and termsAccepted was not true; nothing is charged |
| VALIDATION_ERROR | 422 | The customer has no country, or the subscription price has no billing interval |
| NO_SUBSCRIPTION_GATEWAY | 422 | Live subscription checkout, but no connection that renews automatically has Use for subscriptions on |
| PLAN_LIMIT_REACHED | 403 | The merchant's plan has no transactions left this month; nothing is charged |
| INTERNAL_ERROR | 500 | Payment processing failed, including when fraud screening is unavailable (the payment is rejected, never sent unscreened) |
Per-session webhooks
Checkout outcomes are sent to the webhook endpointsyou register in the dashboard (subject to each endpoint's event subscriptions). Pass webhookUrlwhen creating a session to also receive that session's events at a URL of your choice. The table shows where each event is delivered.
| Event | Session webhookUrl | Registered endpoints | When |
|---|---|---|---|
| checkout.session.created | No | Yes | The session was created |
| checkout.session.completed | Yes | Yes | Payment succeeded and the session is complete |
| checkout.session.payment_failed | Yes | Yes | Payment failed or was declined |
| checkout.session.expired | Yes | Yes | The session was first accessed after expiresAt and moved to status expired (sent once) |
| payment.succeeded | No | Yes | The payment behind the session succeeded (payment_intent object) |
| payment.failed | No | Yes | The payment behind the session failed (payment_intent object) |
| payment.requires_action | Yes | No | The payment needs a 3D Secure challenge before it can complete |
Delivery
- One POST per event. The request times out after 10 seconds. Respond with any 2xx quickly and do slow work asynchronously.
- A non-2xx response, timeout, or network error is retried automatically, for both the session
webhookUrland registered endpoints: after 1 minute, 5 minutes, 30 minutes, and 2 hours (5 attempts in total). Every retry carries the same eventid, so deduplicate on it. - If all attempts fail, reconcile with
GET /v1/checkout-sessions/:id.
Verifying the signature
Each delivery carries an X-PaymentHooks-Signature header computed with the same scheme as endpoint webhooks (see Verifying signatures), but signed with your merchant-wide session webhook signing secret, not an endpoint secret. Read it from Developers → Webhooks in the dashboard, or with GET /v1/webhooks/session-secret (scope webhooks:read). Rotate it with POST /v1/webhooks/session-secret/rotate (scope webhooks:write); the new secret takes effect immediately with no grace period. Always verify the signature; do not rely on the URL being secret.
Payload
The body is the standard event envelope with a checkout.session object in data.object, built from the current session record. On checkout.session.completed, status is complete and payment_status is paid; the object also carries your metadata, customer, success_url and cancel_url, line_items, created and expires_at, and subscription (the created subscription id in subscription mode). payment_intent is the PaymentHooks payment id; fetch full details with GET /v1/payments/:id. The envelope livemode reflects your merchant mode when the event was sent.
{
"id": "ph_evt_5c1f0b9a2e7d4c3b8a6f1e2d4b6a8c0e",
"object": "event",
"api_version": "2026-04-22",
"created": 1747397000,
"type": "checkout.session.completed",
"livemode": true,
"data": {
"object": {
"id": "ph_cks_9f2c4e1a7b3d5f6081a2b3c4d5e6f708",
"object": "checkout.session",
"status": "complete",
"payment_status": "paid",
"mode": "payment",
"amount_total": 3568,
"amount_subtotal": 2990,
"currency": "usd",
"amount_usd_cents": 3568,
"usd_to_local_currency_rate": 1,
"customer": "ph_cus_8d2f6a1c3e5b7d9f0a2c4e6b8d1f3a5c",
"customer_email": "[email protected]",
"customer_details": { "email": "[email protected]", "name": "Jane Doe", "phone": null },
"payment_intent": "ph_pay_0c1d2e3f4a5b6c7d8e9f0a1b2c3d4e5f",
"subscription": null,
"success_url": "https://yoursite.com/success",
"cancel_url": "https://yoursite.com/cancel",
"url": "https://paymenthooks.com/checkout/ph_cks_9f2c4e1a7b3d5f6081a2b3c4d5e6f708",
"line_items": {
"object": "list",
"data": [
{ "object": "line_item", "description": "Pro Plan", "quantity": 1, "amount_total": 2990, "currency": "usd" }
]
},
"metadata": { "orderId": "order_789", "captureMethod": "automatic" },
"created": 1747396800,
"expires_at": 1747483200,
"livemode": true
}
},
"request": { "id": null, "idempotency_key": null }
}Session statuses
openCreated and awaiting paymentpendingPayment submitted and awaiting the gateway outcome. Returns to open if the gateway later reports a failurecompletePayment succeeded; the session cannot be paid againexpiredexpiresAt passed before payment. The hosted page, public read, pay, and wallet-init return 410 EXPIRED