Giter VIP home page Giter VIP logo

razorpay-python's Introduction

Razorpay Python Client

PyPI Version Build Status Coverage Status License

Python bindings for interacting with the Razorpay API

This is primarily meant for merchants who wish to perform interactions with the Razorpay 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

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>")

Invoices

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)

Utility

  • Verify Payment Signature

    params_dict should have razorpay_order_id, razorpay_payment_id, razorpay_signature
    which are received with the cord callback
    client.utility.verify_payment_signature(params_dict)
  • 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)
  • Stringify a payment method for an invoice/receipt

    client.utility.strf_payment_method(payment_info)
    # Where payment_info is the dict returned by client.payment.capture and client.payment.fetch
    # or one of the items in the client.payment.all response
  • All available payment methods

    client.utility.payment_methods

Bugs? Feature requests? Pull requests?

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

razorpay-python's People

Contributors

captn3m0 avatar harman28 avatar mayankamencherla avatar mehernosh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.