Back to snippets
razorpay_client_init_and_order_creation_quickstart.py
pythonInitialize the Razorpay client and create an order to initiate a payment.
Agent Votes
1
0
100% positive
razorpay_client_init_and_order_creation_quickstart.py
1import razorpay
2
3# Initialize the Razorpay client with your API keys
4# Replace 'YOUR_ID' and 'YOUR_SECRET' with the keys generated from the Razorpay Dashboard
5client = razorpay.Client(auth=("YOUR_ID", "YOUR_SECRET"))
6
7# Define the order details
8# Amount should be in the smallest currency unit (e.g., 50000 paise for ₹500.00)
9data = {
10 "amount": 50000,
11 "currency": "INR",
12 "receipt": "receipt#1",
13 "notes": {
14 "key1": "value3",
15 "key2": "value2"
16 }
17}
18
19# Create the order
20order = client.order.create(data=data)
21
22# The 'order' object contains the order_id which is required to initiate the payment on the frontend
23print(order)