Handy Tips
3DS2 Authentication
3DS2 is an authentication protocol, the successor of 3DS1, that enables businesses and payment providers to send additional information (such as customer device or browser data) to verify the transaction’s authenticity. Razorpay integration is compliant with the 3DS2 protocol. Know more: Razorpay supports 3DS2 transactions.Handy Tips
- Integration does not differ for the challenge or frictionless flow.
- Frictionless flow is not applicable for payments on cards issued in India.
1.1 Create an Order
Order is an important step in the payment process.- An order should be created for every payment.
- You can create an order using the Orders API. It is a server-side API call. Know how to authenticate Orders API.
- The
order_idreceived in the response should be passed to the checkout. This ties the order with the payment and secures the request from being tampered.
Request Parameters
amount mandatory
: integer Payment amount in the smallest currency subunit. 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
Descriptions for the response parameters are present in the Orders Entity parameters table.Error Response Parameters
The error response parameters are available in the API Reference Guide.1.2 Create a Payment
Create a payment using the API given below after your order is created. /payments/create/redirectSample Code
The following is a sample API request and response for creating a payment:Curl
Request Parameters
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.
1.3 Handle Payment Success and Failure
Once the payment is completed by the customer, aPOST request is sent to the callback_url provided in the create a payment request. The data contained in the POST request depends on the success or failure of the payment made by the customer.
Success
A successful payment contains the following fields:1
`razorpay_payment_id`
razorpay_payment_id2
`razorpay_order_id`
razorpay_order_id3
`razorpay_signature`
razorpay_signatureSuccess - Callback
Failure
In failed payments, the response received at the callback contains the error details as shown below:error_code
: string Error that occurred during payment. For example, BAD_REQUEST_ERROR.
error_description
: string Description of the error that occurred during payment. For example, Payment failed.
error_source
: string The point of failure. For example, gateway.
error_step
: string The stage where the transaction failure occurred. The stages can vary depending on the payment method used to complete the transaction. For example, payment_auhtorization.
error_reason
: string The exact error reason. For example, payment_failed.
metadata
: object Contains additional information about the request.
payment_id
: string Unique identifier of the payment.
order_id
: string Unique identifier of the order associated with the payment.
Know more about errors.
1.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.1.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.