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

# Integrate Pay Later

> Integrate Pay Later with Razorpay to accept payments using S2S JSON APIs.

Available in
🇮🇳 India

Pay Later lets your customers buy now and pay the provider later, using a credit line the provider has approved for them. The customer confirms the payment on the provider's page. You receive the full amount in your settlement, and the customer repays the provider separately.

This page describes how to accept Pay Later payments using the S2S JSON API. Pay Later uses `method=paylater` together with a `provider` code.

> [!NOTE]
>
> **Handy Tips**
>
> Contact our Support team to enable Pay Later and the providers you want for your account. Customers must have an account with the provider they choose.

## Integration Steps

Follow these steps to integrate the S2S JSON API and accept payments using Pay Later:

**1.1** [Fetch the List of Pay Later Providers](#1-1-fetch-the-list-of-pay-later-providers).

**1.2** [Create an Order](#1-2-create-an-order).

**1.3** [Create a Payment](#1-3-create-a-payment).

**1.4** [Handle Payment Success and Error Events](#1-4-handle-payment-success-and-error-events).

**1.5** [Fetch Payment Details and Status](#1-5-fetch-payment-details-and-status).

**1.6** [Verify Payment Signature](#1-6-verify-payment-signature).

**1.7** [Integrate Payments Rainy Day Kit](#1-7-integrate-payments-rainy-day-kit).

**1.8** [Verify Payment Status](#1-8-verify-payment-status).

### 1.1 Fetch the List of Pay Later Providers

Fetch the Pay Later providers enabled on your account and their codes. You pass the provider code in the `provider` field when you create a payment.

The response contains only the providers enabled for your account. A provider that is not enabled for you does not appear in the `paylater` object. Pass your key id as the `key_id` query parameter. Do not send the key secret to this endpoint.

`GET /v1/methods`

```bash Request theme={null}
curl -X GET 'https://api.razorpay.com/v1/methods?key_id=[YOUR_KEY_ID]'
```

```json Response (truncated to the paylater object) theme={null}
{
  "entity": "methods",
  "paylater": {
    "lazypay": true,
    "amazonpay": true
  }
}
```

#### Supported providers

| Provider | Code | Minimum amount | Maximum amount |
| - | - | - | - |
| LazyPay | `lazypay` | ₹1 | ₹10,000 |
| Amazon Pay Later | `amazonpay` | ₹1 | Customer's available credit limit |

The provider approves each payment against the customer's available credit limit.

**Check eligibility before checkout (optional).** To show only the providers a customer is eligible for, call the Eligibility Check API (`POST /v1/customers/eligibility`) before you display Pay Later options. Know more about the [Eligibility Check API](https://razorpay.com/docs/payments/payment-gateway/emi²/eligibility-check.md).

### 1.2 Create an Order

Create an order for every payment. The order ties the payment to the purchase in your system and protects the request from tampering. Create the order from your server using the [Orders API](https://razorpay.com/docs/api/orders/create.md).

`POST /v1/orders`

```bash Request theme={null}
curl -u [YOUR_KEY_ID]:[YOUR_KEY_SECRET] \
-X POST https://api.razorpay.com/v1/orders \
-H "content-type: application/json" \
-d '{
  "amount": 300000,
  "currency": "INR",
  "receipt": "receipt#1",
  "notes": {
    "key1": "value3",
    "key2": "value2"
  }
}'
```

```json Response theme={null}
{
  "id": "order_U1FALYntYLOT41",
  "entity": "order",
  "amount": 300000,
  "amount_paid": 0,
  "amount_due": 300000,
  "currency": "INR",
  "receipt": "receipt#1",
  "offer_id": null,
  "status": "created",
  "attempts": 0,
  "notes": {
    "key1": "value3",
    "key2": "value2"
  },
  "created_at": 1794918748
}
```

#### Request Parameters

**amount** `integer` *required*

Payment amount in the smallest currency sub-unit. For example, for ₹3,000, enter `300000`.

**currency** `string` *required*

The currency in which the transaction should be made. Pay Later supports `INR` only.

**receipt** `string`

Your receipt number for the order. Maximum length is 40 characters.

**notes** `json object`

Key-value pairs for additional information. Maximum 15 pairs, 256 characters each. For example, `"note_key": "Beam me up Scotty"`.

### 1.3 Create a Payment

After you create the order, create a payment with `paylater` as the method and the provider code from [step 1.1](#1-1-fetch-the-list-of-pay-later-providers).

`POST /v1/payments/create/json`

```bash Request theme={null}
curl -u [YOUR_KEY_ID]:[YOUR_KEY_SECRET] \
-X POST https://api.razorpay.com/v1/payments/create/json \
-H "content-type: application/json" \
-d '{
  "amount": 300000,
  "currency": "INR",
  "order_id": "order_U1FALYntYLOT41",
  "email": "gaurav.kumar@example.com",
  "contact": "9000090000",
  "method": "paylater",
  "provider": "lazypay",
  "callback_url": "https://example.com/callback",
  "ip": "105.106.107.108",
  "referer": "https://example.com/checkout",
  "user_agent": "Mozilla/5.0"
}'
```

```json Response theme={null}
{
  "next": [
    {
      "action": "redirect",
      "url": "https://api.razorpay.com/v1/payments/U1FALZJZNhSyMv/authenticate"
    },
    {
      "action": "otp_generate",
      "url": "https://api.razorpay.com/v1/payments/pay_U1FALZJZNhSyMv/otp_generate?key_id=[YOUR_KEY_ID]"
    }
  ],
  "razorpay_payment_id": "pay_U1FALZJZNhSyMv"
}
```

#### Request Parameters

**amount** `integer` *required*

Payment amount in the smallest currency sub-unit. Must match the order amount. For example, for ₹3,000, enter `300000`.

**currency** `string` *required*

The currency of the payment. Use `INR`.

**order\_id** `string` *required*

The unique identifier of the order created in [step 1.2](#1-2-create-an-order).

**email** `string` *required*

Customer's email address.

**contact** `string` *required*

Customer's mobile number. Use an Indian mobile number. Pay Later providers identify the customer by this number.

**method** `string` *required*

The payment method. Use `paylater`.

**provider** `string` *required*

Code of the Pay Later provider. Possible values:

* `lazypay`: LazyPay
* `amazonpay`: Amazon Pay Later

The provider must be enabled on your account. Check the `paylater` object in [step 1.1](#1-1-fetch-the-list-of-pay-later-providers).

**callback\_url** `string`

URL on your server where Razorpay sends a `POST` request with the payment result after the customer completes or abandons the payment on the provider page. Pass this URL to receive the success and failure callbacks in [step 1.4](#1-4-handle-payment-success-and-error-events).

**ip** `string`

IP address of the customer's device.

**referer** `string`

URL of the page from which the customer started the payment.

**user\_agent** `string`

User agent of the customer's browser.

**notes** `json object`

Key-value pairs for additional information. Maximum 15 pairs, 256 characters each.

#### Response Parameters

If the payment request is valid, the response contains these fields:

**razorpay\_payment\_id** `string`

Unique identifier of the payment. Store it to fetch the payment status later.

**next** `array`

A list of actions you can take to continue the payment.

**properties**

**action** `string`

The next step to continue the payment. Possible values:

* `redirect`: Redirect the customer to this URL. The customer is taken to the provider page to confirm the payment.
* `otp_generate`: Returned for some providers. You do not need this action for the redirect flow described on this page.

**url** `string`

The URL to use for the action.

Redirect the customer to the `url` of the `redirect` action. The customer confirms the payment on the provider page, for example, by entering the OTP the provider sends. After that, Razorpay sends the customer back to your `callback_url`.

### 1.4 Handle Payment Success and Error Events

After the customer completes or cancels the payment, Razorpay sends a `POST` request (form-encoded) to the `callback_url` you passed in the payment request. The fields depend on whether the payment succeeded or failed.

#### Success Callback

If the payment is successful, the callback contains these fields:

* `razorpay_payment_id`
* `razorpay_order_id`
* `razorpay_signature`

```json Callback Example theme={null}
{
  "razorpay_payment_id": "pay_U1FALZJZNhSyMv",
  "razorpay_order_id": "order_U1FALYntYLOT41",
  "razorpay_signature": "b3e32eb067fef300ef773966d69ba3b7ca0736281212602dc55560a3e6970e07"
}
```

Verify the signature before you treat the payment as successful. See [step 1.6](#1-6-verify-payment-signature).

#### Failure Callback

If the payment fails, the callback contains an `error` object. For example, this callback is sent when the customer cancels the payment on the provider page:

```json Callback Example theme={null}
{
  "error": {
    "code": "BAD_REQUEST_ERROR",
    "description": "Your payment has been cancelled. Try again or complete the payment later.",
    "source": "customer",
    "step": "payment_authentication",
    "reason": "payment_cancelled",
    "metadata": {
      "payment_id": "pay_U1FBLMlPUkJiNN"
    }
  }
}
```

The callback is a form-encoded POST; the example above shows its fields as JSON. Common reasons a Pay Later payment fails:

* The customer cancelled the payment on the provider page.
* The customer is not registered with or not eligible for the provider.
* The customer's available credit limit is lower than the amount.
* The customer exceeded the OTP attempts on the provider page.
* The provider declined the payment, or the customer did not complete it in time.

Show the customer the error `description` and let them retry with another payment method. Refer to [Errors](https://razorpay.com/docs/errors) for the full list of error codes and reasons.

### 1.5 Fetch Payment Details and Status

Use the `razorpay_payment_id` from the callback to fetch the payment and check its status.

`GET /v1/payments/:id`

```bash Request theme={null}
curl -u [YOUR_KEY_ID]:[YOUR_KEY_SECRET] \
-X GET https://api.razorpay.com/v1/payments/pay_U1FALZJZNhSyMv
```

```json Response theme={null}
{
  "id": "pay_U1FALZJZNhSyMv",
  "entity": "payment",
  "amount": 300000,
  "currency": "INR",
  "status": "captured",
  "order_id": "order_U1FALYntYLOT41",
  "invoice_id": null,
  "international": false,
  "method": "paylater",
  "amount_refunded": 0,
  "refund_status": null,
  "captured": true,
  "description": null,
  "card_id": null,
  "bank": "",
  "wallet": "lazypay",
  "vpa": null,
  "email": "gaurav.kumar@example.com",
  "contact": "+919000090000",
  "notes": [],
  "fee": 7080,
  "tax": 1080,
  "error_code": null,
  "error_description": null,
  "error_source": null,
  "error_step": null,
  "error_reason": null,
  "acquirer_data": {
    "transaction_id": "U1FALZJZNhSyMv"
  },
  "created_at": 1794918748
}
```

> [!NOTE]
>
> **Handy Tips**
>
> For Pay Later payments, the payment entity returns the provider code in the `wallet` field. For example, `"wallet": "lazypay"`.

### 1.6 Verify Payment Signature

Signature verification is mandatory. It confirms that the callback came from Razorpay.

Build a string from the `order_id` you created in [step 1.2](#1-2-create-an-order) and the `razorpay_payment_id` from the callback, separated by `|`. Generate an HMAC-SHA256 hex digest of this string using your key secret. Compare it with `razorpay_signature`.

```js Pseudocode theme={null}
generated_signature = hmac_sha256(order_id + "|" + razorpay_payment_id, secret);

if (generated_signature == razorpay_signature) {
  payment is successful
}
```

Use the `order_id` stored on your server, not the `razorpay_order_id` from the callback.

### 1.7 Integrate Payments Rainy Day Kit

Use the Payments Rainy Day Kit to handle payment exceptions such as:

* [Late Authorisation](https://razorpay.com/docs/payments/payments/late-authorisation.md)
* [Payment Downtime](https://razorpay.com/docs/api/payments/downtime.md)
* [Payment Errors](https://razorpay.com/docs/errors)

### 1.8 Verify Payment Status

> [!NOTE]
>
> **Handy Tips**
>
> Ensure the payment status is `captured`. A payment in `authorized` status is not settled to you until it is captured. Know how to [capture payments automatically](https://razorpay.com/docs/payments/payments/capture-settings.md).

> [accordion] You can track the payment status in three ways:
>
> > [tab] Verify Status from Dashboard
> >
> > To verify the payment status from the Razorpay Dashboard:
> >
> > 1. Log in to the Razorpay Dashboard and go to **Transactions** → **Payments**.
> > 2. Check that a payment id has been generated and note its status. A successful payment shows **Captured**.
>
> > [tab] Subscribe to Webhook Events
> >
> > Webhooks notify your server when an event occurs. Razorpay sends an HTTP `POST` request with a JSON payload to the URL you configure. Subscribe to `payment.authorized`, `payment.captured` or `order.paid` to know when a Pay Later payment completes, and to `payment.failed` to know when it fails. Know how to [set up webhooks](https://razorpay.com/docs/webhooks/setup-edit-payments.md).
>
> > [tab] Poll APIs
> >
> > Poll the [Payments APIs](https://razorpay.com/docs/api/payments/fetch-all-payments.md) to check the payment status. Use this as a fallback when you do not receive the callback or webhook.

### Next Steps

[Step 2: Test Integration](https://razorpay.com/docs/payments/payment-gateway/s2s-integration/json/v2/test-integration)
