> ## Documentation Index
> Fetch the complete documentation index at: https://www.cashfree.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# UPI AutoPay Integration Guide

> Integrate UPI AutoPay with Cashfree Subscriptions: activate the product, set up webhooks, create plans and mandates, charge, and go live.

This guide explains how to integrate UPI AutoPay on Cashfree Subscriptions, from product activation to your first live recurring charge. For eNACH (electronic mandate on the National Automated Clearing House, NACH, of the National Payments Corporation of India, NPCI) and card standing instructions, see [Supported payment methods](https://www.cashfree.com/docs/payments/subscription/payment-modes.md). For the rules that apply to UPI mandates, such as pre-debit notifications, retries, and limits, see [UPI AutoPay rules and limits](https://www.cashfree.com/docs/payments/subscription/upi-autopay.md).

## Prerequisites

Make sure that you have the following before you start:

* An active Cashfree account. To create one, sign up on the [Merchant Dashboard](https://merchant.cashfree.com/merchants/signup).
* Completed know your customer (KYC) verification and an active Payment Gateway account. For details, see [Account activation](https://www.cashfree.com/docs/help/account/account-activation.md).
* The Subscriptions product activated for your account. To request activation, contact your account manager or fill out the [Support Form](https://merchant.cashfree.com/merchants/landing?env=prod\&raise_issue=1).

Activation can include a manual review, so request it before you plan a go-live date.

## Choose an integration method

Decide how much of the mandate approval experience you want to build. The following table compares the two main methods:

| Method | What the customer sees | What you build |
| :- | :- | :- |
| [Hosted Checkout](https://www.cashfree.com/docs/payments/subscription/hosted-checkout.md) | A Cashfree approval page that the customer is redirected to and back from | Almost nothing. Create the subscription, then open the Cashfree checkout with the returned `subscription_session_id`. |
| Seamless (API only) | An approval flow inside your own app or website | The full mandate creation interface, including the handling of UPI and bank details |

You can also use the Subscription Element SDKs, which give you a native mobile interface while Cashfree processes the mandate. To create subscriptions without code, for sales-led billing or testing, use the Merchant Dashboard or a [Subscription Payment Form](https://www.cashfree.com/docs/payments/no-code/payment-forms/subscription-payment-form.md).

If you're not sure which method to use, start with Hosted Checkout. Choose seamless only if a redirect would harm your conversion or brand experience.

## Integrate UPI AutoPay

Complete the following steps to build your integration:

**1. Get API keys and set up webhooks**

Log in to the [Merchant Dashboard](https://merchant.cashfree.com/auth/login) and go to **Payment Gateway > Developers > API Keys** to get your test and production keys. For details, see [Authentication](https://www.cashfree.com/docs/api-reference/authentication.md).

Then register your webhook endpoint and subscribe to the following events:

* `SUBSCRIPTION_STATUS_CHANGED`
* `SUBSCRIPTION_AUTH_STATUS`
* `SUBSCRIPTION_PAYMENT_NOTIFICATION_INITIATED`
* `SUBSCRIPTION_PAYMENT_SUCCESS`
* `SUBSCRIPTION_PAYMENT_FAILED`
* `SUBSCRIPTION_PAYMENT_CANCELLED`

If you use [merchant-controlled charging](https://www.cashfree.com/docs/payments/subscription/upi-autopay.md#merchant-controlled-charging), also subscribe to `SUBSCRIPTION_CONTROLLED_NOTIFICATION_STATUS` and `SUBSCRIPTION_CONTROLLED_EXECUTION_STATUS`.

Webhooks tell your system when a customer approves a mandate or a charge fails. If you miss them, your app can show an outdated status, such as a pending mandate that the customer already approved. Verify the signature of every webhook on your server before you act on it. For details, see [Subscription webhook signature](https://www.cashfree.com/docs/payments/subscription/webhook-signature.md) and [Subscription webhooks](https://www.cashfree.com/docs/payments/subscription/webhooks.md).

**2. Create a plan**

A plan defines the billing rules that the customer approves. When you create it, choose the following:

* **Plan type**: `PERIODIC`, where Cashfree raises each charge on a schedule, or `ON_DEMAND`, where you raise each charge yourself.
* **Amount**: A fixed recurring amount for periodic plans, or a maximum amount for on-demand plans.

Create the plan from the Merchant Dashboard or with the [Create Plan API](https://www.cashfree.com/docs/api-reference/payments/latest/subscription/create-a-plan.md) (`POST /pg/plans`). For the plan fields, see [Plans](https://www.cashfree.com/docs/payments/subscription/introduction.md#plans).

**3. Create the subscription and get it authorised**

Link a customer to the plan with the [Create Subscription API](https://www.cashfree.com/docs/api-reference/payments/latest/subscription/create-subscription.md) (`POST /pg/subscriptions`). The response returns a `subscription_session_id`. For Hosted Checkout, use it to open the Cashfree authorisation checkout. For seamless, pass it to the [Raise a Charge or Create an Auth API](https://www.cashfree.com/docs/api-reference/payments/latest/subscription/raise-a-charge-or-create-an-auth.md) with `payment_type` set to `AUTH`.

The customer approves the mandate with their UPI PIN in their UPI app, through UPI Intent or a QR code. For the authorisation and subscription lifecycle, see [Create a subscription](https://www.cashfree.com/docs/payments/subscription/create.md).

**4. Charge the subscription**

When the subscription is `ACTIVE`, Cashfree raises charges for periodic plans on schedule. For on-demand plans, raise each charge with the [Raise a Charge or Create an Auth API](https://www.cashfree.com/docs/api-reference/payments/latest/subscription/raise-a-charge-or-create-an-auth.md) (`POST /pg/subscriptions/pay`), with `payment_type` set to `CHARGE`.

Every UPI AutoPay charge follows the pre-debit notification and retry rules in [UPI AutoPay rules and limits](https://www.cashfree.com/docs/payments/subscription/upi-autopay.md). Cashfree sends the pre-debit notification before each charge that needs one, and you receive the `SUBSCRIPTION_PAYMENT_NOTIFICATION_INITIATED` webhook. The debit runs at least 24 hours after the notification succeeds. Test charges also wait 24 hours, so raise them a day ahead, or use the [Simulate Payment API](https://www.cashfree.com/docs/api-reference/payments/latest/simulation/simulate-payment.md).

To send pre-debit notifications and trigger debits yourself, see [Merchant-controlled charging](https://www.cashfree.com/docs/payments/subscription/upi-autopay.md#merchant-controlled-charging). For charge cut-off times, see [Charge a subscription](https://www.cashfree.com/docs/payments/subscription/charge.md).

You can't change the amount or expiry of an active mandate directly. To charge a different amount on a periodic subscription, create a plan with the new amount and apply it with the `CHANGE_PLAN` action.

**5. Manage and reconcile subscriptions**

Manage active subscriptions from the Merchant Dashboard or with the [Manage Subscription API](https://www.cashfree.com/docs/api-reference/payments/latest/subscription/manage-subscription.md) (`POST /pg/subscriptions/{subscription_id}/manage`). The following table describes each action:

| Action | Effect on the customer | When to use it |
| :- | :- | :- |
| `PAUSE` | Debits stop, but the mandate stays active. The customer doesn't need to approve it again. | The customer asks for a break, or you're troubleshooting. |
| `ACTIVATE` | Debits resume on the existing mandate. | To end a pause. |
| `CANCEL` | Debits stop. You can reactivate a cancelled subscription from the Merchant Dashboard. | The customer ends the service. |
| `CHANGE_PLAN` | The customer continues to pay under the new plan's terms. | To switch a periodic subscription to another plan, for example to change the recurring amount. You can't switch between interval types, such as from yearly to monthly. |

> [!NOTE]
>
> `PAUSE` and `CHANGE_PLAN` aren't supported for on-demand subscriptions.

For more details, see [Manage subscriptions](https://www.cashfree.com/docs/payments/subscription/manage.md).

## API reference

The following table lists the APIs you use most often:

| Endpoint | Method | Purpose | Reference |
| :- | :- | :- | :- |
| `/pg/plans` | `POST` | Create a plan with billing rules and amounts. | [Create Plan API](https://www.cashfree.com/docs/api-reference/payments/latest/subscription/create-a-plan.md) |
| `/pg/subscriptions` | `POST` | Create a subscription and get the `subscription_session_id`. | [Create Subscription API](https://www.cashfree.com/docs/api-reference/payments/latest/subscription/create-subscription.md) |
| `/pg/subscriptions/{subscription_id}` | `GET` | Get the status and details of a subscription. | [Fetch Subscription API](https://www.cashfree.com/docs/api-reference/payments/latest/subscription/fetch-subscription.md) |
| `/pg/subscriptions/{subscription_id}/manage` | `POST` | Pause, activate, cancel, or change the plan of a subscription. | [Manage Subscription API](https://www.cashfree.com/docs/api-reference/payments/latest/subscription/manage-subscription.md) |
| `/pg/subscriptions/pay` | `POST` | Create an authorisation for a seamless integration (`payment_type` set to `AUTH`), or raise a charge on an on-demand subscription (`payment_type` set to `CHARGE`). | [Raise a Charge or Create an Auth API](https://www.cashfree.com/docs/api-reference/payments/latest/subscription/raise-a-charge-or-create-an-auth.md) |
| `/pg/subscriptions/{subscription_id}/payments` | `GET` | Get the payment history of a subscription. | [Fetch Subscription Payments API](https://www.cashfree.com/docs/api-reference/payments/latest/subscription/fetch-details-of-all-payments-of-a-subscription.md) |

For full schemas, headers, and error responses, see the [Subscriptions API overview](https://www.cashfree.com/docs/api-reference/payments/latest/subscription/overview.md). To try the APIs, use the [Postman collection](https://www.cashfree.com/docs/api-reference/payments/latest/subscription/subscription-postman-collection.md).

## Test and go live

Test end to end in the sandbox environment (`https://sandbox.cashfree.com/pg`) before you go live.

### Sandbox testing checklist

Use this checklist to track your sandbox testing.

Have you tested mandate creation and a simulated UPI PIN approval in the sandbox environment?

Yes
No
N/A

Mandate approval is the first step for every subscription. If it fails, no charges can follow.

For test data, see [Sandbox environment](https://www.cashfree.com/docs/payments/online/resources/sandbox-environment.md).

Have you tested mandate cancellation and a customer declining the mandate?

Yes
No
N/A

Your app must show the correct subscription status when a mandate doesn't become active.

Check the status from the `SUBSCRIPTION_STATUS_CHANGED` and `SUBSCRIPTION_AUTH_STATUS` webhooks.

Have you tested the first charge and verified its webhook?

Yes
No
N/A

The first charge confirms that your plan, mandate, and webhook handling work together.

Check that your app updates the subscription when it receives `SUBSCRIPTION_PAYMENT_SUCCESS`.

Have you tested a charge that fails for insufficient funds?

Yes
No
N/A

Your app must respond correctly to failed charges and retries.

For the retry rules, see [Failed debits and retries](https://www.cashfree.com/docs/payments/subscription/upi-autopay.md#failed-debits-and-retries).

Have you implemented and tested webhook signature verification?

Yes
No
N/A

Without signature verification, your endpoint accepts any request that anyone sends to it.

For the verification steps, see [Subscription webhook signature](https://www.cashfree.com/docs/payments/subscription/webhook-signature.md).

### Go-live checklist

Use this checklist to confirm that you're ready to switch to production.

Has Cashfree approved your KYC?

Yes
No
N/A

You can't collect live recurring payments until your KYC is approved.

For the documents your business type needs, see [Account activation](https://www.cashfree.com/docs/help/account/account-activation.md).

Is Subscriptions activated in your production account?

Yes
No
N/A

Activation can include a manual review, which can delay your launch.

Contact your account manager or fill out the [Support Form](https://merchant.cashfree.com/merchants/landing?env=prod\&raise_issue=1).

Have you added your production API keys to your environment configuration?

Yes
No
N/A

Test keys don't work in production.

Log in to the [Merchant Dashboard](https://merchant.cashfree.com/auth/login) and go to **Payment Gateway > Developers > API Keys**.

Have you updated your webhook URLs to your live HTTPS endpoint?

Yes
No
N/A

Webhooks sent to a test endpoint never reach your production system.

For the events to subscribe to, see [Subscription webhooks](https://www.cashfree.com/docs/payments/subscription/webhooks.md).

Have you mapped your error handling to the subscription error codes?

Yes
No
N/A

Unmapped errors leave customers without a clear next step.

See [Subscription error codes](https://www.cashfree.com/docs/api-reference/payments/latest/subscription/error-codes.md).

## Troubleshooting

The following table explains the subscription statuses that most often need attention after authorisation, and what to do for each:

| Status | What it means | What to do |
| :- | :- | :- |
| `BANK_APPROVAL_PENDING` | The customer completed authorisation, and the bank hasn't approved the mandate yet. UPI AutoPay subscriptions usually become `ACTIVE` within minutes of the customer approving the mandate. | If the subscription stays in this status, check its latest status with the [Fetch Subscription API](https://www.cashfree.com/docs/api-reference/payments/latest/subscription/fetch-subscription.md), and then contact support through the [Support Form](https://merchant.cashfree.com/merchants/landing?env=prod\&raise_issue=1). |
| `LINK_EXPIRED` | The authorisation link expired before the customer completed authorisation. | Create a new subscription with a new `subscription_id`, and ask the customer to complete authorisation again. You can reuse the same plan. |

For all statuses, see [Subscription lifecycle](https://www.cashfree.com/docs/payments/subscription/create.md#subscription-lifecycle). For error codes, see [Subscription error codes](https://www.cashfree.com/docs/api-reference/payments/latest/subscription/error-codes.md).

Related topics

<ul>
  <li>[Create Subscription API](https://www.cashfree.com/docs/api-reference/payments/latest/subscription/create-subscription.md)</li>
  <li>[Hosted Checkout](https://www.cashfree.com/docs/payments/subscription/hosted-checkout.md)</li>
  <li>[Subscription FAQs](https://www.cashfree.com/docs/payments/subscription/faq.md)</li>
</ul>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.