Step 1: Create an Order🔗
Order creation is the first step to integrate your application with Razorpay and start accepting payments. Orders API allows you to create an Order when a payment is expected from a customer.
Ensure the razorpay_order_id
is stored against the corresponding transaction. The API endpoint given below will create an Order at your server-side:
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.
- 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.
API Sample Code🔗
The following is a sample API request and response for creating an order:
Copycurl -X POST https://api.razorpay.com/v1/orders
-u [YOUR_KEY_ID]:[YOUR_KEY_SECRET]
-H 'content-type:application/json'
-d '{
"amount": 50000,
"currency": "INR",
"receipt": "rcptid_11"
}'
Copytry {
JSONObject orderRequest = new JSONObject();
orderRequest.put("amount", 50000); // amount in the smallest currency unit
orderRequest.put("currency", "INR");
orderRequest.put("receipt", "order_rcptid_11");
Order order = razorpay.Orders.create(orderRequest);
} catch (RazorpayException e) {
// Handle Exception
System.out.println(e.getMessage());
}
Copyimport razorpay
client = razorpay.Client(auth=("api_key", "api_secret"))
DATA = {
"amount": 100,
"currency": "INR",
"receipt": "receipt#1",
"notes": {
"key1": "value3",
"key2": "value2"
}
}
client.order.create(data=DATA)
Copy$order = $client->order->create([
'receipt' => 'order_rcptid_11',
'amount' => 50000, // amount in the smallest currency unit
'currency' => 'INR'// <a href="/docs/international-payments/#supported-currencies" target="_blank">See the list of supported currencies</a>.)
]);
CopyDictionary<string, object> options = new Dictionary<string,object>();
options.Add("amount", 50000); // amount in the smallest currency unit
options.add("receipt", "order_rcptid_11");
options.add("currency", "INR");
Order order = client.Order.Create(options);
Copyoptions = amount: 50000, currency: 'INR', receipt: '<order_rcptid_11>'
order = Razorpay::Order.create
Copyvar options = {
amount: 50000, // amount in the smallest currency unit
currency: "INR",
receipt: "order_rcptid_11"
};
instance.orders.create(options, function(err, order) {
console.log(order);
});
Copy{
"id": "order_DBJOWzybf0sJbb",
"entity": "order",
"amount": 50000,
"amount_paid": 0,
"amount_due": 50000,
"currency": "INR",
"receipt": "rcptid_11",
"status": "created",
"attempts": 0,
"notes": [],
"created_at": 1566986570
}
Request Parameters🔗
Here is the list of parameters and their description for creating an 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 3 characters.receipt
optionalstring
Your receipt id for this order should be passed here. Maximum length 40 characters.notes
optionaljson 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
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.