Skip to content

Commit 62f5f34

Browse files
author
bitbucket-pipelines
committed
Generating Python SDK.
1 parent 4e4d008 commit 62f5f34

File tree

571 files changed

+48958
-38096
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

571 files changed

+48958
-38096
lines changed

.github/workflows/python.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# NOTE: This file is auto generated by OpenAPI Generator.
2+
# URL: https://openapi-generator.tech
3+
#
4+
# ref: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
5+
6+
name: cashfree_pg Python package
7+
8+
on: [push, pull_request]
9+
10+
jobs:
11+
build:
12+
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
17+
18+
steps:
19+
- uses: actions/checkout@v3
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install flake8 pytest
28+
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
29+
- name: Lint with flake8
30+
run: |
31+
# stop the build if there are Python syntax errors or undefined names
32+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
33+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
34+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
35+
- name: Test with pytest
36+
run: |
37+
pytest

.gitignore

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,3 @@ target/
6464

6565
#Ipython Notebook
6666
.ipynb_checkpoints
67-
68-
cashfree_pg/api
69-
.DS_Store
70-
__init__.py
71-
api_client.py
72-
api_response.py
73-
docs/

README.md

Lines changed: 89 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Cashfree PG Python SDK
2-
![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)
1+
# Cashfree PG Node SDK
2+
![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)
33

4-
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.
4+
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.
55

66

77

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

1818
### Installation
1919
```bash
20-
pip install cashfree_pg
20+
npm i cashfree-pg
2121
```
2222
### Configuration
2323

24-
```python
25-
from cashfree_pg.models.create_order_request import CreateOrderRequest
26-
from cashfree_pg.api_client import Cashfree
27-
from cashfree_pg.models.customer_details import CustomerDetails
28-
from cashfree_pg.models.order_meta import OrderMeta
24+
## Version >=5
2925

30-
Cashfree.XClientId = "<x-client-id>"
31-
Cashfree.XClientSecret = "<x-client-secret>"
32-
Cashfree.XEnvironment = Cashfree.SANDBOX
33-
x_api_version = "2023-08-01"
26+
```javascript
27+
import { Cashfree } from "cashfree-pg";
28+
29+
var cashfree = new Cashfree(Cashfree.SANDBOX, "<x-client-id>", "<x-client-secret>")
3430
```
3531

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

3834
### Basic Usage
3935
Create Order
40-
```python
41-
customerDetails = CustomerDetails(customer_id="walterwNrcMi", customer_phone="9999999999")
42-
orderMeta = OrderMeta(return_url="https://www.cashfree.com/devstudio/preview/pg/web/checkout?order_id={order_id}")
43-
createOrderRequest = CreateOrderRequest(order_amount=1, order_currency="INR", customer_details=customerDetails, order_meta=orderMeta)
44-
try:
45-
api_response = Cashfree().PGCreateOrder(x_api_version, createOrderRequest, None, None)
46-
print(api_response.data)
47-
except Exception as e:
48-
print(e)
36+
```javascript
37+
var request = {
38+
"order_amount": 1,
39+
"order_currency": "INR",
40+
"order_id": "order_34692745",
41+
"customer_details": {
42+
"customer_id": "walterwNrcMi",
43+
"customer_phone": "9999999999"
44+
},
45+
"order_meta": {
46+
"return_url": "https://www.cashfree.com/devstudio/preview/pg/web/checkout?order_id={order_id}"
47+
}
48+
};
49+
Cashfree.PGCreateOrder(request).then((response) => {
50+
console.log('Order Created successfully:',response.data)
51+
}).catch((error) => {
52+
console.error('Error:', error.response.data.message);
53+
});
4954
```
5055

5156
Get Order
52-
```python
53-
try:
54-
api_response = Cashfree().PGFetchOrder(x_api_version, "order_3242X4jQ5f0S9KYxZO9mtDL1Kx2Y7u", None)
55-
print(api_response.data)
56-
except Exception as e:
57-
print(e)
57+
```javascript
58+
Cashfree.PGFetchOrder("<order_id>").then((response) => {
59+
console.log('Order fetched successfully:', response.data);
60+
}).catch((error) => {
61+
console.error('Error:', error.response.data.message);
62+
});
63+
```
64+
65+
## Version <5
66+
67+
```javascript
68+
import { Cashfree } from "cashfree-pg";
69+
70+
Cashfree.XClientId = "<x-client-id>";
71+
Cashfree.XClientSecret = "<x-client-secret>";
72+
Cashfree.XEnvironment = Cashfree.Environment.SANDBOX;
73+
```
74+
75+
Generate your API keys (x-client-id , x-client-secret) from [Cashfree Merchant Dashboard](https://merchant.cashfree.com/merchants/login)
76+
77+
### Basic Usage
78+
Create Order
79+
```javascript
80+
var request = {
81+
"order_amount": 1,
82+
"order_currency": "INR",
83+
"order_id": "order_34692745",
84+
"customer_details": {
85+
"customer_id": "walterwNrcMi",
86+
"customer_phone": "9999999999"
87+
},
88+
"order_meta": {
89+
"return_url": "https://www.cashfree.com/devstudio/preview/pg/web/checkout?order_id={order_id}"
90+
}
91+
};
92+
Cashfree.PGCreateOrder("2023-08-01", request).then((response) => {
93+
console.log('Order Created successfully:',response.data)
94+
}).catch((error) => {
95+
console.error('Error:', error.response.data.message);
96+
});
97+
```
98+
99+
Get Order
100+
```javascript
101+
Cashfree.PGFetchOrder("2023-08-01", "<order_id>").then((response) => {
102+
console.log('Order fetched successfully:', response.data);
103+
}).catch((error) => {
104+
console.error('Error:', error.response.data.message);
105+
});
106+
```
107+
108+
Validate Webhook
109+
```javascript
110+
app.post('/webhook', function (req, res) {
111+
try {
112+
Cashfree.PGVerifyWebhookSignature(req.headers["x-webhook-signature"], req.rawBody, req.headers["x-webhook-timestamp"]);
113+
} catch (err) {
114+
console.log(err.message)
115+
}
116+
})
58117
```
59118

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

74133
- [Settlements](docs/Settlements.md)
75134

76-
- [Reconciliation](docs/Reconciliation.md)
77-
78-
- [Webhook](docs/Webhook.md)
135+
- [Offers](docs/Offers.md)
79136

137+
- [Reconciliation](docs/Reconciliation.md)
80138

81139
## Licence
82140

0 commit comments

Comments
 (0)