API ReferenceIntegrationsKnowledge Base

Integrating with Razorpay Standard Checkout

Integrate Razorpay Standard Checkout with your website or apps to start accepting online payments from customers. Razorpay supports a slew of payment methods such as netbanking, credit and debit cards, wallets and UPI.

Our checkout.js library provides all the essential features for integrating Razorpay Checkout with the client-side of your application. This is available only for web-based integrations.

If your website is built on top of an ecommerce platform, such as WordPress or Shopify, please refer to Razorpay Ecommerce Plugins documentation.

Payments accepted from registered websites only:
You can accept payments only from those websites that you had registered with us at the time of signing up for an account. All payments received on the unregistered websites are failed by Razorpay. If you want to accept payments from multiple websites, contact our support team to register additional websites for your account.

Integration Methods#

Different flavors of Standard Checkout are available with Razorpay. Depending on your needs, select the integration method of your choice.

Automatic Checkout#

An easy integration method to integrate with your product.
This method provides the default Razorpay Pay with Razorpay button that invokes the Checkout form. The Checkout form options are passed as data attributes inside a script tag. You can add any additional, hidden or visible fields to the form, which will be submitted along with the form.

Manual Checkout#

Provides a greater control of the payment process. Use this method when you have multiple products or a complex way to pre-calculate amount for a payment (in javascript). The Checkout form is invoked by the custom button on your site and form options are passed as variables in a key-value pair format within a script tag.

Switch between Automatic and Manual methods:
You may switch from one checkout method to the other. Also, you can track the modal if you are using the Manual method. Learn more here.


Run the following checklist before you begin the integration:

  • Create a Razorpay Account

  • Generate API Keys

  • Look up the payment flow to know how the different states of the payment.

  • Check if view port meta tag is added in the tag of your webpage HTML code. If not, add the following line <meta name="viewport" content="width=device-width">

Integration Flow#

  1. Create an Order in your server-side.
  2. Paste the Checkout script in your website.
  3. Store fields in Database.
  4. Verify the Signature.

Step 1 - Create an Order in your server-side#

Orders API helps to:

  • Prevent multiple payments by binding a single successful payment to an order.
  • Auto capture payments immediately after authorization.

Here is the list of attributes for creating the order:

amount mandatory
integer The transaction amount, expressed in the currency subunit, such as paise (in case of INR). For example, for an actual amount of ₹299.35, the value of this field should be 29935.
currency mandatory
string The currency in which the transaction should be made. See the list of supported currencies. Default is INR.
receipt optional
string Your receipt id for this order should be passed here. Maximum length 40 characters.
payment_capture optional
boolean Set to 1 to automatically capture the payment. Set to 0 to capture payments manually using the API or Dashboard. Learn about capturing payments.
notes optional
JSON object Object consisting of key value pairs as notes.
You can read more about Notes in the API documentation.

Sample Code#

The following is a sample API request and response for creating an order:

