Billing
Subscriptions
Build recurring billing with products, prices, and dunning management.
Overview
Subscriptions (ph_sub_...) bill a customer on a recurring price. Create products and prices, then attach a customer to a recurring price. Supported billing intervals are day, week, month and year, with intervalCount taken from the price. Monthly and yearly periods are calendar-aware in UTC and clamp to the last day of the month (Jan 31 + 1 month = Feb 28/29). All requests use Authorization: Bearer phk_live_....
Prices
Daily, weekly, monthly or yearly intervals
Free trials
From the price or a trial end date
Dunning
Automatic retries after failed renewals
Create a subscription
Create a subscription by attaching a customer to a price. The API returns the new subscription in active status (trialing when a trial applies), computes the first billing period from the price interval, schedules the first renewal (and, for trials, the trial-expiry notice), and dispatches a subscription.created webhook. Send an Idempotency-Key header (max 200 characters) to make retries safe: a repeated key returns the stored response with X-Idempotent-Replayed: true.
curl https://paymenthooks.com/api/v1/subscriptions \
-X POST \
-H "Authorization: Bearer phk_live_..." \
-H "Content-Type: application/json" \
-H "Idempotency-Key: sub-create-jane-pro" \
-d '{
"customerId": "ph_cus_8f14e45fceea167a5a36dedd4bea2543",
"priceId": "ph_pri_c20ad4d76fe97759aa27a0c99bff6710",
"metadata": { "plan": "pro" }
}'Several prices or an inline price
Send items instead of priceId. The first item is the subscription's price, the others are recurring add-ons billed on every renewal. An item can name a catalog priceId or an inline priceData; no product or price has to exist first.
curl https://paymenthooks.com/api/v1/subscriptions \
-X POST \
-H "Authorization: Bearer phk_live_..." \
-H "Content-Type: application/json" \
-d '{
"customerId": "ph_cus_8f14e45fceea167a5a36dedd4bea2543",
"items": [
{ "priceId": "ph_pri_c20ad4d76fe97759aa27a0c99bff6710", "quantity": 2 },
{ "priceData": { "description": "Priority support", "unitPrice": 1500, "itemLocalCurrency": "USD", "recurring": { "interval": "month" } } }
]
}'| Field | Type | Description |
|---|---|---|
customerId | string | Customer ID (ph_cus_...). Must belong to your account. |
priceId | string | Recurring price ID (ph_pri_...). Send priceId or items. itemLocalCurrency, interval and intervalCount are copied from the price; itemLocalCurrencyAmount / itemAmountUsdCents are the price x quantity. |
quantity | integerDefault: | With priceId: units of the price billed every period (1-10000). |
items | object[] | Instead of priceId (1-20 entries): [{ priceId | priceData, quantity }]. The first item is the subscription's price; the others are recurring add-ons (subscription items) billed on every renewal. All items must be recurring, in one currency and on one interval (400 MIXED_INTERVALS / CURRENCY_MISMATCH; a one-time price is 400 PRICE_NOT_RECURRING). |
items[].priceData | object | Inline recurring price { description, unitPrice, itemLocalCurrency, recurring: { interval, intervalCount? } }. PaymentHooks finds or creates one price per description, amount, currency and interval, so repeating the request reuses it. |
trialEndAt | string | ISO 8601 trial end; must be a valid future timestamp (400 VALIDATION_ERROR otherwise). Overrides the price's trialDays. The subscription starts as trialing and the first billing period starts at the trial end. |
gatewayConnectionId | string | Gateway connection to bill through. Stored as gateway. |
metadata | object | Key-value pairs for your internal reference. |
collectionMethod | string | How renewals are collected. Omitted: charge_automatically when the customer has an active saved payment method PaymentHooks can debit for the renewal amount (variable-amount mandate on Stripe, Razorpay, Cashfree, PhonePe or PayPal, in this currency, within its maximum), else send_invoice (an invoice with a pay link is emailed 7 days before each renewal). charge_automatically without such a method is 422 NO_SAVED_PAYMENT_METHOD. The response's collection { method, reason, paymentMethodLabel } says what was chosen. |
Returns 201 on success; 400 VALIDATION_ERROR if customerId is missing, neither (or both) of priceId and items is sent, or trialEndAt is not a valid future timestamp; 404 NOT_FOUND if the price or customer does not exist (or belongs to another account); 422 INVALID_STATE if the price has an unsupported billing interval; 503 SCHEDULING_FAILED (with Retry-After) if the first renewal could not be scheduled, in which case the subscription is not created and you can safely retry; or 500 on a server error; 422 NO_SAVED_PAYMENT_METHOD for collectionMethod: "charge_automatically" without a usable saved method. With a trial (from trialEndAt, the price's trialDays or your default trial days) the status is trialing, trialStart and trialEndsAt are set, the first period starts at the trial end, and nextPaymentAt is the trial end. Without a trial, nextPaymentAt is the end of the first period.
List subscriptions
curl "https://paymenthooks.com/api/v1/subscriptions?status=active&page=1&pageSize=10" \
-H "Authorization: Bearer phk_live_..."| Field | Type | Description |
|---|---|---|
status | string | Exact match: active, trialing, past_due, paused or cancelled. |
search | string | Case-insensitive match on the customer's ID, email or name. |
businessEntityId | string | Only subscriptions of this business (one of yours, else 400 VALIDATION_ERROR). An API key scoped to a business always sees only its own. |
page | integerDefault: | 1-based page number. |
pageSize | integerDefault: | Items per page, 1-100. Results are always newest first. |
Endpoints & Responses
Every endpoint returns the same camelCase subscription record (e.g. currentPeriodEnd, cancelledAt, nextPaymentAt); retrieve also embeds a customer summary. Subscriptions outside your account return 404 NOT_FOUND. PUT accepts only metadata; any other field returns 400 VALIDATION_ERROR.
| Field | Type | Description |
|---|---|---|
metadata | object | Replaces the stored metadata object entirely (it is not merged). This is the only accepted field: any other field (e.g. priceId, status) returns 400 VALIDATION_ERROR. |
/api/v1/subscriptionsCreate a subscription (201, camelCase record). With a trial the status is trialing. Supports Idempotency-Key.{
"customerId": "ph_cus_8f14e45fceea167a5a36dedd4bea2543",
"priceId": "ph_pri_c20ad4d76fe97759aa27a0c99bff6710",
"gatewayConnectionId": "ph_gwc_1679091c5a880faf6fb5e6087eb1b2dc",
"trialEndAt": "2026-05-15T00:00:00.000Z",
"metadata": { "plan": "pro" }
}{
"data": {
"id": "ph_sub_aab3238922bcc25a6f606eb525ffdc56",
"merchantId": "ph_mrc_c9f0f895fb98ab9159f51fd0297e236d",
"customerId": "ph_cus_8f14e45fceea167a5a36dedd4bea2543",
"productId": "ph_pro_6512bd43d9caa6e02c990b0a82652dca",
"priceId": "ph_pri_c20ad4d76fe97759aa27a0c99bff6710",
"planId": "ph_pro_6512bd43d9caa6e02c990b0a82652dca",
"scheduleId": null,
"status": "trialing",
"billingCycle": "month",
"itemLocalCurrency": "USD",
"itemLocalCurrencyAmount": 2900,
"itemAmountUsdCents": 2900,
"itemUsdToLocalCurrencyRate": 1,
"quantity": 1,
"interval": "month",
"intervalCount": 1,
"gateway": "ph_gwc_1679091c5a880faf6fb5e6087eb1b2dc",
"gatewaySubscriptionId": null,
"currentPeriodStart": "2026-05-15T00:00:00.000Z",
"currentPeriodEnd": "2026-06-15T00:00:00.000Z",
"nextPaymentAt": "2026-05-15T00:00:00.000Z",
"trialStart": "2026-05-01T00:00:00.000Z",
"trialEndsAt": "2026-05-15T00:00:00.000Z",
"cancelledAt": null,
"pausedAt": null,
"cancelAtPeriodEnd": false,
"failedPaymentCount": 0,
"lastPaymentFailedAt": null,
"metadata": { "plan": "pro" },
"createdAt": "2026-05-01T00:00:00.000Z",
"updatedAt": "2026-05-01T00:00:00.000Z"
},
"error": null
}/api/v1/subscriptions?status=active&page=1&pageSize=10List subscriptions (camelCase records with embedded customer and product name){
"data": [
{
"id": "ph_sub_aab3238922bcc25a6f606eb525ffdc56",
"subscription_id": "ph_sub_aab3238922bcc25a6f606eb525ffdc56",
"customerId": "ph_cus_8f14e45fceea167a5a36dedd4bea2543",
"priceId": "ph_pri_c20ad4d76fe97759aa27a0c99bff6710",
"status": "active",
"itemLocalCurrency": "USD",
"itemLocalCurrencyAmount": 2900,
"itemAmountUsdCents": 2900,
"itemUsdToLocalCurrencyRate": 1,
"currentPeriodStart": "2026-05-15T00:00:00.000Z",
"currentPeriodEnd": "2026-06-15T00:00:00.000Z",
"nextPaymentAt": "2026-06-15T00:00:00.000Z",
"cancelAtPeriodEnd": false,
"customer": { "id": "ph_cus_8f14e45fceea167a5a36dedd4bea2543", "name": "Jane Doe", "email": "[email protected]" },
"price": { "product": { "name": "Pro Plan" } },
"createdAt": "2026-05-01T00:00:00.000Z"
}
],
"meta": { "total": 1, "page": 1, "pageSize": 10 },
"error": null,
"livemode": true
}/api/v1/subscriptions/:subscriptionIdRetrieve a subscription (same camelCase record as list and create, plus a customer summary){
"data": {
"id": "ph_sub_aab3238922bcc25a6f606eb525ffdc56",
"merchantId": "ph_mrc_c9f0f895fb98ab9159f51fd0297e236d",
"customerId": "ph_cus_8f14e45fceea167a5a36dedd4bea2543",
"productId": "ph_pro_6512bd43d9caa6e02c990b0a82652dca",
"priceId": "ph_pri_c20ad4d76fe97759aa27a0c99bff6710",
"planId": "ph_pro_6512bd43d9caa6e02c990b0a82652dca",
"scheduleId": null,
"status": "trialing",
"billingCycle": "month",
"itemLocalCurrency": "USD",
"itemLocalCurrencyAmount": 2900,
"itemAmountUsdCents": 2900,
"itemUsdToLocalCurrencyRate": 1,
"quantity": 1,
"interval": "month",
"intervalCount": 1,
"gateway": "ph_gwc_1679091c5a880faf6fb5e6087eb1b2dc",
"gatewaySubscriptionId": null,
"currentPeriodStart": "2026-05-15T00:00:00.000Z",
"currentPeriodEnd": "2026-06-15T00:00:00.000Z",
"nextPaymentAt": "2026-05-15T00:00:00.000Z",
"trialStart": "2026-05-01T00:00:00.000Z",
"trialEndsAt": "2026-05-15T00:00:00.000Z",
"cancelledAt": null,
"pausedAt": null,
"cancelAtPeriodEnd": false,
"failedPaymentCount": 0,
"lastPaymentFailedAt": null,
"metadata": { "plan": "pro" },
"createdAt": "2026-05-01T00:00:00.000Z",
"updatedAt": "2026-05-01T00:00:00.000Z",
"customer": { "id": "ph_cus_8f14e45fceea167a5a36dedd4bea2543", "name": "Jane Doe", "email": "[email protected]", "phone": null, "status": "active" }
},
"error": null
}/api/v1/subscriptions/:subscriptionIdUpdate subscription metadata only (returns the camelCase record){
"metadata": { "plan": "pro", "seats": "5" }
}{
"data": {
"id": "ph_sub_aab3238922bcc25a6f606eb525ffdc56",
"merchantId": "ph_mrc_c9f0f895fb98ab9159f51fd0297e236d",
"customerId": "ph_cus_8f14e45fceea167a5a36dedd4bea2543",
"productId": "ph_pro_6512bd43d9caa6e02c990b0a82652dca",
"priceId": "ph_pri_c20ad4d76fe97759aa27a0c99bff6710",
"planId": "ph_pro_6512bd43d9caa6e02c990b0a82652dca",
"scheduleId": null,
"status": "trialing",
"billingCycle": "month",
"itemLocalCurrency": "USD",
"itemLocalCurrencyAmount": 2900,
"itemAmountUsdCents": 2900,
"itemUsdToLocalCurrencyRate": 1,
"quantity": 1,
"interval": "month",
"intervalCount": 1,
"gateway": "ph_gwc_1679091c5a880faf6fb5e6087eb1b2dc",
"gatewaySubscriptionId": null,
"currentPeriodStart": "2026-05-15T00:00:00.000Z",
"currentPeriodEnd": "2026-06-15T00:00:00.000Z",
"nextPaymentAt": "2026-05-15T00:00:00.000Z",
"trialStart": "2026-05-01T00:00:00.000Z",
"trialEndsAt": "2026-05-15T00:00:00.000Z",
"cancelledAt": null,
"pausedAt": null,
"cancelAtPeriodEnd": false,
"failedPaymentCount": 0,
"lastPaymentFailedAt": null,
"metadata": { "plan": "pro", "seats": "5" },
"createdAt": "2026-05-01T00:00:00.000Z",
"updatedAt": "2026-05-01T00:00:00.000Z"
},
"error": null
}/api/v1/subscriptions/:subscriptionId/pausePause an active or trialing subscription (camelCase record){
"data": {
"id": "ph_sub_aab3238922bcc25a6f606eb525ffdc56",
"status": "paused",
"pausedAt": "2026-05-16T10:30:00.000Z",
"nextPaymentAt": null,
"updatedAt": "2026-05-16T10:30:00.000Z"
},
"error": null
}/api/v1/subscriptions/:subscriptionId/resumeResume a paused subscription (camelCase record){
"data": {
"id": "ph_sub_aab3238922bcc25a6f606eb525ffdc56",
"status": "active",
"pausedAt": null,
"currentPeriodStart": "2026-05-15T00:00:00.000Z",
"currentPeriodEnd": "2026-06-15T00:00:00.000Z",
"updatedAt": "2026-05-16T11:00:00.000Z"
},
"error": null
}/api/v1/subscriptions/:subscriptionId/cancelCancel immediately (default body or none) (camelCase record){
"cancelAtPeriodEnd": false
}{
"data": {
"id": "ph_sub_aab3238922bcc25a6f606eb525ffdc56",
"status": "cancelled",
"cancelledAt": "2026-05-16T12:00:00.000Z",
"cancelAtPeriodEnd": false,
"nextPaymentAt": null,
"updatedAt": "2026-05-16T12:00:00.000Z",
"events": [],
"cancellationCredit": {
"id": "ph_crn_70efdf2ec9b086079795c442636b55fb",
"creditNoteNumber": "CN-LZ4K2Q-7XQ1",
"itemLocalCurrencyAmount": 1880,
"itemLocalCurrency": "USD"
}
},
"error": null
}/api/v1/subscriptions/:subscriptionId/cancelCancel at period end: the status is unchanged until the next renewal date, when the subscription is cancelled instead of renewed{
"cancelAtPeriodEnd": true
}{
"data": {
"id": "ph_sub_aab3238922bcc25a6f606eb525ffdc56",
"status": "active",
"cancelledAt": null,
"cancelAtPeriodEnd": true,
"nextPaymentAt": "2026-06-15T00:00:00.000Z",
"updatedAt": "2026-05-16T12:00:00.000Z",
"events": []
},
"error": null
}/api/v1/subscriptions/:subscriptionId/preview-prorationPreview the proration for a price change (read-only, nothing is changed). Both prices must share an itemLocalCurrency.{
"newPriceId": "ph_pri_6f4922f45568161a8cdf4ad2299f6d23",
"prorationDate": "2026-05-20T00:00:00.000Z"
}{
"data": {
"subscriptionId": "ph_sub_aab3238922bcc25a6f606eb525ffdc56",
"currentPriceId": "ph_pri_c20ad4d76fe97759aa27a0c99bff6710",
"newPriceId": "ph_pri_6f4922f45568161a8cdf4ad2299f6d23",
"prorationDate": "2026-05-20T00:00:00.000Z",
"prorationCreditLocalCurrencyAmount": 2432,
"prorationDebitLocalCurrencyAmount": 8216,
"prorationNetLocalCurrencyAmount": 5784,
"itemLocalCurrency": "USD",
"remainingDays": 26,
"description": "Prorated upgrade from Pro Plan to Pro Plan Plus"
},
"error": null,
"livemode": true
}Pause, resume & cancel
- Pause — only
activeortrialingsubscriptions; otherwise422 INVALID_STATE. Setsstatus: "paused",pausedAt, clearsnextPaymentAt, cancels pending renewals and dispatchessubscription.paused. - Resume — only
pausedsubscriptions; otherwise422 INVALID_STATE. Setsstatus: "active", clearspausedAt, re-schedules the next renewal (at the end of the paid period, or immediately if it has lapsed) and dispatchessubscription.resumed. If the renewal cannot be scheduled the subscription stayspausedand the call returns502 SCHEDULING_FAILED. - Cancel — body
{ "cancelAtPeriodEnd": true }sets thecancelAtPeriodEndflag and leaves the current status (e.g.active) unchanged; the customer keeps access for the period already paid. Asubscription.cancelledwebhook is dispatched immediately with the unchanged status,cancel_at_period_end: trueandcanceled_at: null. When the period ends, the subscription is cancelled instead of renewed (no charge):status: "cancelled",cancelledAtis set, and a secondsubscription.cancelledis dispatched. Any other body (or none) cancels immediately:status: "cancelled",cancelledAtis set, pending renewals are cancelled and, unless you disabled prorate-on-cancel, a credit note for the unused part of a period the customer paid for is issued and returned ascancellationCredit. A period that was never paid (a trial, or a subscription created withPOST /subscriptionswhose first renewal has not been collected) gets no credit. Cancelling an already-cancelled subscription returns422 INVALID_STATE. - Undo —
POST /api/v1/subscriptions/:id/reactivateclearscancelAtPeriodEndbefore the period ends; the subscription renews normally andsubscription.updatedis dispatched. - Customers — cancel when Allow self-cancellation is on, and pause / resume only when Allow pause is on (otherwise
403 FORBIDDEN).
Change plan
POST /api/v1/subscriptions/:id/change-plan moves an active or trialingsubscription to another recurring price in the same currency (the dashboard's Change plan action). Preview the amounts first with preview-proration. With proration, a downgrade switches now and credits the unused value as a credit note and customer balance that later renewals use first; an upgrade is charged the prorated difference on a saved authorisation that supports it, otherwise the response is 202 with a paymentUrl for the customer and the plan switches once it is paid. Without proration the plan switches now and the next renewal charges the new price. A trialing subscription switches with nothing billed. A subscription set to cancel at period end must be reactivated first.
| Field | Type | Description |
|---|---|---|
newPriceId | string | An active recurring (not metered) price of yours in the subscription's itemLocalCurrency. The subscription keeps its quantity: its new amount is this price x quantity. |
prorate | boolean | Bill or credit the difference for the rest of the period now. Omitted: Settings > Subscriptions > Prorate plan changes (default true). false: the plan switches now, nothing is billed or credited, and the next renewal charges the new price. |
effective | stringDefault: | now or period_end. period_end schedules the change for the end of the current period: the customer keeps the current plan until then, the renewal that starts the next period bills the new price, nothing is prorated (prorate: true is refused). One change can be scheduled; a new one replaces it. 409 SCHEDULE_ACTIVE when a subscription schedule drives the subscription. If the plan is changed another way, or the new price is archived before the period ends, the scheduled change is dropped and the subscription renews on its current plan. |
/api/v1/subscriptions/:subscriptionId/change-planChange the plan. 200 switched; 202 payment_required (send the customer paymentUrl, the plan switches once it is paid); 402 PAYMENT_FAILED; 409 PLAN_CHANGE_PENDING / CONFLICT; 422 INVALID_STATE.{
"newPriceId": "ph_pri_6f4922f45568161a8cdf4ad2299f6d23",
"prorate": true
}{
"data": {
"subscriptionId": "ph_sub_5d41402abc4b2a76b9719d911017c592",
"status": "switched",
"newPriceId": "ph_pri_6f4922f45568161a8cdf4ad2299f6d23",
"prorationCreditLocalCurrencyAmount": 2432,
"prorationDebitLocalCurrencyAmount": 8216,
"prorationNetLocalCurrencyAmount": 5784,
"itemLocalCurrency": "USD",
"prorationApplied": true,
"invoiceId": "ph_inv_1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e",
"paymentId": "ph_pay_4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b"
},
"error": null
}/api/v1/subscriptions/:subscriptionId/change-planSchedule a change for the end of the period. 200 with status scheduled and effectiveAt; subscription.updated is sent now and again when the renewal applies it.{
"newPriceId": "ph_pri_6f4922f45568161a8cdf4ad2299f6d23",
"effective": "period_end"
}{
"data": {
"subscriptionId": "ph_sub_5d41402abc4b2a76b9719d911017c592",
"status": "scheduled",
"newPriceId": "ph_pri_6f4922f45568161a8cdf4ad2299f6d23",
"effectiveAt": "2026-12-15T00:00:00.000Z",
"prorationApplied": false,
"itemLocalCurrency": "USD",
"scheduledPlanChange": {
"newPriceId": "ph_pri_6f4922f45568161a8cdf4ad2299f6d23",
"fromPriceId": "ph_pri_c20ad4d76fe97759aa27a0c99bff6710",
"effectiveAt": "2026-12-15T00:00:00.000Z",
"scheduledAt": "2026-11-19T10:00:00.000Z",
"source": "api"
}
},
"error": null
}/api/v1/subscriptions/:subscriptionId/change-planCancel the change scheduled for the period end. removed false when none was scheduled.{
"data": {
"subscriptionId": "ph_sub_5d41402abc4b2a76b9719d911017c592",
"scheduledPlanChange": null,
"removed": true
},
"error": null
}/api/v1/subscriptions/:subscriptionId/amendChange a live (active, trialing or past_due) subscription other than its plan: one or more of the fields above. 200 with the subscription and `changed`; 400 VALIDATION_ERROR; 409 CONFLICT or SCHEDULE_ACTIVE; 422 INVALID_STATE; 503 SCHEDULING_FAILED (nothing was changed; retry). Sends subscription.updated with previous_attributes.{
"billingCycleAnchor": "2026-12-01T00:00:00.000Z",
"quantity": 3
}{
"data": {
"id": "ph_sub_5d41402abc4b2a76b9719d911017c592",
"status": "active",
"quantity": 3,
"itemLocalCurrency": "USD",
"itemLocalCurrencyAmount": 8700,
"itemAmountUsdCents": 8700,
"currentPeriodEnd": "2026-12-01T00:00:00.000Z",
"nextPaymentAt": "2026-12-01T00:00:00.000Z",
"changed": ["currentPeriodEnd", "nextPaymentAt", "quantity", "itemLocalCurrencyAmount", "itemAmountUsdCents", "itemUsdToLocalCurrencyRate"]
},
"error": null
}/api/v1/subscriptions/:subscriptionId/reactivateUndo a cancellation at period end before the period ends; the subscription renews normally. 422 INVALID_STATE when it is not set to cancel or has already ended.{
"data": {
"id": "ph_sub_5d41402abc4b2a76b9719d911017c592",
"status": "active",
"cancelAtPeriodEnd": false,
"nextPaymentAt": "2026-06-15T00:00:00.000Z"
},
"error": null
}Change a live subscription
POST /api/v1/subscriptions/:id/amend changes an active, trialing or past_duesubscription without changing its plan: its billing date, its trial, its quantity, its coupon, a cancellation date, or a pause with an automatic resume (the dashboard's Edit subscription). The renewal is rescheduled through the same scheduling every renewal uses; when that fails nothing is changed and the response is 503 SCHEDULING_FAILED. A subscription driven by a subscription schedule cannot move its dates or quantity (409 SCHEDULE_ACTIVE).
| Field | Type | Description |
|---|---|---|
billingCycleAnchor | string (ISO 8601) | Move the next renewal to this date: in the future and within one billing period. The current period is shortened or extended to it; nothing is charged or credited for the difference. Not for a trialing subscription (change trialEnd). |
trialEnd | string | Trialing subscriptions only. now ends the trial and renews now; a future date (within 2 years) extends or shortens it. |
quantity | integer | 1-10,000. The base price's quantity from the next renewal: itemLocalCurrencyAmount / itemAmountUsdCents become the price x the new quantity. To prorate seats now, add them as an item (POST /subscriptions/:id/items). |
couponId | string | null | Apply an active coupon with duration repeating or forever to the remaining renewals (its duration counts from now), or null to remove it. A once coupon is 422 INVALID_STATE. |
cancelAt | string (ISO 8601) | null | Cancel on this future date: the subscription ends when the period that contains it ends (no partial period is billed). null removes it. |
pauseUntil | string (ISO 8601) | Pause now and resume automatically on this date (within one year). Cannot be combined with other fields. Resuming re-arms the renewal at the end of the paid period, or now when it has lapsed. |
Coupons on renewals
A coupon applied to a subscription checkout keeps discounting renewals according to its duration. The discount is taken before tax from the base price and recurring add-ons (only the coupon's appliesTo prices when set), never from usage, one-time or proration lines, and is shown on the renewal invoice as itemDiscountLocalCurrencyAmount / itemDiscountAmountUsdCents. After a plan change the discount continues only while the new price is covered. The subscription records couponId, couponEndsAt and couponDiscountedPeriods. Duration is fixed when the coupon is created.
| Field | Type | Description |
|---|---|---|
once | duration | The payment the coupon is applied to. A subscription renews at full price. |
repeating | duration | With durationInMonths (1-36): every renewal period that starts before purchase + N months is discounted. |
forever | duration | Every renewal is discounted while the subscription lives. |
Subscription settings
Settings > Subscriptions, also GET/PUT /api/v1/merchant/settings (scopes account:read / account:write). Every default is the behaviour when the setting is not saved.
| Field | Type | Description |
|---|---|---|
gracePeriodDays | integerDefault: | 0-30. A past_due subscription keeps its features this many days after the first failed payment (with Features > past-due access on). 0: until retries end. |
retryAttempts | integerDefault: | 1-8. Automatic retries of a failed renewal. A hard decline (lost or stolen card, closed account, invalid number, expired card, fraud) is never retried: the customer is emailed to update the payment method and the subscription waits in past_due. |
dunningFinalAction | stringDefault: | When retries run out: cancel (subscription.cancelled), pause (subscription.paused; paying from the billing page resumes it) or past_due (no further retry; subscription.updated). Any other value is 400 VALIDATION_ERROR. |
retryHourOfDay | integer | nullDefault: | 0-23. Dunning retries run on the days of dunningCadenceDays, moved later to this hour in your account timezone. null: exactly N x 24 h after the failure. |
smartRetry | booleanDefault: | A retry that falls on a Saturday or Sunday (your timezone) runs on Monday. |
selfCancellation | booleanDefault: | Customers can cancel from the billing page and portal (403 otherwise). |
allowPause | booleanDefault: | Customers can pause and resume from the billing page (POST /billing-page/pause) and portal (403 otherwise). Merchants can always pause. |
prorateOnChange | booleanDefault: | An immediate cancellation credits the unused time of a period the customer paid for (never a trial or an uncollected first period). |
prorateOnPlanChange | booleanDefault: | Plan changes (dashboard, API, billing page) are prorated. Off: the new price applies from the next renewal. |
billingCycleAnchor | stringDefault: | subscription_start or first_of_month. For subscriptions created through POST /subscriptions on month or year prices: first_of_month ends the first period on the next 1st (your timezone), so renewals fall on the 1st. |
defaultTrialDays | integerDefault: | 0-730. Trial for POST /subscriptions when neither trialEndAt nor the price's trialDays sets one. |
Subscription schedules
A schedule (ph_sch_...) changes one subscription's price over time: a discounted first quarter, a trial on the second plan, an annual ramp. The schedule owns a single subscription: it is created from phase 0, and each later phase changes that same subscription's price in place, so its id, payment method, invoices and history stay the same. PaymentHooks moves between phases itself at each renewal; you do not call anything.
Create a schedule
Starting now (no startDate), the subscription is created exactly as POST /api/v1/subscriptions creates one: first period, tax, how renewals are collected, the first renewal scheduled and subscription.created sent. The response carries its subscriptionId. With a future startDate the schedule is NOT_STARTED and the subscription is created at that time.
curl https://paymenthooks.com/api/v1/subscription-schedules \
-X POST \
-H "Authorization: Bearer phk_live_..." \
-H "Content-Type: application/json" \
-H "Idempotency-Key: ramp-acme-2026" \
-d '{
"customerId": "ph_cus_8f14e45fceea167a5a36dedd4bea2543",
"endBehavior": "release",
"phases": [
{ "priceId": "ph_pri_c20ad4d76fe97759aa27a0c99bff6710", "iterations": 3, "trialDays": 14 },
{ "priceId": "ph_pri_6f4922f45568161a8cdf4ad2299f6d23" }
]
}'| Field | Type | Description |
|---|---|---|
customerId | string | Your customer. The schedule's subscription is created for them. |
phases | array | 1-20 phases, run in order. See the phase fields below. |
startDate | string (ISO 8601) | When phase 0 begins. Omitted, now or in the past: the schedule starts now and the response includes subscriptionId. In the future: the schedule is NOT_STARTED and its subscription is created at that time. |
endBehavior | stringDefault: | After the last phase: release (the schedule detaches and the subscription keeps renewing on the last phase's price) or cancel (the subscription ends when the last phase does; the last phase needs iterations). |
collectionMethod | string | How the subscription's renewals are collected, exactly as on POST /subscriptions: charge_automatically (needs a usable saved payment method, else 422 NO_SAVED_PAYMENT_METHOD) or send_invoice. Omitted: debit a usable saved method when the customer has one, otherwise invoice each renewal. |
defaultPaymentMethodId | string | Stored on the schedule for your reference. |
metadata | object | Your key-value data, returned on the schedule. |
Phases and iterations
| Field | Type | Description |
|---|---|---|
priceId | string | An active recurring (not metered) price of yours. Every phase uses the same itemLocalCurrency; intervals may differ. |
iterations | integer | 1-1000 paid billing cycles of this phase's price. Required on every phase except the last; a last phase without it runs until you release or cancel the schedule. |
trialDays | integerDefault: | 0-730. A trial at the start of the phase, before its first paid cycle (not counted in iterations). Nothing is billed during it; the price's own trialDays and your default trial days do not apply to schedule phases. |
prorate | booleanDefault: | Used only when you advance into this phase mid-period (POST /advance): bill or credit the difference for the rest of the period. A phase that begins at its renewal never prorates. |
metadata | object | Your key-value data for the phase. |
- A phase lasts
iterationspaid billing cycles of its price. Its trial, when it has one, comes first and is not a cycle. A cycle is counted once per billing period, so a failed payment that is retried, a postponed debit or a duplicate delivery never counts twice. - The next phase begins at the renewal after the phase's last cycle. That renewal changes the subscription to the next phase's price and bills it, with no proration (the change is exactly at the period boundary).
subscription.updatedis sent with the previous price inprevious_attributes, then the usualsubscription.renewed. - A phase with
trialDaysbegins with its trial instead: the subscription istrialing, nothing is billed, and the first cycle of the phase is billed at the trial end. - A subscription renewed by invoice (
send_invoice) follows the same phases: each period's invoice, issued 7 days ahead, is for the price of the phase that period belongs to. currentPhaseon the schedule shows the running phase,cyclesBilledso far and aprojectedEndsAt(projected: a postponed debit moves later dates a little).
End behaviour
With endBehavior: "release" (the default), the renewal after the last phase releases the schedule: it becomes RELEASED, subscription_schedule.released is sent, and the subscription keeps renewing on the last price. With "cancel", the last cycle of the last phase sets the subscription to cancel at its period end (you see cancelAtPeriodEnd: true for that last period); when it ends nothing more is billed, subscription.cancelled is sent and the schedule is COMPLETED. If you undo that cancellation, the subscription continues and the schedule is released.
NOT_STARTEDstartDate is in the future; no subscription yet.ACTIVEDriving its subscription through the phases.COMPLETEDThe last phase ended and, with endBehavior cancel, so did the subscription.RELEASEDDetached (POST /release, or endBehavior release after the last phase). The subscription keeps running.CANCELEDCancelled through POST /cancel, or its subscription was cancelled (by you, or after failed payment retries).Release, cancel and advance
- Release stops the schedule from changing the subscription. The subscription itself is not touched.
- Cancel cancels the schedule and its subscription: at the end of the current period by default, or now with
cancelAtPeriodEnd: false. - Advance moves to the next phase now, mid-period, using the next phase's
prorateflag exactly like a plan change (a downgrade credits the unused time; an upgrade is charged on a saved payment method that allows it, otherwise the response carries apaymentUrl). The rest of the current period is extra: the new phase then runs its fulliterations. A next phase with a trial cannot begin mid-period (that period is paid for), so it begins with its trial at the next renewal. SendfromPhaseIndexso a retry never advances twice.
| Field | Type | Description |
|---|---|---|
cancelAtPeriodEnd | booleanDefault: | true: the subscription ends at the end of its current period (the customer keeps what they paid for). false: it is cancelled now, exactly like POST /subscriptions/:id/cancel (pending renewals stop; unused time is credited unless you turned that off). Any other field is 400 VALIDATION_ERROR. |
invoiceNow | boolean | Accepted for SDK 3.0.0 (ScheduleCancelParams): true is cancelAtPeriodEnd: false. Prefer cancelAtPeriodEnd; sending both with contradicting values is 400 VALIDATION_ERROR. |
| Field | Type | Description |
|---|---|---|
fromPhaseIndex | integer | The phase you saw. The advance applies only from it: a retried request returns the schedule with phaseChange.status: "already_advanced" instead of advancing twice, and any other phase is 409 PHASE_CHANGED. The endpoint also honours Idempotency-Key. |
/api/v1/subscription-schedulesCreate a schedule. 201 with the schedule (and its subscriptionId when it starts now). 400 VALIDATION_ERROR; 404 NOT_FOUND (customer or a phase price); 422 INVALID_STATE (archived, one-time or metered price, or mixed currencies) or NO_SAVED_PAYMENT_METHOD; 503 SCHEDULING_FAILED when the subscription's renewal or the schedule's start could not be scheduled: nothing was created, retry with the same Idempotency-Key.{
"customerId": "ph_cus_8f14e45fceea167a5a36dedd4bea2543",
"phases": [
{ "priceId": "ph_pri_c20ad4d76fe97759aa27a0c99bff6710", "iterations": 3, "trialDays": 14 },
{ "priceId": "ph_pri_6f4922f45568161a8cdf4ad2299f6d23" }
]
}{
"data": {
"id": "ph_ssc_c4ca4238a0b923820dcc509a6f75849b",
"scheduleId": "ph_sch_3a7d1f5b9e2c6a0d4f8b2e6c0a4d8f1b",
"merchantId": "ph_mrc_c9f0f895fb98ab9159f51fd0297e236d",
"customerId": "ph_cus_8f14e45fceea167a5a36dedd4bea2543",
"subscriptionId": "ph_sub_5d41402abc4b2a76b9719d911017c592",
"phaseCount": 2,
"status": "ACTIVE",
"endBehavior": "release",
"collectionMethod": null,
"startDate": "2026-11-18T10:00:00.000Z",
"endDate": null,
"releasedAt": null,
"defaultPaymentMethodId": null,
"currentPhase": {
"phaseIndex": 0,
"priceId": "ph_pri_c20ad4d76fe97759aa27a0c99bff6710",
"iterations": 3,
"cyclesBilled": 0,
"startedAt": "2026-11-18T10:00:00.000Z",
"trialEndsAt": "2026-12-02T10:00:00.000Z",
"projectedEndsAt": "2027-03-02T10:00:00.000Z",
"begun": true
},
"metadata": {},
"createdAt": "2026-11-18T10:00:00.000Z",
"updatedAt": "2026-11-18T10:00:00.000Z",
"phases": [
{
"id": "ph_ssp_a87ff679a2f3e71d9181a67b7542122c",
"scheduleId": "ph_ssc_c4ca4238a0b923820dcc509a6f75849b",
"phaseIndex": 0,
"priceId": "ph_pri_c20ad4d76fe97759aa27a0c99bff6710",
"trialDays": 14,
"iterations": 3,
"prorate": true,
"metadata": {}
},
{
"id": "ph_ssp_e4da3b7fbbce2345d7772b0674a318d5",
"scheduleId": "ph_ssc_c4ca4238a0b923820dcc509a6f75849b",
"phaseIndex": 1,
"priceId": "ph_pri_6f4922f45568161a8cdf4ad2299f6d23",
"trialDays": 0,
"iterations": null,
"prorate": true,
"metadata": {}
}
]
},
"error": null
}/api/v1/subscription-schedules/:scheduleIdRetrieve a schedule by its ph_sch_ id. List with GET /api/v1/subscription-schedules?customerId=&status=&page=&pageSize=. Another account's schedule is 404.{
"data": {
"id": "ph_ssc_c4ca4238a0b923820dcc509a6f75849b",
"scheduleId": "ph_sch_3a7d1f5b9e2c6a0d4f8b2e6c0a4d8f1b",
"merchantId": "ph_mrc_c9f0f895fb98ab9159f51fd0297e236d",
"customerId": "ph_cus_8f14e45fceea167a5a36dedd4bea2543",
"subscriptionId": "ph_sub_5d41402abc4b2a76b9719d911017c592",
"phaseCount": 2,
"status": "ACTIVE",
"endBehavior": "release",
"collectionMethod": null,
"startDate": "2026-11-18T10:00:00.000Z",
"endDate": null,
"releasedAt": null,
"defaultPaymentMethodId": null,
"currentPhase": {
"phaseIndex": 0,
"priceId": "ph_pri_c20ad4d76fe97759aa27a0c99bff6710",
"iterations": 3,
"cyclesBilled": 2,
"startedAt": "2026-11-18T10:00:00.000Z",
"trialEndsAt": "2026-12-02T10:00:00.000Z",
"projectedEndsAt": "2027-03-02T10:00:00.000Z",
"begun": true
},
"metadata": {},
"createdAt": "2026-11-18T10:00:00.000Z",
"updatedAt": "2026-11-18T10:00:00.000Z",
"phases": [
{
"id": "ph_ssp_a87ff679a2f3e71d9181a67b7542122c",
"scheduleId": "ph_ssc_c4ca4238a0b923820dcc509a6f75849b",
"phaseIndex": 0,
"priceId": "ph_pri_c20ad4d76fe97759aa27a0c99bff6710",
"trialDays": 14,
"iterations": 3,
"prorate": true,
"metadata": {}
},
{
"id": "ph_ssp_e4da3b7fbbce2345d7772b0674a318d5",
"scheduleId": "ph_ssc_c4ca4238a0b923820dcc509a6f75849b",
"phaseIndex": 1,
"priceId": "ph_pri_6f4922f45568161a8cdf4ad2299f6d23",
"trialDays": 0,
"iterations": null,
"prorate": true,
"metadata": {}
}
]
},
"error": null
}/api/v1/subscription-schedules/:scheduleId/advanceMove to the next phase now. 200 with phaseChange.status switched, payment_required (send the customer paymentUrl; the price changes once it is paid, or at the next renewal at the latest), begins_at_next_renewal (the next phase has a trial) or already_advanced. 402 PAYMENT_FAILED; 409 INVALID_STATE (last phase, not ACTIVE), PHASE_CHANGED, PLAN_CHANGE_PENDING or CONFLICT.{
"fromPhaseIndex": 0
}{
"data": {
"id": "ph_ssc_c4ca4238a0b923820dcc509a6f75849b",
"scheduleId": "ph_sch_3a7d1f5b9e2c6a0d4f8b2e6c0a4d8f1b",
"merchantId": "ph_mrc_c9f0f895fb98ab9159f51fd0297e236d",
"customerId": "ph_cus_8f14e45fceea167a5a36dedd4bea2543",
"subscriptionId": "ph_sub_5d41402abc4b2a76b9719d911017c592",
"phaseCount": 2,
"status": "ACTIVE",
"endBehavior": "release",
"collectionMethod": null,
"startDate": "2026-11-18T10:00:00.000Z",
"endDate": null,
"releasedAt": null,
"defaultPaymentMethodId": null,
"currentPhase": {
"phaseIndex": 1,
"priceId": "ph_pri_6f4922f45568161a8cdf4ad2299f6d23",
"iterations": null,
"cyclesBilled": 0,
"startedAt": "2027-01-10T09:30:00.000Z",
"trialEndsAt": null,
"projectedEndsAt": null,
"begun": true
},
"metadata": {},
"createdAt": "2026-11-18T10:00:00.000Z",
"updatedAt": "2026-11-18T10:00:00.000Z",
"phases": [
{
"id": "ph_ssp_a87ff679a2f3e71d9181a67b7542122c",
"scheduleId": "ph_ssc_c4ca4238a0b923820dcc509a6f75849b",
"phaseIndex": 0,
"priceId": "ph_pri_c20ad4d76fe97759aa27a0c99bff6710",
"trialDays": 14,
"iterations": 3,
"prorate": true,
"metadata": {}
},
{
"id": "ph_ssp_e4da3b7fbbce2345d7772b0674a318d5",
"scheduleId": "ph_ssc_c4ca4238a0b923820dcc509a6f75849b",
"phaseIndex": 1,
"priceId": "ph_pri_6f4922f45568161a8cdf4ad2299f6d23",
"trialDays": 0,
"iterations": null,
"prorate": true,
"metadata": {}
}
],
"phaseChange": {
"status": "switched",
"phaseIndex": 1,
"proration": {
"prorationCreditLocalCurrencyAmount": 1290,
"prorationDebitLocalCurrencyAmount": 3870,
"prorationNetLocalCurrencyAmount": 2580,
"invoiceId": "ph_inv_1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e",
"paymentId": "ph_pay_4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b"
}
}
},
"error": null
}/api/v1/subscription-schedules/:scheduleId/releaseDetach the schedule. The subscription is not changed and keeps renewing on its current price. Releasing a schedule that has not started yet means no subscription is ever created. Releasing again returns the schedule unchanged; 409 INVALID_STATE once it is COMPLETED or CANCELED.{
"data": {
"id": "ph_ssc_c4ca4238a0b923820dcc509a6f75849b",
"scheduleId": "ph_sch_3a7d1f5b9e2c6a0d4f8b2e6c0a4d8f1b",
"merchantId": "ph_mrc_c9f0f895fb98ab9159f51fd0297e236d",
"customerId": "ph_cus_8f14e45fceea167a5a36dedd4bea2543",
"subscriptionId": "ph_sub_5d41402abc4b2a76b9719d911017c592",
"phaseCount": 2,
"status": "RELEASED",
"endBehavior": "release",
"collectionMethod": null,
"startDate": "2026-11-18T10:00:00.000Z",
"endDate": "2027-01-10T09:30:00.000Z",
"releasedAt": "2027-01-10T09:30:00.000Z",
"defaultPaymentMethodId": null,
"currentPhase": {
"phaseIndex": 0,
"priceId": "ph_pri_c20ad4d76fe97759aa27a0c99bff6710",
"iterations": 3,
"cyclesBilled": 0,
"startedAt": "2026-11-18T10:00:00.000Z",
"trialEndsAt": "2026-12-02T10:00:00.000Z",
"projectedEndsAt": "2027-03-02T10:00:00.000Z",
"begun": true
},
"metadata": {},
"createdAt": "2026-11-18T10:00:00.000Z",
"updatedAt": "2026-11-18T10:00:00.000Z",
"phases": [
{
"id": "ph_ssp_a87ff679a2f3e71d9181a67b7542122c",
"scheduleId": "ph_ssc_c4ca4238a0b923820dcc509a6f75849b",
"phaseIndex": 0,
"priceId": "ph_pri_c20ad4d76fe97759aa27a0c99bff6710",
"trialDays": 14,
"iterations": 3,
"prorate": true,
"metadata": {}
},
{
"id": "ph_ssp_e4da3b7fbbce2345d7772b0674a318d5",
"scheduleId": "ph_ssc_c4ca4238a0b923820dcc509a6f75849b",
"phaseIndex": 1,
"priceId": "ph_pri_6f4922f45568161a8cdf4ad2299f6d23",
"trialDays": 0,
"iterations": null,
"prorate": true,
"metadata": {}
}
]
},
"error": null
}/api/v1/subscription-schedules/:scheduleId/cancelCancel the schedule and its subscription (at the end of the current period by default; now with cancelAtPeriodEnd false). 409 INVALID_STATE when it is already COMPLETED, RELEASED or CANCELED. To keep the subscription, release instead.{
"cancelAtPeriodEnd": false
}{
"data": {
"id": "ph_ssc_c4ca4238a0b923820dcc509a6f75849b",
"scheduleId": "ph_sch_3a7d1f5b9e2c6a0d4f8b2e6c0a4d8f1b",
"merchantId": "ph_mrc_c9f0f895fb98ab9159f51fd0297e236d",
"customerId": "ph_cus_8f14e45fceea167a5a36dedd4bea2543",
"subscriptionId": "ph_sub_5d41402abc4b2a76b9719d911017c592",
"phaseCount": 2,
"status": "CANCELED",
"endBehavior": "release",
"collectionMethod": null,
"startDate": "2026-11-18T10:00:00.000Z",
"endDate": "2027-01-10T09:30:00.000Z",
"releasedAt": null,
"defaultPaymentMethodId": null,
"currentPhase": {
"phaseIndex": 0,
"priceId": "ph_pri_c20ad4d76fe97759aa27a0c99bff6710",
"iterations": 3,
"cyclesBilled": 0,
"startedAt": "2026-11-18T10:00:00.000Z",
"trialEndsAt": "2026-12-02T10:00:00.000Z",
"projectedEndsAt": "2027-03-02T10:00:00.000Z",
"begun": true
},
"metadata": {},
"createdAt": "2026-11-18T10:00:00.000Z",
"updatedAt": "2026-11-18T10:00:00.000Z",
"phases": [
{
"id": "ph_ssp_a87ff679a2f3e71d9181a67b7542122c",
"scheduleId": "ph_ssc_c4ca4238a0b923820dcc509a6f75849b",
"phaseIndex": 0,
"priceId": "ph_pri_c20ad4d76fe97759aa27a0c99bff6710",
"trialDays": 14,
"iterations": 3,
"prorate": true,
"metadata": {}
},
{
"id": "ph_ssp_e4da3b7fbbce2345d7772b0674a318d5",
"scheduleId": "ph_ssc_c4ca4238a0b923820dcc509a6f75849b",
"phaseIndex": 1,
"priceId": "ph_pri_6f4922f45568161a8cdf4ad2299f6d23",
"trialDays": 0,
"iterations": null,
"prorate": true,
"metadata": {}
}
]
},
"error": null
}Webhooks
subscription_schedule.released is sent when a schedule stops driving a subscription that keeps running (POST /release, or the end of the last phase with endBehavior: "release"); releaseReason says which. Phase changes arrive as subscription.updated and subscription.renewed on the subscription, whose metadata carries subscriptionScheduleId; a schedule that ends its subscription sends subscription.cancelled.
{
"id": "ph_evt_3c7e9a1b5d2f4a6c8e0b2d4f6a8c1e3b",
"object": "event",
"type": "subscription_schedule.released",
"data": {
"object": {
"id": "ph_ssc_c4ca4238a0b923820dcc509a6f75849b",
"object": "subscription_schedule",
"scheduleId": "ph_sch_3a7d1f5b9e2c6a0d4f8b2e6c0a4d8f1b",
"subscriptionId": "ph_sub_5d41402abc4b2a76b9719d911017c592",
"customerId": "ph_cus_8f14e45fceea167a5a36dedd4bea2543",
"status": "RELEASED",
"endBehavior": "release",
"phaseIndex": 1,
"releasedAt": "2027-04-02T10:00:00.000Z",
"releaseReason": "end_behavior_release",
"currentPhase": {
"phaseIndex": 1,
"priceId": "ph_pri_6f4922f45568161a8cdf4ad2299f6d23",
"iterations": null,
"cyclesBilled": 3,
"begun": true
},
"metadata": {}
}
}
}Subscription lifecycle
The status field takes one of these values. Note the spelling cancelled (two Ls) in API responses and filters.
activeBilling normally. Subscriptions created with POST /api/v1/subscriptions without a trial start here.trialingIn a trial period. Set on create when trialEndAt or the price's trialDays applies, by a checkout whose recurring lines share the price's trialDays (nothing of them charged today; the card is saved without a charge), and for schedule phases with a trial. The first renewal, the reminder, the RBI pre-debit notice and the trial-ending email are scheduled for the trial end.past_dueA renewal charge failed. Retries are running per the dunning schedule.pausedPaused via the pause endpoint. No renewal charges until resumed.cancelledCancelled via the API, at period end when cancelAtPeriodEnd was set, or after dunning was exhausted. Terminal; cancelledAt is set.Automatic renewals
PaymentHooks owns the renewal. At the first subscription checkout the customer authorises automatic payments on the gateway (a saved card, token or mandate). On each renewal date PaymentHooks computes what the period owes (base price, add-ons, metered usage, pending items, tax), applies the customer's account credit, checks the authorisation's status and per-debit maximum, waits for the RBI pre-debit notice on Indian mandates, then debits the gateway itself. You do not trigger charges; you receive webhooks.
| Gateway | Authorisation | Checkout | Renewal debit | Per-debit limit | Result |
|---|---|---|---|---|---|
| Stripe | Saved card on a Stripe Customer (setup_future_usage=off_session) | First PaymentIntent is created for a Customer and saves the card; INR cards carry an RBI e-mandate (amount_type maximum). | Off-session PaymentIntent (off_session=true, confirm=true) with the renewal's idempotency key. | None (INR: the e-mandate maximum) | Immediate; bank debits confirm by payment_intent.* webhook |
| Razorpay | Recurring token (card, UPI Autopay, eMandate) | Authorisation order with token { max_amount, expire_at, frequency: as_presented }, opened in Checkout with customer_id and recurring. | New order, then POST /v1/payments/create/recurring with the token. | Token max_amount | Asynchronous: payment.captured / payment.failed webhook |
| Cashfree | Subscription mandate on an ON_DEMAND plan (UPI, card, eNACH) | POST /pg/subscriptions with plan_max_amount; the customer authorises on Cashfree's hosted subscription checkout. | POST /pg/subscriptions/pay, payment_type CHARGE (scheduled for the next day; Cashfree sends its own pre-debit notice). | plan_max_amount | Asynchronous: SUBSCRIPTION_PAYMENT_SUCCESS / _FAILED webhook |
| PhonePe | UPI Autopay mandate (amountType VARIABLE, frequency ON_DEMAND) | Standard Checkout SUBSCRIPTION_CHECKOUT_SETUP with maxAmount. | Redemption notify with autoDebit; PhonePe debits after the 24-hour notification window. | Mandate maxAmount; INR only | Asynchronous: subscription.redemption.order.* webhook (state read back from PhonePe) |
| CCAvenue | Card standing instruction (fixed amount) | Standing instruction registered with the first payment (si_type Fixed). | SIDebit command for the standing instruction reference. | The registered SI amount (usage or add-ons above it are refused) | Immediate |
| PayPal | Vaulted PayPal account (payment token, usage_type MERCHANT) | First order vaults the payer's account (store_in_vault ON_SUCCESS). Requires PayPal reference transactions on your account. | Order with payment_source.paypal.vault_id, captured in the same call. | None | Immediate |
The per-debit maximum asked of the customer is three times the period price (room for add-ons and usage). A renewal above it, or on an authorisation the customer revoked, is refused before the gateway is called and goes through dunning; the customer can pay and authorise a new payment method from the hosted billing page (Update payment method). Before a renewal is due, an active subscription without working automatic payments can be set up again without any charge (setup sessions). Each debit uses one idempotency key per subscription, billing period and retry, so a redelivered renewal never charges twice.
subscription.renewedA renewal was debited. latest_payment carries the payment id, amount and currency actually charged.invoice.paidThe renewal invoice was paid (billing_reason subscription_cycle, payment_intent = the payment id).payment.succeededThe renewal payment itself, Stripe PaymentIntent shape.subscription.renewal_failedThe debit failed or was refused before the gateway (failure_code mandate_amount_exceeded, mandate_inactive, mandate_currency_mismatch, plan_limit_reached). failure_reason and last_payment_error.message say why.payment.failedA renewal payment the gateway declined.mandate.updatedThe authorisation changed status (Stripe Mandate shape).payment_method.detachedThe customer revoked the authorisation at their bank or the gateway.subscription.renewal_dueOnly when PaymentHooks holds no authorisation it can debit: you collect the payment (reason says why).subscription.deletedSent with every subscription.cancelled once the subscription has ended (Stripe's customer.subscription.deleted).
Dunning & retries
When a scheduled renewal charge fails, the subscription moves to past_due and PaymentHooks retries the charge and emails the customer a link to update their payment method. The default schedule (3 retry attempts):
- 1Failure 1: status becomes past_due; retry 1 runs 1 day later
- 2Retry 1 fails: retry 2 runs 3 days later
- 3Retry 2 fails: retry 3 runs 5 days later
- 4Retry 3 fails: with the default final action the subscription is cancelled (status cancelled, cancelledAt set) and subscription.cancelled is dispatched with cancellation_details.reason "dunning_exhausted"
To customise the schedule, open Settings → Subscription Settings in the merchant dashboard. The retry schedule (days after each failed payment) sets the delay before each retry, Retry attempts (1-8) sets how many retries run, and When retries run out chooses cancel (default), pause (subscription.paused) or leave it past_due (subscription.updated). A hard decline (lost or stolen card, closed account, expired) is never retried: the customer is asked to update the payment method. When there are more attempts than delays, the last delay is reused. Turning off Auto-retry failed payments leaves the subscription past_due with no automatic retry, and turning off Dunning emails stops the reminder, final-notice, cancellation and recovery emails. Changes apply to the next failed payment.
Retry Payment
POST /v1/subscriptions/:id/retry opens a hosted checkout for the overdue period of a subscription, so the customer can pay it now instead of waiting for the next automatic retry. In the dashboard it is the Retry Payment button on the subscription page (next to the status); customers have the same button in the customer portal under My Subscriptions. It is available when a period is overdue: the subscription is past_due, paused because retries ran out, or its period has ended without a charge (subscription.renewal_due).
Returns 201 with sessionId, checkoutUrl, itemLocalCurrencyAmount and itemLocalCurrency: what the renewal owes (price, add-ons, usage and tax with the subscription's tax snapshot), in the subscription's currency. A second call for the same period returns the same open checkout. subscription.retry_created is dispatched.
| HTTP | Code | Meaning |
|---|---|---|
| 404 | NOT_FOUND | No such subscription for your account (or, from the customer portal, for this customer). |
| 422 | INVALID_STATE | Nothing is overdue: the subscription is active or trialing in its period, cancelled, or paused by you. |
| 400 | VALIDATION_ERROR | The subscription's customer has no email address. |
| 409 | SUBSCRIPTION_CANCELLED | At pay time: the subscription was cancelled after the checkout was opened. Nothing is charged. |
| 409 | SUBSCRIPTION_NOT_PAST_DUE | At pay time: the period was already paid another way (a retry, the renewal invoice) or a renewal debit is still processing. Nothing is charged. |