Skip to main content

Cashfree PG Python SDK

GitHub Discord GitHub last commit (branch) GitHub release (with filter) GitHub forks Order Create API Order Create API

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

Metadata

Release files for cashfree-pg 6.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cashfree-pg 6.0.7
File Size Uploaded Provenance Actions
cashfree_pg-6.0.7.tar.gz 261.2 kB Without provenance Details for cashfree_pg-6.0.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for cashfree-pg 6.0.7
File Interpreter ABI Platform Actions
cashfree_pg-6.0.7-py3-none-any.whl Python 3 none any Details for cashfree_pg-6.0.7-py3-none-any.whl

Total release size: 878.0 kB

Release files / cashfree_pg-6.0.7.tar.gz

Download URL cashfree_pg-6.0.7.tar.gz
Size 261.2 kB
Tags Source
SHA-256 checksum
How to use checksums
8f4e309c880de7da1343cb2f8d4fddad6b402b1be3e176b53c16dbde978b9f64
BLAKE2b-256 checksum
How to use checksums
b492211316d056b2a79fbd69b8bc44d4174195c331444f9c84b7d05ccc549e12
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.7-py3-none-any.whl

Download URL cashfree_pg-6.0.7-py3-none-any.whl
Size 616.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ae3ccbbe8dc06cc0f82eedc62218f77822f1231b510945015cdb4ccdc982c12b
BLAKE2b-256 checksum
How to use checksums
bf180480fe4ddf52eecddb885399b64ee6c0a5f3642257c57c7afa231af016db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.25

Security for cashfree-pg 6.0.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

6.0.7 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page