Integration Steps
Follow the steps given below to integrate S2S JSON API with browser flow and accept payments using cards. 1.1 Integrate Razorpay Shield JS 1.2 Create Order and Payment 1.3 Handle Payment Success and Error Events 1.4 Verify Payment Signature 1.5 Integrate Payments Rainy Day Kit 1.6 Verify Payment Status1.1 Integrate Razorpay Shield JS
Integrate SHIELD JS and pass session_id in Create Order and Payment.JavaScript
1.2 Create Order and Payment
This step demonstrates creating an Order and processing a Payment using Razorpay APIs. Depending on your integration type, you can choose between:1. Consolidated Order and Payment API
Create an order along with payment using the consolidated order and payment API. This single API call combines order and payment creation, resulting in a more efficient and faster transaction process. Create an order along with payment by:- Making a single API call to Razorpay, combining order and payment creation.
- Authenticating using the provided credentials, ensuring access to the consolidated payment API.
- Manually integrating the API sample codes on your server.
card as the payment method:
/orders
Request
Response
amount mandatory
: integer Payment amount in the smallest currency sub-unit. 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.
Response Parameters
amount
: integer The transaction amount, expressed in the currency subunit. For example, for an actual amount of 299.35, the value of this field should be 29935.
amount_due
: integer The amount pending against the order.
amount_paid
: integer The amount paid against the order.
attempts
: integer The number of payment attempts, successful and failed, that have been made against this order.
created_at
: integer The UNIX timestamp at which the order is created.
currency mandatory
: string The currency in which the transaction should be made. View the list of supported currencies. Length must be of 3 characters.
entity
: string Name of the entity. Here, it is order.
id
: string The unique identifier of the order.
notes
: 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”.
offer_id
: string The unique identifier of the offer.
next
: array A list of action objects available to continue the payment process. Present when the payment requires further processing.
action
: string Indicates the next step to continue the payment process. Possible values:
otp_generate: Use this URL to allow the customer to generate OTP and complete the payment on your webpage.redirect: Use this URL to redirect the customer to submit the OTP on the bank page.
url
: string URL to be used for the action indicated.
razorpay_payment_id
: string Unique identifier of the payment. Present for all responses.
receipt
: string Your receipt id for this order should be passed here. Maximum length is 40 characters.
status
: string The status of the order. Possible values:
created: When you create an order, it is in thecreatedstate. It stays in this state till a payment is attempted on it.attempted: An order moves fromcreatedtoattemptedstate when a payment is first attempted on it. It remains in theattemptedstate till one payment associated with that order is captured.paid: After the successful capture of the payment, the order moves to thepaidstate. No further payment requests are permitted once the order moves to thepaidstate. The order stays in thepaidstate even if the payment associated with the order is refunded.
Error Response Parameters
The error response parameters are available in the API Reference Guide.2. Separate Order and Payment APIs
If you are using separate APIs to create Order and process Payment, follow the steps given below: Step 1: Create an Order Use the Orders API to create an order before initiating a payment. /ordersRequest
Response
amount mandatory
: integer Payment amount in the smallest currency sub-unit. 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.
Response Parameters
amount
: integer The transaction amount, expressed in the currency subunit. For example, for an actual amount of 299.35, the value of this field should be 29935.
amount_due
: integer The amount pending against the order.
amount_paid
: integer The amount paid against the order.
attempts
: integer The number of payment attempts, successful and failed, that have been made against this order.
created_at
: integer The UNIX timestamp at which the order is created.
currency mandatory
: string The currency in which the transaction should be made. View the list of supported currencies. Length must be of 3 characters.
entity
: string Name of the entity. Here, it is order.
id
: string The unique identifier of the order.
notes
: 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”.
offer_id
: string The unique identifier of the offer.
receipt
: string Your receipt id for this order should be passed here. Maximum length is 40 characters.
status
: string The status of the order. Possible values:
created: When you create an order, it is in thecreatedstate. It stays in this state till a payment is attempted on it.attempted: An order moves fromcreatedtoattemptedstate when a payment is first attempted on it. It remains in theattemptedstate till one payment associated with that order is captured.paid: After the successful capture of the payment, the order moves to thepaidstate. No further payment requests are permitted once the order moves to thepaidstate. The order stays in thepaidstate even if the payment associated with the order is refunded.
Error Response Parameters
The error response parameters are available in the API Reference Guide.Step 2: Create a Payment
Once the order is created, pass theorder_id from the Orders API response to the Payments API.
/payments/create/json
Request
Response
amount mandatory
: integer Payment amount in the smallest currency sub-unit. 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.
Response Parameters
next
: array A list of action objects available to continue the payment process. Present when the payment requires further processing.
action
: string Indicates the next step to continue the payment process. Possible values:
otp_generate: Use this URL to allow the customer to generate OTP and complete the payment on your webpage.redirect: Use this URL to redirect the customer to submit the OTP on the bank page.
url
: string URL to be used for the action indicated.
razorpay_payment_id
: string Unique identifier of the payment. Present for all responses.
Error Response Parameters
The error response parameters are available in the API Reference Guide.1.3 Handle Payment Success and Error Events
Once the payment is completed by the customer, aPOST 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_idrazorpay_order_idrazorpay_signature
Callback Example
Failure Callback
If the payment has failed, the callback will contain details of the error. Refer to Errors for details.1.4 Verify Payment Signature
Signature verification is a mandatory step to ensure that the callback is sent by Razorpay. Therazorpay_signature contained in the callback can be regenerated by your system and verified as follows.
Create a string to be hashed using the razorpay_payment_id contained in the callback and the Order ID generated in the first step, separated by a |. Hash this string using SHA256 and your API Secret.
Generate Signature on your Server
Sample code
Java
1.5 Integrate Payments Rainy Day Kit
Use Payments Rainy Day kit to overcome payments exceptions such as:1.6 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.