Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
37 changes: 37 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# NOTE: This file is auto generated by OpenAPI Generator.
# URL: https://openapi-generator.tech
#
# ref: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: cashfree_pg Python package

on: [push, pull_request]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest
7 changes: 0 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,3 @@ target/

#Ipython Notebook
.ipynb_checkpoints

cashfree_pg/api
.DS_Store
__init__.py
api_client.py
api_response.py
docs/
120 changes: 89 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Cashfree PG Python SDK
![GitHub](https://img.shields.io/github/license/cashfree/cashfree-pg-sdk-python) ![Discord](https://img.shields.io/discord/931125665669972018?label=discord) ![GitHub last commit (branch)](https://img.shields.io/github/last-commit/cashfree/cashfree-pg-sdk-python/master) ![GitHub release (with filter)](https://img.shields.io/github/v/release/cashfree/cashfree-pg-sdk-python?label=latest) ![GitHub forks](https://img.shields.io/github/forks/cashfree/cashfree-pg-sdk-python) ![Order Create API Order Create API](https://statuspage.cashfree.com/badge/pg-create-order-api/status)
# Cashfree PG Node SDK
![GitHub](https://img.shields.io/github/license/cashfree/cashfree-pg-sdk-nodejs) ![Discord](https://img.shields.io/discord/931125665669972018?label=discord) ![GitHub last commit (branch)](https://img.shields.io/github/last-commit/cashfree/cashfree-pg-sdk-nodejs/main) ![GitHub release (with filter)](https://img.shields.io/github/v/release/cashfree/cashfree-pg-sdk-nodejs?label=latest) ![npm](https://img.shields.io/npm/v/cashfree-pg) ![GitHub forks](https://img.shields.io/github/forks/cashfree/cashfree-pg-sdk-nodejs) [![Coverage Status](https://coveralls.io/repos/github/cashfree/cashfree-pg-sdk-nodejs/badge.svg?branch=)](https://coveralls.io/github/cashfree/cashfree-pg-sdk-nodejs?branch=main)

The Cashfree PG Python SDK offers a convenient solution to access [Cashfree PG APIs](https://docs.cashfree.com/reference/pg-new-apis-endpoint) from a server-side Go applications.
The Cashfree PG Node SDK offers a convenient solution to access [Cashfree PG APIs](https://docs.cashfree.com/reference/pg-new-apis-endpoint) from a server-side JavaScript applications.



Expand All @@ -17,44 +17,103 @@ Try out our interactive guides at [Cashfree Dev Studio](https://www.cashfree.com

### Installation
```bash
pip install cashfree_pg
npm i cashfree-pg
```
### Configuration

```python
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
## Version >=5

Cashfree.XClientId = "<x-client-id>"
Cashfree.XClientSecret = "<x-client-secret>"
Cashfree.XEnvironment = Cashfree.SANDBOX
x_api_version = "2023-08-01"
```javascript
import { Cashfree } from "cashfree-pg";

var cashfree = new Cashfree(Cashfree.SANDBOX, "<x-client-id>", "<x-client-secret>")
```

Generate your API keys (x-client-id , x-client-secret) from [Cashfree Merchant Dashboard](https://merchant.cashfree.com/merchants/login)

### Basic Usage
Create Order
```python
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)
```javascript
var request = {
"order_amount": 1,
"order_currency": "INR",
"order_id": "order_34692745",
"customer_details": {
"customer_id": "walterwNrcMi",
"customer_phone": "9999999999"
},
"order_meta": {
"return_url": "https://www.cashfree.com/devstudio/preview/pg/web/checkout?order_id={order_id}"
}
};
Cashfree.PGCreateOrder(request).then((response) => {
console.log('Order Created successfully:',response.data)
}).catch((error) => {
console.error('Error:', error.response.data.message);
});
```

Get Order
```python
try:
api_response = Cashfree().PGFetchOrder(x_api_version, "order_3242X4jQ5f0S9KYxZO9mtDL1Kx2Y7u", None)
print(api_response.data)
except Exception as e:
print(e)
```javascript
Cashfree.PGFetchOrder("<order_id>").then((response) => {
console.log('Order fetched successfully:', response.data);
}).catch((error) => {
console.error('Error:', error.response.data.message);
});
```

## Version <5

```javascript
import { Cashfree } from "cashfree-pg";

Cashfree.XClientId = "<x-client-id>";
Cashfree.XClientSecret = "<x-client-secret>";
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;
```

Generate your API keys (x-client-id , x-client-secret) from [Cashfree Merchant Dashboard](https://merchant.cashfree.com/merchants/login)

### Basic Usage
Create Order
```javascript
var request = {
"order_amount": 1,
"order_currency": "INR",
"order_id": "order_34692745",
"customer_details": {
"customer_id": "walterwNrcMi",
"customer_phone": "9999999999"
},
"order_meta": {
"return_url": "https://www.cashfree.com/devstudio/preview/pg/web/checkout?order_id={order_id}"
}
};
Cashfree.PGCreateOrder("2023-08-01", request).then((response) => {
console.log('Order Created successfully:',response.data)
}).catch((error) => {
console.error('Error:', error.response.data.message);
});
```

Get Order
```javascript
Cashfree.PGFetchOrder("2023-08-01", "<order_id>").then((response) => {
console.log('Order fetched successfully:', response.data);
}).catch((error) => {
console.error('Error:', error.response.data.message);
});
```

Validate Webhook
```javascript
app.post('/webhook', function (req, res) {
try {
Cashfree.PGVerifyWebhookSignature(req.headers["x-webhook-signature"], req.rawBody, req.headers["x-webhook-timestamp"]);
} catch (err) {
console.log(err.message)
}
})
```

## Supported Resources
Expand All @@ -73,10 +132,9 @@ except Exception as e:

- [Settlements](docs/Settlements.md)

- [Reconciliation](docs/Reconciliation.md)

- [Webhook](docs/Webhook.md)
- [Offers](docs/Offers.md)

- [Reconciliation](docs/Reconciliation.md)

## Licence

Expand Down
Loading
Loading