Prerequisites
- Create a Razorpay account.
- Generate API keys from the Dashboard.
- Refer to our web custom integration document.
Integration flow
If you want to display the No Cost EMI offered by Bajaj Finserv on the Checkout, you must associate the offer with an order. Follow the integration steps given below:1
[Create No Cost EMI offers](#step-1-create-no-cost-emi-offers).
2
[Create an order](#step-2-create-an-order).
3
[Fetch payment methods](#step-3-fetch-payment-methods).
4
[Invoke checkout and pass order_id and other options](#step-4-invok...
5
[Store fields in your server](#step-5-store-fields-in-your-server).
6
[Verify payment signature](#step-6-verify-payment-signature).
Step 1: Create No Cost EMI Offers
Raise a request with the Razorpay Support team to create the relevant No Cost EMIs you want to display on the Checkout. Get the appropriateoffer_id created for each EMI plan.
Step 2: Create an Order
Obtain theoffer_id. Let us say, offer_ANZoaxsOww2X53, from our Support team. Create an order for the transaction amount for which the created offer should be applied.
/orders
amount mandatory
: integer Amount in currency subunits for which the order is created. For example, if the order is for ₹30,000, enter the value 3000000 (in paise).
currency mandatory
: string ISO code of the currency associated with the order amount.
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”.
offers mandatory
: array Unique identifier of the Offer.
Pass the offer_id obtained from the Razorpay Support team.
discountoptional
: boolean Indicate if a discount is to be applied by Razorpay or not. Possible values are:
true: Discount is applied.false: Discount is not applied.
Curl
Step 3: Fetch Payment Methods
When creating a custom checkout form, you need to ensure that only the methods that are activated for your account are displayed to the customer. Use the below methods to fetch all payments methods available to you.Request
Step 4: Invoke Checkout and Pass Order Id and Other Options
The list of checkout parameters is available here.Step 4.1: Include the JavaScript code in your Webpage
Include the following script, preferably in “ section of your page:Index HTML
Including the Javascript, not the Library
https://checkout.razorpay.com/v1/razorpay.js instead of serving a copy from your own server. This allows new updates and bug fixes to the library to get automatically served to your application.
We always maintain backward compatibility with our code.
Step 4.2: Instantiate Razorpay Custom Checkout
You can choose to have:Single Instance on a Page
If you need a single instance on a page, use the code given below:Invoke a Single Instance
Multiple Instances on Same Page
If you need multiple razorpay instances on same page, you can globally set some of the options:Invoke Multiple Instances
Step 4.3: Submit Payment Details
Once the order is created and the customer’s payment details are obtained, the information should be sent to Razorpay to complete the payment. The data that needs to be submitted depends upon the payment method selected by the customer. You can do this by invokingcreatePayment method:
createPayment with handler function
Step 5: Store Fields in Your Server
A successful payment returns the following fields to the Checkout form.Success Callback
- You need to store these fields in your server.
- You can confirm the authenticity of these details by verifying the signature in the next step.
Success Callback
razorpay_payment_id
: string Unique identifier for the payment returned by Checkout only for successful payments.
razorpay_order_id
: string Unique identifier for the order returned by Checkout.
razorpay_signature
: string Signature returned by the Checkout. This is used to verify the payment.
Step 6: Verify Payment Signature
This is a mandatory step to confirm the authenticity of the details returned to the Checkout form for successful payments.To verify the razorpay_signature returned to you by the Checkout form:
-
Create a signature in your server using the following attributes:
order_id: Retrieve theorder_idfrom your server. Do not use therazorpay_order_idreturned by Checkout.razorpay_payment_id: Returned by Checkout.key_secret: Available in your server. Thekey_secretthat was generated from the Dashboard.
-
Use the SHA256 algorithm, the
razorpay_payment_idand theorder_idto construct a HMAC hex digest as shown below:HMAC Hex Digest -
If the signature you generate on your server matches the
razorpay_signaturereturned to you by the Checkout form, the payment received is from an authentic source.
Generate Signature on Your Server
Given below is the sample code for payment signature verification:Java
Post Signature Verification
After you have completed the integration, you can set up webhooks, make test payments, replace the test key with the live key and integrate with other APIs.Payment Capture Settings
After payment isauthorized, you need to capture it to settle the amount to your bank account as per the settlement schedule. Payments that are not captured are auto-refunded after a fixed time.
Test Integration
After the integration is complete, you need to test the integration to ensure that it is working as expected. You can make a test transaction using the test cards, verify the payment status from the Dashboard or through 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 actual payments from your customers.Test Payments
You can make test payments using any of the payment methods configured at 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.EMI Test Card
You can use the EMI test card given below 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 | Card Number | CVV & Expiry Date
Mastercard | 5241 8100 0000 0000 | Use a random CVV and any future dateVerify Payment Status
You can track the status of the payment from the Dashboard, subscribe to the Webhook event or poll our APIs.From Dashboard
- Log in to the Dashboard and navigate to Transactions → Payments.
- Check if a
payment_IDhas been generated. If nopayment_IDhas 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 happens in our server. When one of those events is triggered, Razorpay sends the Webhook payload to the configured URL. Know how to set up Webhooks.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 and confident that the integration is working as expected, switch to the live mode and start accepting payments from customers. However, make sure that you swap the test API keys with the live keys. To generate API key in live mode:- Log in to Dashboard and switch to Live mode on the menu.
- Navigate to Account & Settings → API Keys → Generate Key to generate API key for live mode.
- Download the keys and save them securely.
- Replace the test API key with the Live Key in the Checkout code and start accepting actual payments.
Related Information
- Webhooks (Recommended)
- Error Codes (Recommended)
- How Payment Gateway Works
- Payment States
- Settlements
- Refunds