How to hit the Razorpay API

Razorpay's API at https://api.razorpay.com/v1 handles payments in India. Amounts are in the smallest unit: 50000 = ₹500.00. Test-mode keys start with rzp_test_.

Authentication

Generate a key id and secret under Account & Settings → API Keys. Razorpay uses Basic auth with the key id as username and the secret as password — curl's -u, PostTaco's Auth tab.

Full reference: https://razorpay.com/docs/api/

Create an order

curl -X POST https://api.razorpay.com/v1/orders \
  -u {{RAZORPAY_KEY_ID}}:{{RAZORPAY_KEY_SECRET}} \
  -H "Content-Type: application/json" \
  -d '{"amount": 50000, "currency": "INR", "receipt": "receipt_posttaco_1"}'
Run in PostTaco

List payments

curl "https://api.razorpay.com/v1/payments?count=10" \
  -u {{RAZORPAY_KEY_ID}}:{{RAZORPAY_KEY_SECRET}}
Run in PostTaco

Refund a payment

Amount is optional; omit it for a full refund.

curl -X POST https://api.razorpay.com/v1/payments/{{PAYMENT_ID}}/refund \
  -u {{RAZORPAY_KEY_ID}}:{{RAZORPAY_KEY_SECRET}} \
  -H "Content-Type: application/json" \
  -d '{"amount": 10000}'
Run in PostTaco