Payabbhi Python Library http://payabbhi.com
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
payabbhi
.gitignore
CHANGELOG.md
LICENSE
LONG_DESCRIPTION.rst
MANIFEST.in
README.md
VERSION
setup.py
tox.ini

README.md

license

Payabbhi Python library

Make sure you have signed up for your Payabbhi Account and downloaded the API keys from the Portal.

Requirements

Python 2.6 and later.

pip

The library can be installed via pip. Run the following command:

$ pip install payabbhi

Manual Installation

Download the library and install as below:

python setup.py install

Dependencies

The library requires the following extensions:

If installed via setup.py, the dependencies are handled automatically. In case of manual installation, make sure that the dependencies are resolved.

Documentation

Please refer to:

Getting Started

Authentication

import payabbhi
# Set your credentials
client = payabbhi.Client(access_id='<access_id>', secret_key='<secret_key>')

# Optionally set your app info.
# app_version and app_url are optional
client.set_app_info(app_name='app_name',
                    app_version='app_version',
                    app_url='app_url')

Orders

# Create order
created_order = client.order.create(data={'amount':100,
                                  'merchant_order_id': '<merchant_order_id>',
                                  'currency':'INR',
                                  'payment_auto_capture':False})

# Retrieve a particular order object
order = client.order.retrieve('<order_id>')

# Retrieve a set of order objects based on given filter params
list_of_orders = client.order.all(data={'count': 5})

# Retrieve a set of payments for a given order
payments = retrieved_order.payments()

Payments

# Retrieve all payments
payments = client.payment.all(data={'count': 10})

# Retrieve a particular payment object
payment = client.payment.retrieve('<payment_id>')

# Capture a payment
payment = payment.capture()

# Refund a payment
refund = payment.refund(data={'amount':100,
                    'currency':'INR'})

# Retrieve a set of refund objects for a given payment with optional filter params
refunds = client.payment.refunds('<payment_id>', data={'count': 2})

Refunds

# Create a refund
refund = client.refund.create('<payment_id>')

# Create a partial refund
refund = client.refund.create('<payment_id>', data={'amount':100})

# Retrieve a set of refunds with the given filter params
refunds = client.refund.all(data={'count': 2})

# Retrieve a particular refund object
refund = client.refund.retrieve('<refund_id>')

Verify a payment signature

client.utility.verify_payment_signature({
        'order_id': '<order_id>',
        'payment_id': '<payment_id>',
        'payment_signature': '<payment_signature>'
})

Verify webhook signature

# replay_interval is optional. (default value is 300 seconds)
client.utility.verify_webhook_signature('<payload>','<actual_signature>','<secret>',<replay_interval>)

Tests

Install dependencies to run unittests

$ pip install unittest2 responses

or using easy_install

$ easy_install unittest2 responses

N.B: make sure version of six must be atleast 1.10.0

Now run the entire test suite using

$ python -m unittest2 discover

Or to run an individual test file:

$ python -m unittest2 discover -p test_payment.py

Testing for different versions of Python

Payabbhi Python Library is compatible with Python 2.6+, Python 3.3+ . We should run these tests for all the supported versions . For local testing, we use tox to handle testing against different Python versions.

Setting up tox

Install tox using pip install tox and then simply run tox from the project root. But to make tox work you will need an interpreter installed for each of the versions of python we test (see the envlist in tox.ini). You can find these releases on Python downloads page.

You may choose not to install interpreters for every Python version we support. In that case, test at least any one of Python 2.x versions and any one of Python 3.x versions.

You can test with a specific interpreter e.g. Python 2.7 using tox -e py27.