1
[Create an order using Orders API](#step-1-create-an-order-using-or...
2
[Add the Razorpay Checkout code to your website](#step-2-add-razorp...
3
[Store fields in your server](#step-3-store-fields-in-your-server).
4
[Verify payment signature](#step-4-verify-payment-signature).
5
[Verify payment status](#step-5-verify-payment-status).
Step 1: Create an Order Using Orders API
Integrate with Orders API to create an order. Given below is the sample code for Create an Order API. Pass theaccount_id of the sub-merchant using X-Razorpay-Account in the header.
/orders
Curl
Request Parameters
Here is the list of parameters and their description for creating an order:amount mandatory
: integer The transaction amount, expressed in the currency subunits. For example, for an actual amount of 300, the value of this field should be 30000.
currency mandatory
: string The currency in which the transaction should be made. See the list of supported currencies. Length must be 3 characters.
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.
Step 2: Add Razorpay Checkout Code to Website
Copy-paste the parameters asoptions in your code. This creates a Pay button on the website, which the customer can use to invoke Checkout and complete the payment. Pass the order_id received in the response of step 1 to the checkout code.
Checkout with Handler Functions (JavaScript)
Handy Tips
Checkout Options
key mandatory
: string API Key ID generated from the Dashboard.
amount mandatory
: integer Payment amount in the smallest currency subunit. For example, if the amount to be charged is , enter 222250 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.
Step 3: 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 4: 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. Check our SDKs for the supported platforms.Step 5: Verify Payment Status
Handy Tips
captured. Refer to the payment capture settings page to know how to capture payments automatically.
You can track the payment status in three ways:
To verify the payment status from the Razorpay Dashboard:- Log in to the Razorpay Dashboard and navigate to Transactions → Payments.
- Check if a Payment Id has been generated and note the status. In case of a successful payment, the status is marked as Captured.
Example
If you have subscribed to theorder.paid webhook event, you will receive a notification every time a customer pays you for an order.
Poll Payment APIs to check the payment status.
Next Steps
You can view the payments received from customers on the sub-merchant’s Dashboard. Also, you can retrieve the status of the payments by polling our APIs. Given below is the APIs used to fetch payments. You must pass the sub-merchant account identifier as a header while retrieving details using GET requests.Fetch Payments of Sub-Merchants API
You can fetch the details of the payments received by sub-merchant using the endpoint given below. Pass theaccount_id of the sub-merchant using X-Razorpay-Account in the header.
/payments
Curl