{"id":181,"library":"razorpay","title":"Razorpay Python SDK","description":"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_'.","status":"active","version":"2.0.1","language":"python","source_language":"en","source_url":"https://github.com/razorpay/razorpay-python","tags":["razorpay","payments","india","fintech","python","payment-gateway"],"install":[{"cmd":"pip install razorpay","lang":"bash","label":"Python"}],"dependencies":[{"reason":"Required. Installed automatically.","package":"requests","optional":false}],"imports":[{"wrong":"import razorpay","symbol":"Client","correct":"from razorpay import Client"}],"quickstart":{"code":"# pip install razorpay\nimport razorpay\n\n# Use test keys from dashboard.razorpay.com\nclient = razorpay.Client(auth=('rzp_test_YOUR_KEY', 'YOUR_SECRET'))\nclient.enable_retry(True)  # retry on transient failures\n\n# Step 1: Create order server-side\norder = client.order.create({\n    'amount': 50000,    # 500 INR in paise\n    'currency': 'INR',\n    'receipt': 'receipt_001',\n    'notes': {\n        'product': 'Widget',\n        'user_id': '123'\n    }\n})\nprint('Order ID:', order['id'])\n# Pass order['id'], key_id, amount to frontend Razorpay checkout\n\n# Step 2: After frontend payment, verify signature\nparams = {\n    'razorpay_order_id': order['id'],\n    'razorpay_payment_id': 'pay_XXXX',   # from frontend\n    'razorpay_signature': 'SIG_XXXX'     # from frontend\n}\ntry:\n    client.utility.verify_payment_signature(params)\n    print('Payment confirmed')\nexcept razorpay.errors.SignatureVerificationError:\n    print('Invalid signature — reject payment')\n\n# Fetch payment details\npayment = client.payment.fetch('pay_XXXX')\nprint(payment['status'], payment['amount'])\n\n# Refund\nrefund = client.payment.refund('pay_XXXX', {'amount': 50000})\nprint(refund['id'])","lang":"python","description":"Razorpay Python SDK — order creation, signature verification, and refund."},"warnings":[{"fix":"amount_in_paise = amount_in_inr * 100. Always multiply INR by 100.","message":"All 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.","severity":"breaking","affected_versions":"all"},{"fix":"Always call client.utility.verify_payment_signature(params) with razorpay_order_id, razorpay_payment_id, razorpay_signature.","message":"Signature verification is mandatory after payment. Skipping it allows fraudulent payment_id injection. Never fulfill orders without calling verify_payment_signature().","severity":"breaking","affected_versions":"all"},{"fix":"Use environment variables: RAZORPAY_KEY_ID and RAZORPAY_KEY_SECRET. Verify key starts with 'rzp_test_' in development.","message":"Test 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.","severity":"gotcha","affected_versions":"all"},{"fix":"client.utility.verify_webhook_signature(payload, signature, WEBHOOK_SECRET) — get WEBHOOK_SECRET from Razorpay dashboard under Webhooks settings.","message":"Webhook signature uses a separate webhook secret — not the API secret. Using API secret for webhook verification raises SignatureVerificationError.","severity":"gotcha","affected_versions":"all"},{"fix":"Add 'payment_capture': 1 to order creation for automatic capture.","message":"payment_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).","severity":"gotcha","affected_versions":"all"},{"fix":"client.payment.fetch(), client.order.create(), client.refund.fetch(), client.customer.create()","message":"SDK method naming: client.payment (singular) not client.payments. client.order (singular) not client.orders. Common LLM error.","severity":"gotcha","affected_versions":"all"},{"fix":"Use currency='INR' for standard integration. Contact Razorpay for international payment activation.","message":"Razorpay only supports INR for domestic payments. International currencies require Razorpay's international payment product with separate activation.","severity":"gotcha","affected_versions":"all"},{"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).","message":"The '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.","severity":"breaking","affected_versions":"all"},{"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.","message":"The 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.","severity":"breaking","affected_versions":"all"}],"env_vars":null,"search_vec":"'1':29 '100':31 '2.0.1':16 '2026':18 'amount':26 'api':21 'auth':19 'client':45 'client-sid':44 'collect':42 'creat':37 'current':14 'fintech':76 'flow':36 'gateway':13,80 'india':9,75 'inr':30 'key':22,63,69 'lead':11 'live':68,72 'mandatori':55 'mar':17 'offici':4 'order':38 'pais':28,32 'payment':12,35,43,74,79 'payment-gateway':78 'python':2,5,77 'razorpay':1,8,73 'rupe':34 'rzp':66,71 'sdk':3,6 'secret':23 'secur':60 'server':40,50 'server-sid':39,49 'side':41,46,51 'signatur':48,52 'skip':56 'start':64 'test':62,67 'tupl':24 'use':20 'verif':53 'verifi':47 'version':15 'vulner':61","created_at":"2026-03-25T03:00:36.309485+00:00","updated_at":"2026-03-25T03:00:36.309485+00:00","problems":null,"ecosystem":"pypi","meta_description":null,"install_score":100,"quickstart_score":0,"quickstart_tag":"stale","pypi_latest":"2.0.1","cli_name":"","cli_version":null,"type":"library","homepage":"https://razorpay.com","github":"https://github.com/razorpay/razorpay-python","docs":null,"changelog":null,"pypi":"https://pypi.org/project/razorpay/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["payments","auth-security","http-networking"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-30","last_verified":"2026-08-26","next_check":"2026-07-30","install_tag":"verified"}}