> ## Documentation Index
> Fetch the complete documentation index at: https://razorpay-60c89f9a-mintlify-audit-missing-sections-1778528421.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Pay with Reward Points on S2S Integration (Redirect)

> You can enable your customers to pay using a combination of reward points and a payment method such as cards, netbanking, wallets or UPI, on your S2S integration.

<Info>
  **Feature Request**
</Info>

This is an on-demand feature. Please raise a request with our [Support team](https://razorpay.com/support/#request) to get this feature activated on your Razorpay account.

to get this feature activated on your account.

## Prerequisites

* Sign up for a Razorpay account.
* Generate [API Keys](/api/authentication#generate-api-keys) on the Dashboard.
* Configure [payment capture settings](/payments/payments#dashboard-actions) on the Dashboard.
* Follow the [Razorpay S2S Integration (Redirect) documentation](/payments/payment-gateway/s2s-integration/redirect).
* Customers should have earned reward points. In the absence of reward points, customers will get an error and will not be able to proceed with `Pay with Reward Points`.

## Integration Steps

Given below are the integration steps:

<Steps>
  <Step title="[Fetch payment methods using the Methods API](#step-1-fetch-payment...">
    [Fetch payment methods using the Methods API](#step-1-fetch-payment-methods-using-methods-api).
  </Step>

  <Step title="[Create an order using the Orders API](#step-2-create-an-order-usin...">
    [Create an order using the Orders API](#step-2-create-an-order-using-orders-api).
  </Step>

  <Step title="[Create a payment using the S2S Payments Redirect API](#step-3-crea...">
    [Create a payment using the S2S Payments Redirect API](#step-3-create-a-payment-using-s2s-redirect).
  </Step>

  <Step title="[Handle payment success and failure](#step-4-handle-payment-success...">
    [Handle payment success and failure](#step-4-handle-payment-success-and-failure).
  </Step>

  <Step title="[Fetch payment status](#step-5-fetch-payment-status).">
    [Fetch payment status](#step-5-fetch-payment-status).
  </Step>
</Steps>

### Step 1: Fetch Payment Methods using Methods API

To fetch a list of payment methods enabled for your account, send the following request:

/methods

````curl: Request theme={null}
curl -u [YOUR_KEY_ID] \
- X GET https://api.razorpay.com/v1/methods \
```json: Response
{
  "entity": "methods",
  ...
  "apps": {
    "twid": true,
    "cred": true
  },
  ...
}
````

### Step 2: Create an order using Orders API

Create an order using the Orders API. Send the order request parameters to the following endpoint:

**Order is an important step in the payment process.**

* An order should be created for every payment.
* You can create an order using the [Orders API](#api-sample-code). It is a server-side API call. Know how to [authenticate](/payments/dashboard/account-settings/api-keys#generate-api-keys) Orders API.
* The `order_id` received in the response should be passed to the checkout. This ties the order with the payment and secures the request from being tampered.

<Warning>
  **Watch Out!**

  Payments made without an `order_id` cannot be captured and will be automatically refunded. You must create an order before initiating payments to ensure proper payment processing.

  You can create an order:

  * Using the sample code on the Razorpay Postman Public Workspace.
  * By manually integrating the API sample codes on your server.

  #### Razorpay Postman Public Workspace

  You can use the Postman workspace below to create an order:

  [](https://www.postman.com/razorpaydev/workspace/razorpay-public-workspace/request/12492020-6f15a901-06ea-4224-b396-15cd94c6148d)

  <Info>
    **Handy Tips**
  </Info>

  Under the **Authorization** section in Postman, select **Basic Auth** and add the Key Id and secret as the Username and Password, respectively.

  #### API Sample Code

  Use this endpoint to create an order using the Orders API.

  /orders

  ````curl: Curl theme={null}
  curl -X POST https://api.razorpay.com/v1/orders
  -U [YOUR_KEY_ID]:[YOUR_KEY_SECRET]
  -H 'content-type:application/json'
  -d '{
   "amount": 500,
   "currency": "INR",
   "receipt": "qwsaq1",
   "partial_payment": true,
   "first_payment_min_amount": 230,
   "notes": {
     "key1": "value3",
     "key2": "value2"
   }
  }'
  ```java: Java
  RazorpayClient razorpay = new RazorpayClient("[YOUR_KEY_ID]", "[YOUR_KEY_SECRET]");

  JSONObject orderRequest = new JSONObject();
  orderRequest.put("amount",50000);
  orderRequest.put("currency","INR");
  orderRequest.put("receipt", "receipt#1");
  JSONObject notes = new JSONObject();
  notes.put("notes_key_1","Tea, Earl Grey, Hot");
  notes.put("notes_key_1","Tea, Earl Grey, Hot");
  orderRequest.put("notes",notes);

  Order order = instance.orders.create(orderRequest);
  ```Python: Python
  import razorpay
  client = razorpay.Client(auth=("YOUR_ID", "YOUR_SECRET"))

  client.order.create({
   "amount": 50000,
   "currency": "INR",
   "receipt": "receipt#1",
   "partial_payment": False,
   "notes": {
     "key1": "value3",
     "key2": "value2"
   }
  })
  ```php: PHP
  $api = new Api($key_id, $secret);

  $api->order->create(array('receipt' => '123', 'amount' => 100, 'currency' => 'INR', 'notes'=> array('key1'=> 'value3','key2'=> 'value2')));
  ```csharp: .NET
  RazorpayClient client = new RazorpayClient("[YOUR_KEY_ID]", "[YOUR_KEY_SECRET]");

  Dictionary orderRequest = new Dictionary();
  orderRequest.Add("amount", 50000);
  orderRequest.Add("currency", "INR");
  orderRequest.Add("receipt", "receipt#1");
  Dictionary notes = new Dictionary();
  notes.Add("notes_key_1", "Tea, Earl Grey, Hot");
  notes.Add("notes_key_2", "Tea, Earl Grey, Hot");
  orderRequest.Add("notes", notes);

  Order order = client.Order.Create(orderRequest);
  ```ruby: Ruby
  require "razorpay"
  Razorpay.setup('YOUR_KEY_ID', 'YOUR_SECRET')

  para_attr = {
   "amount": 50000,
   "currency": "INR",
   "receipt": "receipt#1",
   "notes": {
     "key1": "value3",
     "key2": "value2"
   }
  }

  Razorpay::Order.create(para_attr)
  ```javascript: Node.js
  var instance = new Razorpay({ key_id: 'YOUR_KEY_ID', key_secret: 'YOUR_SECRET' })

  instance.orders.create({
   "amount": 50000,
   "currency": "INR",
   "receipt": "receipt#1",
   "partial_payment": false,
   "notes": {
     "key1": "value3",
     "key2": "value2"
   }
  })
  ```go: Go
  import ( razorpay "github.com/razorpay/razorpay-go" )
  client := razorpay.NewClient("YOUR_KEY_ID", "YOUR_SECRET")

  data := map[string]interface{}{
   "amount": 50000,
   "currency": "INR",
   "receipt": "some_receipt_id",
   "partial_payment": false,
   "notes": map[string]interface{}{
       "key1": "value1",
       "key2": "value2",
     },
  }
  body, err := client.Order.Create(data, nil)
  ````

  ````json: Success Response theme={null}
  {
   "id": "order_IluGWxBm9U8zJ8",
   "entity": "order",
   "amount": 5000,
   "amount_paid": 0,
   "amount_due": 5000,
   "currency": "INR",
   "receipt": "rcptid_11",
   "offer_id": null,
   "status": "created",
   "attempts": 0,
   "notes": [],
   "created_at": 1642662092
  }
  ```json: Failure Response
  {
   "error": {
     "code": "BAD_REQUEST_ERROR",
     "description": "Order amount less than minimum amount allowed",
     "source": "business",
     "step": "payment_initiation",
     "reason": "input_validation_failed",
     "metadata": {},
     "field": "amount"
   }
  }
  ````
</Warning>

### Request Parameters

`amount` *mandatory*
: `integer` Payment amount in the smallest currency subunit. For example, if the amount to be charged is 299, then pass `29900` in this field. In the case of three decimal currencies, such as KWD, BHD and OMR, to accept a payment of 295.991, pass the value as 295990. And in the case of zero decimal currencies such as JPY, to accept a payment of 295, pass the value as 295.

<Warning>
  **Watch Out!**

  As per payment guidelines, you should pass the last decimal number as 0 for three decimal currency payments. For example, if you want to charge a customer 99.991 KD for a transaction, you should pass the value for the amount parameter as `99990` and not `99991`.

  `currency` *mandatory*
  : `string` The currency in which the transaction should be made. See the [list of supported currencies](/payments/international-payments#supported-currencies). Length must be 3 characters.

  <Info>
    **Handy Tips**
  </Info>

  Razorpay has added support for zero decimal currencies, such as JPY and three decimal currencies, such as KWD, BHD and OMR, allowing businesses to accept international payments in these currencies. Know more about [Currency Conversion](/payments/international-payments/currency-conversion) (May 2024).

  `receipt` *optional*
  : `string` Your receipt id for this order should be passed here. Maximum length is 40 characters.

  `notes` *optional*
  : `json object` Key-value pair that can be used to store additional information about the entity. Maximum 15 key-value pairs, 256 characters (maximum) each. For example, `"note_key": "Beam me up Scotty”`.

  `partial_payment` *optional*
  : `boolean` Indicates whether the customer can make a partial payment. Possible values:

  * `true`: The customer can make partial payments.
  * `false` (default): The customer cannot make partial payments.

  `first_payment_min_amount` *optional*
  : `integer` Minimum amount that must be paid by the customer as the first partial payment. For example, if an amount of 7000 is to be received from the customer in two installments of #1 - 5000, #2 - 2000 then you can set this value as `500000`. This parameter should be passed only if `partial_payment` is `true`.

  Know more about [Orders API](/api/orders).
</Warning>

### Response Parameters

Descriptions for the response parameters are present in the [Orders Entity](/api/orders/entity) parameters table.

### Error Response Parameters

The error response parameters are available in the [API Reference Guide](/api/orders/create).

### Step 3: Create a Payment using S2S Redirect Payments API

Use the following API to create a payment with `app` as the payment method:

/payments/create/redirect

```curl: curl theme={null}
curl -u [YOUR_KEY_ID]:[YOUR_KEY_SECRET] \
-X POST https://api.razorpay.com/v1/payments/create/redirect \
-H "Content-Type: application/json" \
 -d '{
  "amount": "100",
  "currency": "INR",
  "email": "gaurav.kumar@example.com",
  "contact": "9000090000",
  "order_id": "order_EKwxwAgItmmXdp",
  "method": "app",
  "provider": "twid"
}'
```

#### Request Parameters

`amount` *mandatory*
: `integer` The amount to be paid by the customer in currency subunits. For example, if the amount is ₹100, enter `10000`.

`currency` *mandatory*
: `string` The currency in which the payment should be made by the customer. See the list of [supported currencies](/payments/international-payments#supported-currencies).

`order_id` *mandatory*
: `string` Order ID generated in the previous step.

`email` *mandatory*
: `string` Email address of the customer.

`contact` *mandatory*
: `string`  Phone number of the customer.

`method` *mandatory*
: `string` Name of the payment method. Enter the value `app`.

`provider` *mandatory*
: `string`  Name of the service provider partnered with Razorpay. Enter the value `twid`.

`notes` *optional*
: `object` Set of key-value pairs used to store additional information about the payment. It can hold a maximum of 15 key-value pairs, each 256 characters long (maximum).

`callback_url` *optional*
: `string` URL endpoint where Razorpay will submit the final payment status.

`ip` *optional*
: `string` Customer IP Address.

`referrer` *optional*
: `string` Customer referrer.

`user_agent` *optional*
: `string` Customer user-agent.

#### Response Types

`2OO OK`
: In this case, the response contains `200 OK` code along with the HTML content that needs to be opened in the customer's browser. This HTML content contains form fields that will be automatically posted to the bank or wallet URL (specified in the form) to continue with the payment process.

`400 Bad Request`
: This can happen when incorrect parameters are passed in the request. For example, passing an invalid currency or wrong card number.

```json: 400 Bad Request theme={null}
{
  "error_code": "BAD_REQUEST_ERROR",
  "error_description": "Payment failed",
  "error_source": "gateway",
  "error_step": "payment_authorization",
  "error_reason": "payment_failed",
}
```

Refer to the [errors document](/errors) for more details.

The HTML form returned in the response should be opened in the customer's browser. The customer completes the payment on the displayed page.

### Step 4: Handle Payment Success and Failure

Once the customer completes the payment, a `POST` request is made to the `callback_url` provided in the payment request. The data contained in this request will depend on whether the payment was a **success** or a **failure**.

#### Success Callback

If the payment made by the customer is successful, the following fields are sent:

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

```json: Callback example theme={null}
{
  "razorpay_payment_id": "pay_FVptEVkDdNzFx8",
  "razorpay_order_id": "order_EKwxwAgItmmXdp",
  "razorpay_signature": "9ef4dffbfd84f1318f6739a3ce19f9d85851857ae648f114332d8401e0949a3d"
}
```

#### Failure Callback

If the payment has failed, the callback will contain details of the error. Know more about [errors](/errors).

### Step 5: Fetch Payment Status

Upon payment completion, you can fetch the status of the payment using:

* [Fetch Payments API](/api/payments#fetch-multiple-payments)
* [Payments Webhooks (Recommended)](/webhooks/payments#payments)

### Related Information

* [FAQs](/payments/payment-methods/apps/reward-points/faqs)
