Registry / payments / razorpay

razorpay

JSON →
library2.0.1pypypi✓ verified 26d ago

Official Python SDK for Razorpay — India's leading payment gateway. Current version: 2.0.1 (Mar 2026). Auth uses API key + secret tuple. All amounts in paise (1 INR = 100 paise) — not rupees. Payment flow: create order server-side → collect payment client-side → verify signature server-side. Signature verification is mandatory — skipping it is a security vulnerability. Test keys start with 'rzp_test_', live keys with 'rzp_live_'.

pip install razorpay
INSTALL
IMPORT
SIG · RAZORPAY
R
razorpay
paymentspythonv2.0.1
Install
2.5s avg
Import
367ms
Disk
20MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v2.0.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.374s · 21.7MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 2.5s · import 0.360s · 22MB
20MB installed
● package 20MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Client
from razorpay import Client
import razorpay

Razorpay Python SDK — order creation, signature verification, and refund.

# pip install razorpay import razorpay # Use test keys from dashboard.razorpay.com client = razorpay.Client(auth=('rzp_test_YOUR_KEY', 'YOUR_SECRET')) client.enable_retry(True) # retry on transient failures # Step 1: Create order server-side order = client.order.create({ 'amount': 50000, # 500 INR in paise 'currency': 'INR', 'receipt': 'receipt_001', 'notes': { 'product': 'Widget', 'user_id': '123' } }) print('Order ID:', order['id']) # Pass order['id'], key_id, amount to frontend Razorpay checkout # Step 2: After frontend payment, verify signature params = { 'razorpay_order_id': order['id'], 'razorpay_payment_id': 'pay_XXXX', # from frontend 'razorpay_signature': 'SIG_XXXX' # from frontend } try: client.utility.verify_payment_signature(params) print('Payment confirmed') except razorpay.errors.SignatureVerificationError: print('Invalid signature — reject payment') # Fetch payment details payment = client.payment.fetch('pay_XXXX') print(payment['status'], payment['amount']) # Refund refund = client.payment.refund('pay_XXXX', {'amount': 50000}) print(refund['id'])
Debug
Known issues
breakingAll amounts are in paise (smallest currency unit) — NOT rupees. 500 INR must be passed as 50000. Passing 500 charges 5 paise (₹0.05). No error is raised — silent wrong charge.
fix
amount_in_paise = amount_in_inr * 100. Always multiply INR by 100.
affects: all
breakingSignature verification is mandatory after payment. Skipping it allows fraudulent payment_id injection. Never fulfill orders without calling verify_payment_signature().
fix
Always call client.utility.verify_payment_signature(params) with razorpay_order_id, razorpay_payment_id, razorpay_signature.
affects: all
gotchaTest keys (rzp_test_) and live keys (rzp_live_) are different. Test payments don't transfer real money. Accidentally using live keys in development charges real users.
fix
Use environment variables: RAZORPAY_KEY_ID and RAZORPAY_KEY_SECRET. Verify key starts with 'rzp_test_' in development.
affects: all
gotchaWebhook signature uses a separate webhook secret — not the API secret. Using API secret for webhook verification raises SignatureVerificationError.
fix
client.utility.verify_webhook_signature(payload, signature, WEBHOOK_SECRET) — get WEBHOOK_SECRET from Razorpay dashboard under Webhooks settings.
affects: all
gotchapayment_capture=1 in order.create auto-captures payment. Without it, payment is authorized but not captured — must manually call client.payment.capture(payment_id, amount).
fix
Add 'payment_capture': 1 to order creation for automatic capture.
affects: all
gotchaSDK method naming: client.payment (singular) not client.payments. client.order (singular) not client.orders. Common LLM error.
fix
client.payment.fetch(), client.order.create(), client.refund.fetch(), client.customer.create()
affects: all
gotchaRazorpay only supports INR for domestic payments. International currencies require Razorpay's international payment product with separate activation.
fix
Use currency='INR' for standard integration. Contact Razorpay for international payment activation.
affects: all
breakingThe 'Authentication failed' error means your API Key ID or Secret is incorrect or missing. Verify that both RAZORPAY_KEY_ID and RAZORPAY_KEY_SECRET are accurately set and passed to the Razorpay client.
fix
Ensure that RAZORPAY_KEY_ID and RAZORPAY_KEY_SECRET are correctly obtained from your Razorpay dashboard and properly configured in your application (e.g., via environment variables or direct instantiation of razorpay.Client).
affects: all
breakingThe API keys (RAZORPAY_KEY_ID and RAZORPAY_KEY_SECRET) are either incorrect, missing, or have insufficient permissions, leading to an 'Authentication failed' error. This is a fundamental issue preventing any API interaction.
fix
Ensure RAZORPAY_KEY_ID and RAZORPAY_KEY_SECRET environment variables are set correctly with valid API keys. Double-check for typos and confirm the keys are active and have the necessary permissions in your Razorpay dashboard.
affects: all
Upgrade
Version history
2.0.1latest on PyPI · released Mar 9, 2026
Audit
Dependencies
requestsrequiredRequired. Installed automatically.
Agent activity
42 hits · last 30 days
node
38
Resources
razorpay — pip install razorpay · libregistry