Package: razorpayx
RazorpayX Python ClientPython bindings for interacting with the RazorpayX APIThis is primarily meant for merchants who wish to perform interactions with the RazorpayX API programatically.Installation$pipinstallrazorpayUsageYou need to setup your key and secret using the following:
You can find your API keys athttps://dashboard.razorpay.com/#/app/keys.importrazorpayclient=razorpay.Client(auth=("<YOUR_API_KEY>","<YOUR_API_SECRET>"))App DetailsAfter setting up client, you can set your app details before making any request
to Razorpay using the following:client.set_app_details({"title":"<YOUR_APP_TITLE>","version":"<YOUR_APP_VERSION>"})For example, you can set the title toDjangoand version to1.8.17. Please ensure
that both app title and version are strings.PaymentsFetch all paymentsclient.payment.all()Fetch a particular paymentclient.payment.fetch("<PAYMENT_ID>")Capture a paymentclient.payment.capture("<PAYMENT_ID>","<AMOUNT>")Note:<AMOUNT>shouldbesameastheoriginalamountwhilecreatingthepaymentRefund a paymentclient.payment.refund("<PAYMENT_ID>","<AMOUNT>")# for full refundclient.payment.refund("<PAYMENT_ID>","<AMOUNT_TO_BE_REFUNDED>")# for particular amountNote:<AMOUNT_TO_BE_REFUNDED>shouldbeequal/lessthantheoriginalamountGet Bank Transfer Entity for given paymentclient.payment.bank_transfer("<PAYMENT_ID>")Create transfer for given payment idclient.payment.transfer("<PAYMENT_ID>")For List of params refer to the API guide :https://razorpay.com/docs/route/api-reference/#creating-paymentsFetch all transfers associated with the paymentclient.payment.transfers("<PAYMENT_ID>")RefundsFetch a particular refundclient.refund.fetch("<refund_id>")Fetch all refundsclient.refund.all()OrdersCreate a new orderclient.order.create(data=DATA)DATAshouldcontainthesekeysamount:amountofordercurrency:currencyoforderreceipt:receiptidoforderpayment_capture:1ifcaptureshouldbedoneautomaticallyorelse0notes(optional):optionalnotesfororderfetch a particular orderclient.order.fetch("<ORDER_ID>")fetch all ordersclient.order.all()fetch Payments of orderclient.order.payments("<ORDER_ID>")Payment LinkCreate payment linkReferapi docsfor allowed request parameters.DATA={"customer":{"name":"Test Customer","email":"test@example.com","contact":"+919999888877"},"type":"link","amount":100,"currency":"INR","description":"Payment link for this purpose - xyz"}client.invoice.create(data=DATA)Fetch payment link's details by idclient.invoice.fetch("<INVOICE_ID>")Fetch all payment linkReferapi docsfor allowed query parameters.client.invoice.all()Cancel a payment link by idclient.invoice.cancel("<INVOICE_ID>")Send/resend notifications for a payment link by idclient.invoice.notify_by("<INVOICE_ID>","<MEDIUM>")# MEDIUM - sms/emailInvoicesCreate a new invoiceReferapi docsfor allowed request parameters in detail.client.invoice.create(data=DATA)Fetch a invoice by idclient.invoice.fetch("<INVOICE_ID>")Fetch all invoicesReferapi docsfor allowed query parameters.client.invoice.all()Cancel an invoice by idclient.invoice.cancel("<INVOICE_ID>")Send/resend notifications for an invoice by idclient.invoice.notify_by("<INVOICE_ID>","<MEDIUM>")# MEDIUM - sms/emailIssue an invoice in draft status by idclient.invoice.issue("<INVOICE_ID>")Delete an invoice by idclient.invoice.delete("<INVOICE_ID>")Edit an invoice by idReferapi docsfor allowed request parameters in detail.client.invoice.edit(invoice_id=invoice_id,data=DATA)Settlementsfetch a particular settlement detailclient.settlement.fetch("<SETTLEMENT_ID>")fetch all settlement detailclient.settlement.all()Cardfetch a particular card dataclient.card.fetch(card_id=card_id)Customerfetch a particular customer Infoclient.customer.fetch(customer_id=customer_id)Create a customerclient.customer.create(data=data)Edit a customer infoclient.customer.edit(customer_id=customer_id,data=data)Tokenfetch a token associated with a customerclient.token.fetch(customer_id=customer_id,token_id=token_id)fetch all tokens associated with customerclient.token.all(customer_id=customer_id)Delete a given token assicated with a customerclient.token.delete(customer_id=customer_id,token_id=token_id)Virtual Accountfetch all virtual account entitiesclient.virtual_account.all()fetch single virtual account detailsclient.virtual_account.fetch(virtual_account_id=virtual_account_id)create virtual accountclient.virtual_account.create(data=DATA)DATAshouldcontainthesekeysreceiver_types:['bank_account']description:'Random Description'customer_id(optional):<CUSTOMER_ID>close virtual accountclient.virtual_account.close(virtual_account_id=virtual_account_id)fetch all payments for virtual account idclient.virtual_account.payments(virtual_account_id=virtual_account_id)UtilityVerify Payment Signatureparams_dictshould haverazorpay_order_id,razorpay_payment_id,razorpay_signaturewhich are received in the callbackclient.utility.verify_payment_signature(params_dict)Verify Webhook Signaturewebhook_signatureis the signature you receive underX-Razorpay-Signaturein the webhook, whilewebhook_secretis the secret you used when creating the webhook on dashboard.client.utility.verify_webhook_signature(webhook_body,webhook_signature,webhook_secret)SubscriptionsCreate a new subscriptionclient.subscription.create(data=DATA)DATAshouldcontainthesekeysplan_id:plan_idofsubscriptioncustomer_id:idofcustomertotal_count:numberofsubscriptionsFetch a particular subscriptionclient.subscription.fetch("<SUBSCRIPTION_ID>")Fetch all subscriptionsclient.subscription.all()Cancel subscriptionclient.subscription.cancel("<SUBSCRIPTION_ID>")Create an addon for subscriptionclient.subscription.createAddon("<SUBSCRIPTION_ID>", data=DATA)
DATA should have these keys
    item               : dict with keys amount, name and currency
    quantity           : number of itemsFetch a particular addon Infoclient.addon.fetch(addon_id=addon_id)Delete an addonclient.addon.delete(addon_id=addon_id)PlansCreate a new planclient.plan.create(data=DATA)DATAshouldcontainthesekeysitem_id:correspondingitem_idFetch a particular planclient.plan.fetch("<PLAN_ID>")Fetch all plansclient.plan.all()TransfersFetch all Transfersclient.transfer.all()Fetch transfer by IDclient.transfer.fetch("<TRANSFER_ID>")Create Transfer from given dataclient.transfer.create(data=DATA)DATAshouldcontainthesekeysamount:100currency:INRaccount:acc_865rdfghu7632Edit Transfer from given dataclient.transfer.edit(transfer_id=transfer_id,data=DATA)DATAmaycontainthesekeyson_hold:True/Falseon_hold_until:15678903127For details on Transfer edit, please refer to the API guide:https://razorpay.com/docs/route/api-reference/#examplesReverse a given Transferclient.transfer.reverse(transfer_id=transfer_id)Fetch all reversals for a given Transferclient.transfer.reversals(transfer_id=transfer_id)Bugs? Feature requests? Pull requests?All of those are welcome. You canfile issuesorsubmit pull requestsin this repository.