Razorpay API error codes
Razorpay's error object has a code field that takes one of only three values, plus a description, source, step and reason that carry the detail. That surprises people who go looking for a long enumerated list: the code tells you who failed, and the reason tells you what failed.
Checked against Razorpay’s own documentation.
- BAD_REQUEST_ERROR
BAD_REQUEST_ERROR
The request was malformed, unauthorised, or referred to something that does not exist. It is the broadest of Razorpay's three error codes and covers most client-side faults, so the useful detail is in the `description` and `reason` fields rather than in the code itself.
- GATEWAY_ERROR
GATEWAY_ERROR
The request could not be completed because of an error at the payment gateway or the downstream bank. It is not your request that is wrong — something further along the chain failed, and Razorpay's guidance is to retry with the same idempotency key and request body.
- SERVER_ERROR
SERVER_ERROR
An unexpected error occurred on Razorpay's side while processing the request. Their documented description is "We are facing some trouble completing your request at the moment. Please try again shortly." — it is transient and the remedy is a retry.