Copycurl -X POST https://api.razorpay.com/v1/orders -H 'content-type:application/json' -d '{ "amount": 50000, "currency": "INR", "receipt": "rcptid_11", "payment_capture": 1 }'
Copytry { JSONObject orderRequest = new JSONObject(); orderRequest.put("amount", 50000); // amount in the smallest currency unit orderRequest.put("currency", "INR"); orderRequest.put("receipt", "order_rcptid_11"); orderRequest.put("payment_capture", false); Order order = razorpay.Orders.create(orderRequest); } catch (RazorpayException e) { // Handle Exception System.out.println(e.getMessage()); }
Copyorder_amount = 50000 order_currency = 'INR' order_receipt = 'order_rcptid_11' notes = {'Shipping address': 'Bommanahalli, Bangalore'} # OPTIONAL client.order.create(amount=order_amount, currency=order_currency, receipt=order_receipt, notes=notes, payment_capture='0')
Copy$order = $client->order->create([ 'receipt' => 'order_rcptid_11', 'amount' => 50000, // amount in the smallest currency unit 'currency' => 'INR',// <a href="https://razorpay.freshdesk.com/support/solutions/articles/11000065530-what-currencies-does-razorpay-support" target="_blank">See the list of supported currencies</a>.) 'payment_capture' => '0' ]);
CopyDictionary<string, object> options = new Dictionary<string,object>(); options.Add("amount", 50000); // amount in the smallest currency unit options.add("receipt", "order_rcptid_11"); options.add("currency", "INR"); options.add("payment_capture", "0"); Order order = client.Order.Create(options);
Copyoptions = amount: 50000, currency: 'INR', receipt: '<order_rcptid_11>', payment_capture: '0' order = Razorpay::Order.create
Copyvar options = { amount: 50000, // amount in the smallest currency unit currency: "INR", receipt: "order_rcptid_11", payment_capture: '0' }; instance.orders.create(options, function(err, order) { console.log(order); });
Copy{ "id": "order_DBJOWzybf0sJbb", "entity": "order", "amount": 50000, "amount_paid": 0, "amount_due": 50000, "currency": "INR", "receipt": "rcptid_11", "status": "created", "attempts": 0, "notes": [], "created_at": 1566986570 }

A successful creation of the Order returns an id (referred to the order_id) that should be stored against the Order defined in your system.

The id obtained in the response should be passed as order_id along with other data attributes as described in the section below.

Step 2 - Paste the Checkout script in your website#

Depending on the method of Standard Checkout integration, the Checkout options can be sent in the following ways:

Automatic Checkout#

Copy-paste the form parameters as data attributes in your HTML code:

Copy<form action="https://www.example.com/payment/success/" method="POST"> // Replace this with your website's success callback URL <script src="https://checkout.razorpay.com/v1/checkout.js" data-key="YOUR_KEY_ID" // Enter the Key ID generated from the Dashboard data-amount="50000" // Amount is in currency subunits. Default currency is INR. Hence, 50000 refers to 50000 paise data-currency="INR" data-order_id="order_CgmcjRh9ti2lP7"//This is a sample Order ID. Pass the `id` obtained in the response of the previous step. data-buttontext="Pay with Razorpay" data-name="Acme Corp" data-description="Test transaction" data-image="https://example.com/your_logo.jpg" data-prefill.name="Gaurav Kumar" data-prefill.email="gaurav.kumar@example.com" data-prefill.contact="9999999999" data-theme.color="#F37254" ></script> <input type="hidden" custom="Hidden Element" name="hidden"> </form>

An extensive list of Checkout form options is available here.

You can customize the appearance of the Pay with Razorpay button by writing CSS rules for the .razorpay-payment-button.

Payment Success and Failure#

Once the customer completes the payment on the Checkout, the browser will add an additional field <name=id> to the form that contains the script tag. This form is then automatically submitted. For each succesful payment, razorpay_payment_id, razorpay_order_id and razorpay_signature are submitted along with the form to the action url. Only successful authorizations are auto-submitted. In case of failed payments, checkout form is displayed again to facilitate retry of the payments.

Manual Checkout#

Copy-paste the form parameters as options in your HTML code:

Copy<button id="rzp-button1">Pay</button> <script src="https://checkout.razorpay.com/v1/checkout.js"></script> <script> var options = {    "key": "YOUR_KEY_ID", // Enter the Key ID generated from the Dashboard    "amount": "50000", // Amount is in currency subunits. Default currency is INR. Hence, 50000 refers to 50000 paise    "currency": "INR", "name": "Acme Corp",    "description": "Test Transaction",    "image": "https://example.com/your_logo", "order_id": "order_9A33XWu170gUtm", //This is a sample Order ID. Pass the `id` obtained in the response of Step 1    "handler": function (response){        alert(response.razorpay_payment_id); alert(response.razorpay_order_id); alert(response.razorpay_signature)    },    "prefill": {        "name": "Gaurav Kumar",        "email": "gaurav.kumar@example.com", "contact": "9999999999"    },    "notes": {        "address": "Razorpay Corporate Office"    },    "theme": {        "color": "#F37254"    } }; var rzp1 = new Razorpay(options); document.getElementById('rzp-button1').onclick = function(e){    rzp1.open();    e.preventDefault(); } </script>

Modify the attributes and the handler function to handle the response object.

Points to Remember:

  • The open method of Razorpay object (rzp1.open()) must be invoked by your site's JavaScript, which may or may not be a user-driven action such as a click.

  • You can customize the appearance of the custom button by writing CSS rules for the .razorpay-payment-button.

An extensive list of Checkout form options is available here

Payment Success and Failure#

Once the customer completes the payment successfully on the Checkout, a handler function is called automatically. This function returns a response object containing razorpay_payment_id, razorpay_order_id and razorpay_signature. The handler function must be called back to your server-side for capturing the payment. Send the razorpay_payment_id to your server-sided handler URL with any other attributes as you may need to capture the transaction. If the capture response has no error code set, it means that the payment has been captured successfully.

Step 3 - Store fields in your Database#

A successful payment for the Order returns razorpay_order_id, razorpay_payment_id and razorpay_signature, which is then used for payment verification. Make arrangements to store these objects from Razorpay in your database:

string Order ID returned by Razorpay Orders API.
string Returned by Razorpay API only for successful payments.
string A hexadecimal string used for verifying the payment.

In your system, let us say, unique identifier for an Order is transaction_id or checkout_id. This is not the order_id returned by Razorpay.

Step 4 - Verify the Signature#

Signature verification is a mandatory step to ensure that the callback is sent by Razorpay and the payment is received from an authentic source.

Once the payment is completed by the customer, a POST request is sent to the callback_url provided in the Checkout or the payment request. The data contained in this request will depend on whether the payment was a success or a failure.

Copy{ "razorpay_payment_id": "pay_29QQoUBi66xm2f", "razorpay_order_id": "order_9A33XWu170gUtm", "razorpay_signature": "9ef4dffbfd84f1318f6739a3ce19f9d85851857ae648f114332d8401e0949a3d" }

In failed payments, the callback will contain the errors returned by Razorpay.

Generate a Signature#

The razorpay_signature, returned to you by the Checkout form on successful payment, can be regenerated by your system and verified as follows:

  1. Create a string to be hashed using the following attributes:

    • razorpay_payment_id - Returned by Checkout
    • razorpay_order_id - Returned by Checkout
    • key_secret - Available in your server.
      The key_secret that was generated from the Dashboard.
  2. Use the SHA256 algorithm and razorpay_payment_id,razorpay_order_idto construct a HMAC hex digest as shown below:

Copygenerated_signature = hmac_sha256(razorpay_order_id + "|" + razorpay_payment_id, secret); if (generated_signature == razorpay_signature) { payment is successful }

Post Signature Verification#

After verifying the signature, fetch the order in your system that corresponds to razorpay_order_id in your database. You can now mark this fetched order as successful and process the order.

Test the Integration#

Now that the integration is complete, you must ensure that your integration works as expected. You can make a test transaction using the test cards, verify the payment status from Dashboard, APIs or subscribe to related Webhook events to take appropriate actions at your end. After testing the integration in test mode, you can start accepting payments from your customers in real-time.

Test Payments#

You can make test payments using any of the payment methods configured on the Checkout. No money is deducted from the customer's account as this is a simulated transaction. In the Checkout code, ensure that you have entered the API keys generated in the test mode.

Test Cards#

You can use any of the test cards to make transactions in the test mode. Use any valid expiration date in the future and any random CVV to create a successful payment.

Card Network

Domestic / International

Card Number



5104 0155 5555 5558
5104 0600 0000 0008



4111 1111 1111 1111



5555 5555 5555 4444
5105 1051 0510 5100



4012 8888 8888 1881
4000 1841 8621 8826

Verify the Payment Status#

You can track the status of the payment from the Dashboard or subscribe to the Webhook event or poll our APIs.

From the Dashboard#

  1. Login to your Dashboard and navigate to TransactionsPayments.
  2. Look if a payment_ID has been generated. If no payment_ID has been generated, it means that the transaction has failed.

Subscribe to Webhook events#

You can subscribe to a Webhook event that is generated when a certain event happen in our server. When one of those events is triggered, Razorpay will send the request paylaod to the configured URL on your server.

Learn how to setup Webhooks.

When the customer has made sucessful payment on the Checkout, payment.authorized event is created in Razorpay.

Poll APIs#

You can retrieve the status of the payments by polling our Payment APIs.

Accept Live Payments#

After testing the flow of funds end-to-end in test mode, you are now ready to take your integration live. Once you are confident that the integration is working fine, you can switch to the live mode and start accepting payments from customers. But first you need to swap the test API keys with the live keys.

To generate API key in live mode:

  1. Login to Dashboard and switch to Live mode on the menu.
  2. Navigate to SettingsAPI KeysGenerate Key to generate API key for live mode.
  3. Download the keys and save it securely.

Replace the test API key with the Live Key in the Checkout code and start accepting real-time payments.