Library to integrate cashfree APIs
Project description
Cashfree SDK's are released in Beta. This is work in progress and we are continuously working on improving various aspects of it. It is released as learning aid and example kit for the API integrators. This is not recommended by Cashfree for direct use in production code. Please report any bugs to Cashfree at techsupport@cashfree.com.
cashfree-sdk-python
The official Cashfree SDK for Python3,
Get started quickly using Cashfree with the Cashfree SDK for python. The SDK helps take the complexity out of coding by providing Python objects for Cashfree services including Payouts, Payment Gateway, Marketplace and Autocollect. The single, downloadable package includes the Cashfree Python Library and documentation.
Please refer to the Cashfree Docs for the complete API reference.
Installing
In Django or Flask Application for Python 3.5+
The preferred way to install the Cashfree SDK for Python is to use the pip package manager for pip. Simply type the following into a terminal window:
pip3 install cashfree-sdk
Getting Started
Pre-requisites
- A Cashfree Merchant Account
- API keys for different products. You can generate them from your Dashboard
IP Whitelisting and dynamic IPs
Your IP has to be whitelisted to hit Cashfree's server. Or if you have a dynamic IP please pass in the public key parameter during the init method as shown below. For more information please go here.
Usage
Payouts
The package needs to be configured with your account's secret key which is available in your Cashfree Dashboard. Init the package with your credentials and add the below code in your config.py of your package.
In case of static IP (Your IP is whitelisted)
from cashfree_sdk.payouts import Payouts
//Initialize Cashfree Payout
Payouts.init("<client_id>", "<client_secret>", "PROD")
In case of dynamic IP you will need a public key to generate a signature(which will be done by sdk itself)
from cashfree_sdk.payouts import Payouts
//Initialize Cashfree Payout
Payouts.init("<client_id>", "<client_secret>", "PROD", public_key_path='/User/Cashfree/file_path.pem')
// OR
Payouts.init("<client_id>", "<client_secret>", "PROD", public_key= b'public key')
Option | Default | Description |
---|---|---|
env |
TEST |
Environment to be initialized. Can be set to TEST or PROD |
client_id |
`` | client_id which can be generated on cashfree dashboard. |
client_secret |
`` | client_secret which can be found alongside generated client_id . |
public_key_path |
`` | public_key_path specify the path to your .pem public key file `. |
public_key |
`` | public_key Pass your Public Key to this parameter as an alternative to public_key_path . |
Payout Library Docs
WebHook Verification
To verify the webhook received from Cashfree for different events and accept the webhook only when it returns True
.
Usage
Pass the webhook received along with the payload type.
Option | Options |
---|---|
payload_type |
JSON for application/json , FORM for application/x-www-form-urlencoded |
from cashfree_sdk import verification
webhook_data = '{"cashgramId": "5b8283182e0711eaa4c531df6a4f439b-28", "event": "CASHGRAM_EXPIRED", "eventTime": "2020-01-03 15:01:06", "reason": "OTP_ATTEMPTS_EXCEEDED", "signature": "TBpM+4nr1DsWsov7QiHSTfRJP4Z9BD8XrDgEhBlf9ss="}'
verification.verify_webhook(webhook_data, 'JSON')
Using Python requests
Every method returns a python request object which can be used:
from cashfree_sdk.payouts.beneficiary import Beneficiary
bene_add = Beneficiary.add("kit_test6", "ankur", "ankur@cashfree.com", "9999999999", "aakjakjakja")
- All Optional Arguments Should Be Passed As An Keyword (Named) Arguments
Readme for the exception thrown for invalid operation and how to handle the exceptions.
TODO
- PG
- Market Place
- Autocollect
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file cashfree_sdk-0.1.3.tar.gz
.
File metadata
- Download URL: cashfree_sdk-0.1.3.tar.gz
- Upload date:
- Size: 13.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6454b0a460084b451af70ed0a3bed7a3dba047642bec96b0347aa1bdb0166b8 |
|
MD5 | 32136fc82b7e9ae12892987f33176361 |
|
BLAKE2b-256 | b4131d965fc8586dc1b9e6be4bd7611239dc03744c0de0a1779b53d3f3c3f7fd |