1. Build Integration
Steps to integrate your Web application with the Razorpay Curlec S2S Redirect API.
You can integrate with Razorpay Curlec APIs to start accepting payments made using card, fpx and other payment methods. In this document, the fpx payment method has been shown as an example.
Follow these steps to integrate your Web application with the Razorpay Curlec S2S Redirect API:
1.1
.1.2
.1.3
.1.4
.1.5
.Watch Out!
Do not hardcode the URL returned in the API responses.
Order is an important step in the payment process.
- An order should be created for every payment.
- You can create an order using the . It is a server-side API call. Know how to 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.
Use this endpoint to create an order using the Orders API.
curl -X POST https://api.razorpay.com/v1/orders-U [YOUR_KEY_ID]:[YOUR_KEY_SECRET]-H 'content-type:application/json'-d '{"amount": 100,"currency": "MYR","receipt": "qwsaq1","partial_payment": true,"first_payment_min_amount": 230,"notes": {"key1": "value3","key2": "value2"}}'
amount
mandatory
integer The amount to be paid by the customer in sen. For example, if the amount is RM 500.00, enter 50000.
currency
mandatory
string The currency in which the payment should be made by the customer. Length must be of 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.
first_payment_min_amount
optional
integer Minimum amount that must be paid by the customer as the first partial payment. For example, if an amount of RM 7,000.00 is to be received from the customer in two installments of #1 - RM 5,000.00, #2 - RM 2,000.00 then you can set this value as 500000. This parameter should be passed only if partial_payment is true.
Know more about
.Descriptions for the response parameters are present in the
parameters table.The error response parameters are available in the
.Create a payment using the API given below after your order is created.
The following is a sample API request and response for creating a payment:
amount
mandatory
integer Payment amount in the smallest currency subunit.
For example, if the amount to be charged is RM 299.00, then pass 29900 in this field.
currency
mandatory
string Currency code for the currency in which you want to accept the payment. For example, MYR.
order_id
mandatory
string Unique identifier of the Order created at your server side.
Enter the id returned in the response of the
mandatory
string Email address of the customer.
contact
mandatory
string Contact of the customer.
method
mandatory
string Supported payment methods are:
cardfpxwallet
card
The fields that can be pre-populated in the Checkout form.
number
mandatory
string Unformatted card number. Required if the method is card.
name
mandatory
string Name of the cardholder. Required if the method is card.
expiry_month
mandatory
integer Expiry month for the card in MM format. Required if the method is card.
expiry_year
mandatory
string Expiry year for the card in YY format. Required if the method is card.
cvv
mandatory
string CVV printed on the back of the card. Required if the method is card.
bank
mandatory
string Bank code of the bank used for the payment. Required if the method is fpx.
wallet
mandatory
string Wallet code for the wallet used for the payment. Required if the method is wallet.
notes
optional
object Key-value object used for passing tracking info. Refer to
callback_url
optional
string URL endpoint where Razorpay Curlec will submit the final payment status.
ip
mandatory
string IP Address of the client's browser.
referrer
mandatory
string Referrer header passed by the client's browser.
user_agent
mandatory
string Value of user_agent header passed by the client's browser.
Descriptions for the response parameters are present in the
parameters table.2OO OK
The response contains 200 OK code along with the HTML content that needs to be opened in the customer's browser. This HTML content contains form fields that will be automatically posted to the bank or wallet URL (specified in the form) to continue with the payment process.
400 Bad Request
This can happen when erroneous parameters are passed in the request, for example invalid currency.
{"error_code": "BAD_REQUEST_ERROR","error_description": "Payment failed","error_source": "gateway","error_step": "payment_authorization","error_reason": "payment_failed",}
Know more about
.The HTML form returned in the response should be opened in the customer's browser. The customer completes the payment on the displayed page.
Once the payment is completed by the customer, a POST request is sent to the callback_url provided in the
POST request depends on the success or failure of the payment made by the customer.
A successful payment contains the following fields:
razorpay_payment_idrazorpay_order_idrazorpay_signature
{ "razorpay_payment_id": "pay_29QQoUBi66xm2f","razorpay_order_id": "order_9A33XWu170gUtm","razorpay_signature": "9ef4dffbfd84f1318f6739a3ce19f9d85851857ae648f114332d8401e0949a3d"}
In failed payments, the response received at the callback contains the error details as shown below:
error%5Bcode%5D=BAD_REQUEST_ERROR&error%5Bdescription%5D=Payment+failed&error%5Bsource%5D=gateway&error%5Bstep%5D=payment_authorization&error%5Breason%5D=payment_failed&error%5Bmetadata%5D=%7B%22payment_id%22%3A%22pay_HDP0E0MdoAaOYu%22%2C%22order_id%22%3A%22order_HDOSKuUVbejk0C%22%7D
The key-value parameters of the request are 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
.This is a mandatory step to confirm the authenticity of the details returned to the Checkout form for successful payments.
-
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 .
-
Use the SHA256 algorithm, the
razorpay_payment_idand theorder_idto construct a HMAC hex digest as shown below:generated_signature = hmac_sha256(order_id + "|" + razorpay_payment_id, secret);if (generated_signature == razorpay_signature) {payment is successful} -
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.
Given below is the sample code for payment signature verification:
RazorpayClient razorpay = new RazorpayClient("[YOUR_KEY_ID]", "[YOUR_KEY_SECRET]");String secret = "EnLs21M47BllR3X8PSFtjtbd";JSONObject options = new JSONObject();options.put("razorpay_order_id", "order_IEIaMR65cu6nz3");options.put("razorpay_payment_id", "pay_IH4NVgf4Dreq1l");options.put("razorpay_signature", "0d4e745a1838664ad6c9c9902212a32d627d68e917290b0ad5f08ff4561bc50f");boolean status = Utils.verifyPaymentSignature(options, secret);
After you have completed the integration, you can
, make test payments, replace the test key with the live key and integrate with other .Handy Tips
On the Razorpay Curlec Dashboard, ensure that the payment status is captured. Refer to the payment capture settings page to know how to
To verify the payment status from the Razorpay Curlec Dashboard:
- Log in to the Razorpay Curlec 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.

Use Payments Rainy Day kit to overcome payments exceptions such as:
Is this integration guide useful?