Recurring Payments - S2S Integration

Integrate Recurring Payments using Razorpay APIs.


Recurring Payments allow you to charge your customers repeatedly without requiring them to enter payment details each time. Your customers authorise their payment method once and you can charge them at intervals you control based on your business needs.

Use Razorpay Recurring Payments to create flexible payment schedules for subscriptions, installments, usage-based billing or on-demand charges. Set up recurring payments quickly using our powerful REST APIs.

How It Works

  1. Authorise: Customer authorises their payment method.
  2. Tokenise: Payment method is securely tokenised after first successful payment.
  3. Charge: You initiate charges as needed using the token.

When to Use Recurring Payments

Recurring Payments are ideal when you need:

  • Flexible billing cycles: Charge customers based on usage, milestones or variable schedules.
  • Manual control: You decide when to charge each payment.

For automated, fixed-schedule billing (weekly, monthly, quarterly), consider using

instead.

The integration flow varies depending on how you choose to create the authorisation transaction.

Using Razorpay APIs

This is possible only via APIs. The integration flow to collect recurring payments using Razorpay APIs is:

  1. Create a customer. This returns a customer_id.
  2. Create an order. This returns an order_id. The order amount for cards is a minimum of $1.
  3. Pass the customer_id, order_id and a few additional parameters in your Checkout to create the authorisation payment. The customer completes the authorisation payment, which generates a token. This payment can be authorised using card.
  4. Retrieve and check the status of the token. Once the token status changes to confirmed, you can create and charge subsequent payments.
  5. Create and charge subsequent payments. To do this, you have to manually:
    1. Create a new order.
    2. Create a recurring payment.

You can create registration links from the Dashboard or using APIs.

Following is the integration flow to collect recurring payments using a registration link:

  1. Create a registration link and send it to your customer
    The customer completes the authorisation payment, which generates a token. This payment can be authorised using card or wallet.

    No Need to Create a Customer and Order Separately

    If you use a registration link to create the authorisation transaction, Razorpay automatically creates a customer and the order on your behalf.

  2. Retrieve and check the token status
    After the token status changes to confirmed, you can create and charge subsequent payments.

  3. Create and charge subsequent payments
    To do this, you have to manually:

    1. Create a new order.
    2. Create a recurring payment.

For most of the Razorpay APIs, the Gateway URL is https://api.razorpay.com/v1. You need to include this before each API endpoint to make API calls. However, certain APIs are on V2. Hence, the gateway URL may differ for certain APIs.

Example

Use the URL https://api.razorpay.com/v1/payments to access payment resources.

All Razorpay APIs are authenticated using Basic Auth. Basic auth requires the following:

  • [YOUR_KEY_ID]
  • [YOUR_KEY_SECRET]

Basic auth expects an Authorization header for each request in the Basic base64token format. Here, base64token is a base64 encoded string of YOUR_KEY_ID:YOUR_KEY_SECRET.

Watch Out!

The Authorization header value should strictly adhere to the format mentioned above. Invalid formats will result in authentication failures. Few examples of invalid headers are: BASIC base64token, basic base64token, Basic "base64token" and Basic $base64token.

Generate API Key

Follow these steps to generate API keys:

  1. Log in to your Dashboard with the appropriate credentials.
  2. Select the mode (Test or Live) for which you want to generate the API key.
    • Test Mode: The test mode is a simulation mode that you can use to test your integration flow. Your customers will not be able to make payments in this mode.
    • Live Mode: When your integration is complete, switch to live mode and generate live mode API keys. In the integration, replace test mode keys with live mode keys to accept customer payments.
  3. Navigate to Account & SettingsAPI Keys (under Website and app settings) → Generate Key to generate key for the selected mode.

The Key Id and Key Secret appear on a pop-up page.

Step 1: Create Authorisation Payment

Set up the authorisation payment using the

.

Step 2: Fetch Token Details

Fetch the customer's token detail to proceed with the authorisation payment using the

.

Step 3: Charge Subsequent Payments

Use the token to charge customers as needed using the

.


Is this integration guide useful?