Cashfree PG Python SDK
The Cashfree PG Python SDK offers a convenient solution to access Cashfree PG APIs from a server-side Go applications.
Documentation
Cashfree's PG API Documentation - https://docs.cashfree.com/reference/pg-new-apis-endpoint
Learn and understand payment gateway workflows at Cashfree Payments here
Try out our interactive guides at Cashfree Dev Studio !
Getting Started
Installation
pip install cashfree_pg
Configuration
Version >=6
from cashfree_pg.models.create_order_request import CreateOrderRequest
from cashfree_pg.api_client import Cashfree
from cashfree_pg.models.customer_details import CustomerDetails
from cashfree_pg.models.order_meta import OrderMeta
cashfree_instance = Cashfree(
XEnvironment=Cashfree.SANDBOX,
XClientId="<x-client-id>",
XClientSecret="<x-client-secret>",
XPartnerKey="<x-partner-key>",
XClientSignature="<x-client-signature>",
XPartnerMerchantId="<x-partner-merchant-id>"
)
Generate your API keys (x-client-id , x-client-secret) from Cashfree Merchant Dashboard
Basic Usage
Create Order
customerDetails = CustomerDetails(customer_id="walterwNrcMi", customer_phone="9999999999")
orderMeta = OrderMeta(return_url="https://www.cashfree.com/devstudio/preview/pg/web/checkout?order_id={order_id}")
createOrderRequest = CreateOrderRequest(order_amount=1, order_currency="INR", customer_details=customerDetails, order_meta=orderMeta)
try:
api_response = cashfree_instance.PGCreateOrder(createOrderRequest, None, None)
print(api_response.data)
except Exception as e:
print(e)
Get Order
try:
api_response = cashfree_instance.PGFetchOrder("order_3242X4jQ5f0S9KYxZO9mtDL1Kx2Y7u", None, None)
print(api_response.data)
except Exception as e:
print(e)
Version <6
from cashfree_pg.models.create_order_request import CreateOrderRequest
from cashfree_pg.api_client import Cashfree
from cashfree_pg.models.customer_details import CustomerDetails
from cashfree_pg.models.order_meta import OrderMeta
Cashfree.XClientId = "<x-client-id>"
Cashfree.XClientSecret = "<x-client-secret>"
Cashfree.XEnvironment = Cashfree.SANDBOX
x_api_version = "2023-08-01"
cashfree = Cashfree()
Generate your API keys (x-client-id , x-client-secret) from Cashfree Merchant Dashboard
Basic Usage
Create Order
customerDetails = CustomerDetails(customer_id="walterwNrcMi", customer_phone="9999999999")
orderMeta = OrderMeta(return_url="https://www.cashfree.com/devstudio/preview/pg/web/checkout?order_id={order_id}")
createOrderRequest = CreateOrderRequest(order_amount=1, order_currency="INR", customer_details=customerDetails, order_meta=orderMeta)
try:
api_response = cashfree.PGCreateOrder(x_api_version, createOrderRequest, None, None)
print(api_response.data)
except Exception as e:
print(e)
Get Order
try:
api_response = cashfree.PGFetchOrder(x_api_version, "order_3242X4jQ5f0S9KYxZO9mtDL1Kx2Y7u", None)
print(api_response.data)
except Exception as e:
print(e)
Supported Resources
Licence
Apache Licensed. See LICENSE.md for more details
Release files for cashfree-pg 6.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| cashfree_pg-6.0.1.tar.gz | 250.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cashfree_pg-6.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 840.2 kB
Release files / cashfree_pg-6.0.1.tar.gz
| Download URL | cashfree_pg-6.0.1.tar.gz |
|---|---|
| Size | 250.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ba90111239866e1be9055f195959767bc6c36f38db0398582e690c7386b565fb
|
|
BLAKE2b-256 checksum How to use checksums |
40b9515f272a447b3efc1157d165cf26b5e894470448b1b1c14b33067557048d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / cashfree_pg-6.0.1-py3-none-any.whl
| Download URL | cashfree_pg-6.0.1-py3-none-any.whl |
|---|---|
| Size | 589.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6ea294b97b86f7bf0dffdcf61ce5242a16618efa877f5abdef7fb9ac1fe89634
|
|
BLAKE2b-256 checksum How to use checksums |
0c03616b7934d0a84c6d023b02d7e4832acff27002a43db3f03ba0f8460f8f13
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|