Skip to main content

squares the number

Project description

RazorpayX Python Client

PyPI Version Build Status Coverage Status PyPI License

Python bindings for interacting with the RazorpayX API

This is primarily meant for merchants who wish to perform interactions with the RazorpayX API programatically.

Installation

$ pip install razorpay

Usage

You need to setup your key and secret using the following: You can find your API keys at https://dashboard.razorpay.com/#/app/keys.

import razorpay
client = razorpay.Client(auth=("<YOUR_API_KEY>", "<YOUR_API_SECRET>"))

App Details

After 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 to Django and version to 1.8.17. Please ensure that both app title and version are strings.

Payments

  • Fetch all payments

    client.payment.all()
    
  • Fetch a particular payment

    client.payment.fetch("<PAYMENT_ID>")
    
  • Capture a payment

    client.payment.capture("<PAYMENT_ID>", "<AMOUNT>")
    Note: <AMOUNT> should be same as the original amount while creating the payment
    
  • Refund a payment

    client.payment.refund("<PAYMENT_ID>", "<AMOUNT>")
    # for full refund
    
    client.payment.refund("<PAYMENT_ID>", "<AMOUNT_TO_BE_REFUNDED>")
    # for particular amount
    
    Note: <AMOUNT_TO_BE_REFUNDED> should be equal/less than the original amount
    
  • Get Bank Transfer Entity for given payment

    client.payment.bank_transfer("<PAYMENT_ID>")
    
  • Create transfer for given payment id

    client.payment.transfer("<PAYMENT_ID>")
    

    For List of params refer to the API guide : https://razorpay.com/docs/route/api-reference/#creating-payments

  • Fetch all transfers associated with the payment

    client.payment.transfers("<PAYMENT_ID>")
    

Refunds

  • Fetch a particular refund

    client.refund.fetch("<refund_id>")
    
  • Fetch all refunds

    client.refund.all()
    

Orders

  • Create a new order

    client.order.create(data=DATA)
    DATA should contain these keys
        amount           : amount of order
        currency         : currency of order
        receipt          : receipt id of order
        payment_capture  : 1 if capture should be done automatically or else 0
        notes(optional)  : optional notes for order
    
  • fetch a particular order

    client.order.fetch("<ORDER_ID>")
    
  • fetch all orders

    client.order.all()
    
  • fetch Payments of order

    client.order.payments("<ORDER_ID>")
    

Payment Link

  • Create payment link

    Refer api docs for 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 id

    client.invoice.fetch("<INVOICE_ID>")
    
  • Fetch all payment link

    Refer api docs for allowed query parameters.

    client.invoice.all()
    
  • Cancel a payment link by id

    client.invoice.cancel("<INVOICE_ID>")
    
  • Send/resend notifications for a payment link by id

    client.invoice.notify_by("<INVOICE_ID>", "<MEDIUM>")
    # MEDIUM - sms/email
    

Invoices

  • Create a new invoice

    Refer api docs for allowed request parameters in detail.

    client.invoice.create(data=DATA)
    
  • Fetch a invoice by id

    client.invoice.fetch("<INVOICE_ID>")
    
  • Fetch all invoices

    Refer api docs for allowed query parameters.

    client.invoice.all()
    
  • Cancel an invoice by id

    client.invoice.cancel("<INVOICE_ID>")
    
  • Send/resend notifications for an invoice by id

    client.invoice.notify_by("<INVOICE_ID>", "<MEDIUM>")
    # MEDIUM - sms/email
    
  • Issue an invoice in draft status by id

    client.invoice.issue("<INVOICE_ID>")
    
  • Delete an invoice by id

    client.invoice.delete("<INVOICE_ID>")
    
  • Edit an invoice by id

    Refer api docs for allowed request parameters in detail.

    client.invoice.edit(invoice_id=invoice_id,data=DATA)
    

Settlements

  • fetch a particular settlement detail

    client.settlement.fetch("<SETTLEMENT_ID>")
    
  • fetch all settlement detail

    client.settlement.all()
    

Card

  • fetch a particular card data

    client.card.fetch(card_id=card_id)
    

Customer

  • fetch a particular customer Info

    client.customer.fetch(customer_id=customer_id)
    
  • Create a customer

    client.customer.create(data=data)
    
  • Edit a customer info

    client.customer.edit(customer_id=customer_id, data=data)
    

Token

  • fetch a token associated with a customer

    client.token.fetch(customer_id=customer_id, token_id=token_id)
    
  • fetch all tokens associated with customer

    client.token.all(customer_id=customer_id)
    
  • Delete a given token assicated with a customer

    client.token.delete(customer_id=customer_id, token_id=token_id)
    

