Billing
Update Payment Method
Let a customer set up automatic payments again before a renewal is due, without charging the period early.
Overview
A subscription renews by debiting the automatic-payment authorisation (mandate) the customer gave at checkout. When that authorisation fails, is never confirmed, or is cancelled at the bank, the subscription stays active but its next renewal cannot be collected. A setup session lets the customer authorise a new payment method right away. It is a checkout session with mode: "setup" tied to the subscription: it never charges the period, never moves the billing period and never changes the price.
Gateway support
The setup page lists every gateway you enabled for subscriptions. Gateways that cannot save a payment method without a payment are shown as not available, with the reason; they are never simulated.
| Gateway | Setup only | How |
|---|---|---|
| Stripe | Supported | SetupIntent (usage off_session) on the merchant's Stripe Customer. Nothing is charged. INR cards register the RBI e-mandate (amount_type maximum). |
| Razorpay | Supported | Recurring-token authorisation of Rs 1 (Razorpay's card and UPI authorisation minimum), refunded immediately through the Razorpay refund API. INR only. |
| Cashfree | Not supported | Its mandate is set up with the renewal payment: the customer sets it up when the renewal is due (Update payment method). |
| PhonePe | Not supported | Autopay is set up with the renewal payment: the customer sets it up when the renewal is due. |
| CCAvenue | Not supported | A standing instruction is registered only with a payment of the fixed renewal amount. |
| PayPal | Not supported | Saving a PayPal account without a purchase needs PayPal's setup-token API, which is not integrated. |
| Other gateways | Not supported | No off-session debit: they cannot be used for subscriptions. |
Ways to open it
- Hosted billing page: an active subscription without working automatic payments shows Set up automatic payments.
- Dashboard: the subscription page's Automatic payments card has Send setup link, which emails the customer (
mandate_setup_link). - Automatically: when a mandate fails or is cancelled at the gateway, the customer is emailed a setup link, and the renewal reminder links to it while automatic payments are not set up. Both follow your Subscription emails preference.
- API:
POST /api/v1/subscriptions/{id}/setup-sessionreturns the URL to send yourself.
Create a setup session
POST /api/v1/subscriptions/{subscriptionId}/setup-session, scope subscriptions:write. An open session of the same subscription is returned again with reused: true. Links are valid for 24 hours (emailed links for 7 days).
| Field | Type | Description |
|---|---|---|
subscriptionId | string (path) | An active or trialing subscription that renews automatically and has no active mandate. |
curl -X POST https://paymenthooks.com/api/v1/subscriptions/ph_sub_9f86d081884c7d659a2feaa0c55ad015/setup-session \
-H "Authorization: Bearer phk_live_..."{
"data": {
"id": "ph_cks_4d7a1c9e2b5f8a0d3c6e9b2f5a8d1c4e",
"object": "setup_session",
"url": "https://paymenthooks.com/checkout/setup/ph_cks_4d7a1c9e2b5f8a0d3c6e9b2f5a8d1c4e",
"expiresAt": "2026-11-15T10:00:00.000Z",
"subscriptionId": "ph_sub_9f86d081884c7d659a2feaa0c55ad015",
"reused": false,
"gateways": [
{ "connectionId": "ph_gwc_1679091c5a880faf6fb5e6087eb1b2dc","gateway": "gw_razorpay", "displayName": "Razorpay", "supported": true, "method": "refunded_authorisation", "description": "Authorise a card, UPI Autopay or bank mandate with a Rs 1 verification payment, refunded immediately." },
{ "connectionId": "ph_gwc_8f14e45fceea167a5a36dedd4bea2543","gateway": "gw_cashfree", "displayName": "Cashfree", "supported": false, "method": null, "description": "Cashfree mandates are set up with a renewal payment. Use it when the renewal is due." }
]
},
"error": null
}What happens on success
- The gateway result is read back from the gateway with your own connection credentials (never from the browser).
- The new mandate is stored on the subscription; the old one is marked replaced and cancelled at its gateway.
- A pending dunning sequence caused by the mandate failure is cancelled.
- For Indian mandates, the RBI pre-debit notice is scheduled for the next renewal as usual: the debit still waits for an accepted notice 24 hours ahead.
subscription.payment_method_updatedandmandate.updatedare sent, and the change is written to the audit log.
Completion is confirmed by the gateway, even if the customer closes the page: Stripe setup_intent.succeeded and Razorpay payment.authorized / payment.capturedfinish the setup on the server (PaymentHooks registers the Stripe webhook in your account itself, and a Razorpay account connected with Connect with Razorpay sends its events through the PaymentHooks partner app), and a check 30 minutes after the setup started catches a webhook that never arrived. A card that needs 3D Secure returns to the setup page, which completes it from Stripe's answer. Whichever arrives first completes it once; the Rs 1 verification is refunded once. A link that expires unused releases what the gateway holds: an unfinished SetupIntent is cancelled, a saved card nothing uses is detached at Stripe.
Verification payments
Razorpay saves a recurring card or UPI token only with a payment, so the customer authorises Rs 1 and PaymentHooks refunds it immediately through Razorpay's refund API. The Payment and its Refund carry purpose: "mandate_authorisation": they never count as revenue, refunds, analytics, customer spend, gateway volume or plan transactions, and no receipt is sent. If Razorpay refuses the refund it is recorded as failed and you receive a refund failure alert.
Webhooks
{
"type": "subscription.payment_method_updated",
"data": {
"object": {
"id": "ph_sub_9f86d081884c7d659a2feaa0c55ad015",
"object": "subscription",
"status": "active",
"setup_session": "ph_cks_4d7a1c9e2b5f8a0d3c6e9b2f5a8d1c4e",
"mandate": "ph_man_6c8a2e4f0b6d8a2c4e6f0b2d4a6c8e0f",
"mandate_status": "active",
"payment_method": "token_Ny1Ma9kP2Lx",
"payment_method_label": "Card (recurring)",
"gateway": "gw_razorpay",
"replaced_mandates": ["ph_man_1b3d5f7a9c0e2b4d6f8a0c2e4b6d8f0a"],
"current_period_end": 1789430400
}
}
}mandate_status is pending while a bank confirms the authorisation; mandate.updated follows when it becomes active.
Errors
| Code | HTTP | Meaning |
|---|---|---|
| SETUP_NOT_AVAILABLE | 422 | Automatic payments are already active, the subscription is past_due (it pays and re-authorises with Update payment method), paused, cancelled, ends at period end or renews by invoice. |
| NO_SETUP_GATEWAY | 422 | No gateway enabled for subscriptions can save a payment method without a payment. |
| SETUP_UNSUPPORTED | 422 | The customer chose a gateway without setup-only support (setup page). |
| SETUP_NOT_CONFIRMED | 409 | Stripe has not confirmed the SetupIntent yet (card authentication not finished). |
| SETUP_SESSION | 409 | A payment route was called with a setup session; setup sessions never take a payment. |
| SESSION_ALREADY_COMPLETED / EXPIRED | 409 / 410 | The setup link was already used or has expired; create a new one. |