1.1 Create an Order in Server🔗
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_id received in the response should be passed to the checkout. This ties the Order with the payment and secures the request from being tampered.
Handy Tips
You can capture payments automatically with one-time Payment Capture setting configuration on the Razorpay Dashboard.
API Sample Code🔗
In the sample app, the rubysample.rb file contains the code for order creation using Orders API.
Copyrequire "razorpay"
Razorpay.setup('YOUR_KEY_ID', 'YOUR_SECRET')
order = Razorpay::Order.create amount: 50000, currency: 'INR', receipt: 'TEST'
Parameters🔗
Here is the list of parameters for creating the order:
amount
mandatoryinteger
The transaction amount, expressed in the currency subunit, such as paise (in case of INR). For example, for an actual amount of ₹299.35, the value of this field should be29935
.currency
mandatorystring
The currency in which the transaction should be made. See the list of supported currencies. Length must be of 3 characters.receipt
optionalstring
Pass the receipt id created for this order. Maximum length 40 characters.notes
optionaljson object
Optional notes for order. Key-value pair 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
optionalboolean
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.
Know more about Orders API.
Error Response Parameters🔗
The error response parameters are available in the API Reference Guide.