Virtual Account

  • fetch all virtual account entities

    client.virtual_account.all()
    
  • fetch single virtual account details

    client.virtual_account.fetch(virtual_account_id=virtual_account_id)
    
  • create virtual account

    client.virtual_account.create(data=DATA)
    DATA should contain these keys
        receiver_types        : ['bank_account']
        description           : 'Random Description'
        customer_id(optional) : <CUSTOMER_ID>
    
  • close virtual account

    client.virtual_account.close(virtual_account_id=virtual_account_id)
    
  • fetch all payments for virtual account id

    client.virtual_account.payments(virtual_account_id=virtual_account_id)
    

Utility

  • Verify Payment Signature

    params_dict should have razorpay_order_id, razorpay_payment_id, razorpay_signature which are received in the callback

    client.utility.verify_payment_signature(params_dict)
    
  • Verify Webhook Signature

    webhook_signature is the signature you receive under X-Razorpay-Signature in the webhook, while webhook_secret is the secret you used when creating the webhook on dashboard.

    client.utility.verify_webhook_signature(webhook_body, webhook_signature, webhook_secret)
    

Subscriptions

  • Create a new subscription

    client.subscription.create(data=DATA)
    DATA should contain these keys
        plan_id           : plan_id of subscription
        customer_id       : id of customer
        total_count       : number of subscriptions
    
  • Fetch a particular subscription

    client.subscription.fetch("<SUBSCRIPTION_ID>")
    
  • Fetch all subscriptions

    client.subscription.all()
    
  • Cancel subscription

    client.subscription.cancel("<SUBSCRIPTION_ID>")
    
  • Create an addon for subscription

    client.subscription.createAddon("<SUBSCRIPTION_ID>", data=DATA)
    DATA should have these keys
        item               : dict with keys amount, name and currency
        quantity           : number of items
    
  • Fetch a particular addon Info

    client.addon.fetch(addon_id=addon_id)
    
  • Delete an addon

    client.addon.delete(addon_id=addon_id)
    

Plans

  • Create a new plan

    client.plan.create(data=DATA)
    DATA should contain these keys
        item_id           : corresponding item_id
    
  • Fetch a particular plan

    client.plan.fetch("<PLAN_ID>")
    
  • Fetch all plans

    client.plan.all()
    

Transfers

  • Fetch all Transfers

    client.transfer.all()
    
  • Fetch transfer by ID

    client.transfer.fetch("<TRANSFER_ID>")
    
  • Create Transfer from given data

    client.transfer.create(data=DATA)
    DATA should contain these keys
        amount   : 100
        currency : INR
        account  : acc_865rdfghu7632
    
  • Edit Transfer from given data

    client.transfer.edit(transfer_id=transfer_id, data=DATA)
    DATA may contain these keys
        on_hold       : True/False
        on_hold_until : 15678903127
    

    For details on Transfer edit, please refer to the API guide: https://razorpay.com/docs/route/api-reference/#examples

  • Reverse a given Transfer

    client.transfer.reverse(transfer_id=transfer_id)
    
  • Fetch all reversals for a given Transfer

    client.transfer.reversals(transfer_id=transfer_id)
    

Bugs? Feature requests? Pull requests?

All of those are welcome. You can file issues or submit pull requests in this repository.

Project details


Release history Release notifications | RSS feed

This version

1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

vishwam_test-1.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

vishwam_test-1.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file vishwam_test-1.0.tar.gz.

File metadata

  • Download URL: vishwam_test-1.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for vishwam_test-1.0.tar.gz
Algorithm Hash digest
SHA256 a0cf4d4bf47d2a95a654f9dfa17e8acf8ca8e17e46121ff903c9b8a8798f9a9b
MD5 a5ce516ce49fe34162664a3be181bfa5
BLAKE2b-256 d873376bde008eead584d7000c8954752bae7b5a65ed93a9165201d87f128d20

See more details on using hashes here.

File details

Details for the file vishwam_test-1.0-py3-none-any.whl.

File metadata

  • Download URL: vishwam_test-1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for vishwam_test-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 658184e49303fc4f9771fd273250b56cfcd017522e68a6c9e34360e9be75030f
MD5 3c004584bb89b12e77a07d6e0810e63b
BLAKE2b-256 75c1f6c29f2385ccaab5530fbebfe24cf7ac1335b2e83da8c42d797cb1f60e3f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page