Feature RequestThis is an on-demand feature. Please raise a request with our Support team to get this feature activated on your Razorpay account.
Prerequisites
- Contact our Support Team to get this feature enabled for your account.
- Keep the API key (combination of
Key_IdandKey_Secret) handy for integration. - Generate API Keys from the Dashboard if not done already.
- Configure the payment capture settings on the Dashboard.
1. Integration Flow
In TPV integration flow, Razorpay maps the investors’ bank accounts to ensure that the payment is processed only from their registered bank accounts. Follow the steps given below:1.1 Collect Investor Bank Account details
Collect the bank account details provided by the investor at the time of registration.1.2 Create an Order
Pass the bank account details to thebank_account array of the Orders API:
/orders
The investor needs to pay using the payment method specified by you in the order. For example, if you want the investor to pay using UPI, you must pass method=upi.
Netbanking
Given below is the sample code when the method is netbanking.
Curl
Debit Card
Given below is the sample code when themethod is card.
Curl
UPI
Given below is the sample code when themethod is upi.
Curl
Request Parameters
Create a request payload using the following attributes:amount mandatory
: integer The transaction amount expressed in paise (currency supported is INR). For example, for an actual amount of ₹1, the value of this field should be 100.
currency mandatory
: string The currency in which the transaction should be made. You can create orders in INR only.
receipt optional
: string Receipt number that corresponds to this order, set for your internal reference. 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”.
method mandatory
: string The payment method used to make the payment. If this parameter is not passed, investors will be able to make payments using both netbanking and UPI payment methods. Possible values:
netbanking: Investors can make payments only using netbanking.card: Investors can make payments using debit card.upi: Investors can make payments only using UPI.
bank_account mandatory
: object Details of the bank account that the investor has provided at the time of registration.
account_number mandatory
: string The bank account number from which the investor should make the payment. For example, 765432123456789 Payments will not be processed for an incorrect account number.
name mandatory
: string The name linked to the bank account. For example, Gaurav Kumar.
ifsc mandatory
: string The bank IFSC. For example, HDFC0000053.
1.3 Fetch Payment Methods
When creating a custom checkout form for TPV, you can ensure that only the netbanking, debit card and UPI methods are displayed to the investor. Use the sample code given below to fetch all payment methods available to you.Request
1.4 Invoke Checkout and Pass Order Id and Other Options
1.4.1 Include the JavaScript code in your Webpage Include the following script, preferably in the “ section of your page:Index HTML
Include the Javascript, Not the LibraryInclude the script from
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.1.4.2 Instantiate Razorpay Custom Checkout
Single Instance on a Page
Invoke a Single Instance
Multiple Instances on Same Page
If you need multiple Razorpay instances on the same page, you can globally set some of the options:Invoke Multiple Instances
1.4.3 Submit Payment Details
After the order is created and the investor’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 investor. You can do this by invoking thecreatePayment method:
Netbanking - Handler function
Handler Function Vs. Callback URL
- Handler Function:
razorpay_payment_id, razorpay_order_id and razorpay_signature) is submitted to the Checkout Form. You need to collect these and send them to your server.- Callback URL:
razorpay_payment_id, razorpay_order_id and razorpay_signature) is submitted to the Callback URL.1.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.
1.6 Verify the Signature
This is a mandatory step to confirm the authenticity of the details returned to the Checkout form for successful payments. To verify therazorpay_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.Related Information
- Webhooks (Recommended)
- Error Codes (Recommended)
- How Payment Gateway Works
- Payment States
- Settlements
- Refunds