# cashfree-pg-sdk-python
- API version: 2022-09-01
- Package version: 2.0.1
---
## Requirements.
Python 2.7 and 3.4+
## Discord Server Support
Official Discord server is helpful to get support regarding any cashfree SDK , share any issues , raise tickets , give suggestions and request features for the SDK. Join the community of like-minded developers using the link provided below.
Link :- https://discord.gg/HrCz9tW2sh
## Installation & Usage
### pip install
Yyou can install directly using:
```sh
pip3 install git+https://github.com/cashfree/cashfree-pg-sdk-python.git
```
(you may need to run `pip3` with root permission: `sudo pip3 install git+https://github.com/cashfree/cashfree-pg-sdk-python.git`)
Then import the package:
```python
import cashfree_pg_sdk_python
```
### Setuptools
Install via [Setuptools](http://pypi.python.org/pypi/setuptools).
```sh
python3 setup.py install --user
```
(or `sudo python3 setup.py install` to install the package for all users)
Then import the package:
```python
import cashfree_pg_sdk_python
```
## Getting Started
Please follow the [installation procedure](#installation--usage) and then run the following:
The following part is the basic and common setup required to make any request to Casfhfree using the sdk.
```python
# Note : Please visit https://docs.cashfree.com/ for the complete documentation of the various terminologies used below,
# if not familiar with.
from __future__ import print_function
import time
import cashfree_pg_sdk_python
from cashfree_pg_sdk_python.rest import ApiException
from pprint import pprint
# Defining the host is optional and defaults to https://sandbox.cashfree.com/pg
# See configuration.py for a list of all supported configuration parameters.
configuration = CFPython_sdk.Configuration(
host = "https://sandbox.cashfree.com/pg"
)
# Enter a context with an instance of the API client
with CFPython_sdk.ApiClient(configuration) as api_client:
# Create an instance of the API class
api_instance = CFPython_sdk.OrdersApi(api_client)
x_client_id = 'x_client_id_example' # str |
x_client_secret = 'x_client_secret_example' # str |
x_api_version = '2022-09-01' # str | (optional) (default to '2022-09-01')
x_idempotency_replayed = False # bool | (optional) (default to False)
x_idempotency_key = 'x_idempotency_key_example' # str | (optional)
x_request_id = 'x_request_id_example' # str | (optional)
cf_order_request = CFPython_sdk.CFOrderRequest() # CFOrderRequest | (optional)
```
### Making the config and headers for the subsequent CreateOrder / pay_order etc. requests
The variables declared and assigned in the previous (GETTING STARTED) step will be used here.
```python
cf_config_test = CFConfig(x_client_id,
x_client_secret, x_api_version, CFenv.SANDBOX)
# cfHeaders consists of two things mainly, 1) x-idempotecy-key and 2) x-request-id ; x-request-id can help the consumer of the # sdk to maintain meaningful logs on their side. This can be a unique/non-unique identifier that the consumer can use. It is
# advisable that x-request-id be unique for each request so that the logging of the events of one request do not clash
# with the other. Here, request is a CreateOrder/OrderPay etc. requests that the consumer makes to cashfree.
cf_headers_test = CFHeaders(
x_idempotency_key, x_request_id)
```
### Creating an Order
The following snippet provides an example on how to create an order with Cashfree
```python
# Making the create order request. For more extensive
cf_order_request_test = cf_order_request.CFOrderRequest(
order_amount=10.16,
order_currency="INR",
customer_details=cf_customer_details.CFCustomerDetails(
customer_id="testpythonSDKUSER",
customer_email="email@cf.com",
customer_phone="9999999999"
), order_note="YOUR_NOTE",
order_tags={
"key": "key_example",
},
order_meta=CFOrderMeta(
payment_methods="nb,upi",
notify_url="https://webhook.merchantsite.com/691ffcf3-80db-4c10-b0d6-fbdc0be7b146" # This is the webhook url.
),
)
# Create Order Snippet
try:
createOrderResult = CreateOrder(cf_config_test, cf_headers_test,
cf_order_request_test)
print("Creat order successful with the following details")
print(createOrderResult)
except ApiException as e:
print("Exception when calling create order: %s\n" % e)
```
Note: createOrderResult[0].order_id can be used to get the order id from the response.
### Getting Order Details
You may wonder why is this function important -> Although you get the order details of the created order in the response of the CreateOrder as a part of the result above , but if you have to get the order details again after some time against the orderid then this function can be utilised.
The following snippet is an example on how to use the function.
```python
# Get Order Snippet
try:
GetOrderResult = GetOrder(cfconfigtest, cfheaderstest,
result[0].order_id)
print("Get Order successful wiith the following details")
print(createOrderResult)
except ApiException as e:
print("Exception when calling create order: %s\n" % e)
```
### Other funtions
Pay Order call , getting transaction details and creating refund are all supported by this SDK, the same payload as in the normal API can be created and passed to the funtions and the SDK takes care of the network call thereafter.
gatewayiinterface.py contains all the methods that can be used.
For any queries/help join the Official discord group mentioned in the beginning of this README doc.
## Documentation For Models
- [CFApp](docs/CFApp.md)
- [CFAppPayment](docs/CFAppPayment.md)
- [CFAuthorizationInPaymentsEntity](docs/CFAuthorizationInPaymentsEntity.md)
- [CFAuthorizationRequest](docs/CFAuthorizationRequest.md)
- [CFCard](docs/CFCard.md)
- [CFCardEMI](docs/CFCardEMI.md)
- [CFCardPayment](docs/CFCardPayment.md)
- [CFCardlessEMI](docs/CFCardlessEMI.md)
- [CFCardlessEMIPayment](docs/CFCardlessEMIPayment.md)
- [CFCryptogram](docs/CFCryptogram.md)
- [CFCustomerDetails](docs/CFCustomerDetails.md)
- [CFEMIPayment](docs/CFEMIPayment.md)
- [CFError](docs/CFError.md)
- [CFFetchAllSavedInstruments](docs/CFFetchAllSavedInstruments.md)
- [CFLink](docs/CFLink.md)
- [CFLinkCancelledResponse](docs/CFLinkCancelledResponse.md)
- [CFLinkCustomerDetailsEntity](docs/CFLinkCustomerDetailsEntity.md)
- [CFLinkMetaEntity](docs/CFLinkMetaEntity.md)
- [CFLinkNotifyEntity](docs/CFLinkNotifyEntity.md)
- [CFLinkOrders](docs/CFLinkOrders.md)
- [CFLinkRequest](docs/CFLinkRequest.md)
- [CFNetbanking](docs/CFNetbanking.md)
- [CFNetbankingPayment](docs/CFNetbankingPayment.md)
- [CFOrder](docs/CFOrder.md)
- [CFOrderMeta](docs/CFOrderMeta.md)
- [CFOrderPayData](docs/CFOrderPayData.md)
- [CFOrderPayRequest](docs/CFOrderPayRequest.md)
- [CFOrderPayResponse](docs/CFOrderPayResponse.md)
- [CFOrderRequest](docs/CFOrderRequest.md)
- [CFPaylater](docs/CFPaylater.md)
- [CFPaylaterPayment](docs/CFPaylaterPayment.md)
- [CFPaymentMethod](docs/CFPaymentMethod.md)
- [CFPaymentURLObject](docs/CFPaymentURLObject.md)
- [CFPaymentsEntity](docs/CFPaymentsEntity.md)
- [CFPaymentsEntityApp](docs/CFPaymentsEntityApp.md)
- [CFPaymentsEntityAppPayment](docs/CFPaymentsEntityAppPayment.md)
- [CFPaymentsEntityCard](docs/CFPaymentsEntityCard.md)
- [CFPaymentsEntityCardPayment](docs/CFPaymentsEntityCardPayment.md)
- [CFPaymentsEntityCardlessEMI](docs/CFPaymentsEntityCardlessEMI.md)
- [CFPaymentsEntityCardlessEMIPayment](docs/CFPaymentsEntityCardlessEMIPayment.md)
- [CFPaymentsEntityMethod](docs/CFPaymentsEntityMethod.md)
- [CFPaymentsEntityNetbankingPayment](docs/CFPaymentsEntityNetbankingPayment.md)
- [CFPaymentsEntityPaylater](docs/CFPaymentsEntityPaylater.md)
- [CFPaymentsEntityPaylaterPayment](docs/CFPaymentsEntityPaylaterPayment.md)
- [CFPaymentsEntityUPI](docs/CFPaymentsEntityUPI.md)
- [CFPaymentsEntityUPIPayment](docs/CFPaymentsEntityUPIPayment.md)
- [CFRefund](docs/CFRefund.md)
- [CFRefundRequest](docs/CFRefundRequest.md)
- [CFRefundURLObject](docs/CFRefundURLObject.md)
- [CFSavedInstrumentMeta](docs/CFSavedInstrumentMeta.md)
- [CFSettlementURLObject](docs/CFSettlementURLObject.md)
- [CFSettlementsEntity](docs/CFSettlementsEntity.md)
- [CFUPI](docs/CFUPI.md)
- [CFUPIAuthorizeDetails](docs/CFUPIAuthorizeDetails.md)
- [CFUPIPayment](docs/CFUPIPayment.md)
- [CFVendorSplit](docs/CFVendorSplit.md)
- [LinkCancelledError](docs/LinkCancelledError.md)
- [RefundSpeed](docs/RefundSpeed.md)
## Documentation For Authorization
All endpoints do not require authorization.
## Author
developers@cashfree.com
Raw data
{
"_id": null,
"home_page": "https://github.com/cashfree/cashfree-pg-sdk-python",
"name": "cashfree-pg-sdk-python",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "pg-sdk,cashfree-pg-sdk,cashfree,cashfree-python",
"author": "Cashfree Payments",
"author_email": "developers@cashfree.com",
"download_url": "https://files.pythonhosted.org/packages/58/3b/25a12e97bc3ea43bba7b791ddd7df4612473045787021915aca67a2ee558/cashfree_pg_sdk_python-2.0.1.tar.gz",
"platform": null,
"description": "# cashfree-pg-sdk-python\n\n- API version: 2022-09-01\n- Package version: 2.0.1\n\n---\n\n## Requirements.\n\nPython 2.7 and 3.4+\n\n## Discord Server Support\n\nOfficial Discord server is helpful to get support regarding any cashfree SDK , share any issues , raise tickets , give suggestions and request features for the SDK. Join the community of like-minded developers using the link provided below.\nLink :- https://discord.gg/HrCz9tW2sh \n\n## Installation & Usage\n\n### pip install\n\nYyou can install directly using:\n\n```sh\npip3 install git+https://github.com/cashfree/cashfree-pg-sdk-python.git\n```\n\n(you may need to run `pip3` with root permission: `sudo pip3 install git+https://github.com/cashfree/cashfree-pg-sdk-python.git`)\n\nThen import the package:\n\n```python\nimport cashfree_pg_sdk_python\n```\n\n### Setuptools\n\nInstall via [Setuptools](http://pypi.python.org/pypi/setuptools).\n\n```sh\npython3 setup.py install --user\n```\n\n(or `sudo python3 setup.py install` to install the package for all users)\n\nThen import the package:\n\n```python\nimport cashfree_pg_sdk_python\n```\n\n## Getting Started\n\nPlease follow the [installation procedure](#installation--usage) and then run the following:\nThe following part is the basic and common setup required to make any request to Casfhfree using the sdk.\n\n```python\n# Note : Please visit https://docs.cashfree.com/ for the complete documentation of the various terminologies used below, \n# if not familiar with.\n\n\nfrom __future__ import print_function\n\nimport time\nimport cashfree_pg_sdk_python\nfrom cashfree_pg_sdk_python.rest import ApiException\nfrom pprint import pprint\n\n# Defining the host is optional and defaults to https://sandbox.cashfree.com/pg\n# See configuration.py for a list of all supported configuration parameters.\nconfiguration = CFPython_sdk.Configuration(\n host = \"https://sandbox.cashfree.com/pg\"\n)\n# Enter a context with an instance of the API client\nwith CFPython_sdk.ApiClient(configuration) as api_client:\n# Create an instance of the API class\napi_instance = CFPython_sdk.OrdersApi(api_client)\nx_client_id = 'x_client_id_example' # str |\nx_client_secret = 'x_client_secret_example' # str |\nx_api_version = '2022-09-01' # str | (optional) (default to '2022-09-01')\nx_idempotency_replayed = False # bool | (optional) (default to False)\nx_idempotency_key = 'x_idempotency_key_example' # str | (optional)\nx_request_id = 'x_request_id_example' # str | (optional)\ncf_order_request = CFPython_sdk.CFOrderRequest() # CFOrderRequest | (optional)\n```\n\n### Making the config and headers for the subsequent CreateOrder / pay_order etc. requests\nThe variables declared and assigned in the previous (GETTING STARTED) step will be used here.\n```python\n cf_config_test = CFConfig(x_client_id,\n x_client_secret, x_api_version, CFenv.SANDBOX)\n # cfHeaders consists of two things mainly, 1) x-idempotecy-key and 2) x-request-id ; x-request-id can help the consumer of the # sdk to maintain meaningful logs on their side. This can be a unique/non-unique identifier that the consumer can use. It is\n # advisable that x-request-id be unique for each request so that the logging of the events of one request do not clash \n # with the other. Here, request is a CreateOrder/OrderPay etc. requests that the consumer makes to cashfree.\n cf_headers_test = CFHeaders(\n x_idempotency_key, x_request_id)\n```\n\n### Creating an Order \nThe following snippet provides an example on how to create an order with Cashfree\n```python\n # Making the create order request. For more extensive \n cf_order_request_test = cf_order_request.CFOrderRequest(\n order_amount=10.16,\n order_currency=\"INR\",\n customer_details=cf_customer_details.CFCustomerDetails(\n customer_id=\"testpythonSDKUSER\",\n customer_email=\"email@cf.com\",\n customer_phone=\"9999999999\"\n ), order_note=\"YOUR_NOTE\",\n order_tags={\n \"key\": \"key_example\",\n },\n order_meta=CFOrderMeta(\n payment_methods=\"nb,upi\",\n notify_url=\"https://webhook.merchantsite.com/691ffcf3-80db-4c10-b0d6-fbdc0be7b146\" # This is the webhook url.\n ),\n )\n # Create Order Snippet\n try:\n createOrderResult = CreateOrder(cf_config_test, cf_headers_test,\n cf_order_request_test)\n print(\"Creat order successful with the following details\")\n print(createOrderResult)\n except ApiException as e:\n print(\"Exception when calling create order: %s\\n\" % e)\n```\nNote: createOrderResult[0].order_id can be used to get the order id from the response.\n\n### Getting Order Details\nYou may wonder why is this function important -> Although you get the order details of the created order in the response of the CreateOrder as a part of the result above , but if you have to get the order details again after some time against the orderid then this function can be utilised.\nThe following snippet is an example on how to use the function.\n\n```python\n# Get Order Snippet\ntry:\n GetOrderResult = GetOrder(cfconfigtest, cfheaderstest,\n result[0].order_id)\n print(\"Get Order successful wiith the following details\")\n print(createOrderResult)\nexcept ApiException as e:\n print(\"Exception when calling create order: %s\\n\" % e)\n```\n### Other funtions\nPay Order call , getting transaction details and creating refund are all supported by this SDK, the same payload as in the normal API can be created and passed to the funtions and the SDK takes care of the network call thereafter.\ngatewayiinterface.py contains all the methods that can be used.\n\nFor any queries/help join the Official discord group mentioned in the beginning of this README doc.\n\n## Documentation For Models\n\n- [CFApp](docs/CFApp.md)\n- [CFAppPayment](docs/CFAppPayment.md)\n- [CFAuthorizationInPaymentsEntity](docs/CFAuthorizationInPaymentsEntity.md)\n- [CFAuthorizationRequest](docs/CFAuthorizationRequest.md)\n- [CFCard](docs/CFCard.md)\n- [CFCardEMI](docs/CFCardEMI.md)\n- [CFCardPayment](docs/CFCardPayment.md)\n- [CFCardlessEMI](docs/CFCardlessEMI.md)\n- [CFCardlessEMIPayment](docs/CFCardlessEMIPayment.md)\n- [CFCryptogram](docs/CFCryptogram.md)\n- [CFCustomerDetails](docs/CFCustomerDetails.md)\n- [CFEMIPayment](docs/CFEMIPayment.md)\n- [CFError](docs/CFError.md)\n- [CFFetchAllSavedInstruments](docs/CFFetchAllSavedInstruments.md)\n- [CFLink](docs/CFLink.md)\n- [CFLinkCancelledResponse](docs/CFLinkCancelledResponse.md)\n- [CFLinkCustomerDetailsEntity](docs/CFLinkCustomerDetailsEntity.md)\n- [CFLinkMetaEntity](docs/CFLinkMetaEntity.md)\n- [CFLinkNotifyEntity](docs/CFLinkNotifyEntity.md)\n- [CFLinkOrders](docs/CFLinkOrders.md)\n- [CFLinkRequest](docs/CFLinkRequest.md)\n- [CFNetbanking](docs/CFNetbanking.md)\n- [CFNetbankingPayment](docs/CFNetbankingPayment.md)\n- [CFOrder](docs/CFOrder.md)\n- [CFOrderMeta](docs/CFOrderMeta.md)\n- [CFOrderPayData](docs/CFOrderPayData.md)\n- [CFOrderPayRequest](docs/CFOrderPayRequest.md)\n- [CFOrderPayResponse](docs/CFOrderPayResponse.md)\n- [CFOrderRequest](docs/CFOrderRequest.md)\n- [CFPaylater](docs/CFPaylater.md)\n- [CFPaylaterPayment](docs/CFPaylaterPayment.md)\n- [CFPaymentMethod](docs/CFPaymentMethod.md)\n- [CFPaymentURLObject](docs/CFPaymentURLObject.md)\n- [CFPaymentsEntity](docs/CFPaymentsEntity.md)\n- [CFPaymentsEntityApp](docs/CFPaymentsEntityApp.md)\n- [CFPaymentsEntityAppPayment](docs/CFPaymentsEntityAppPayment.md)\n- [CFPaymentsEntityCard](docs/CFPaymentsEntityCard.md)\n- [CFPaymentsEntityCardPayment](docs/CFPaymentsEntityCardPayment.md)\n- [CFPaymentsEntityCardlessEMI](docs/CFPaymentsEntityCardlessEMI.md)\n- [CFPaymentsEntityCardlessEMIPayment](docs/CFPaymentsEntityCardlessEMIPayment.md)\n- [CFPaymentsEntityMethod](docs/CFPaymentsEntityMethod.md)\n- [CFPaymentsEntityNetbankingPayment](docs/CFPaymentsEntityNetbankingPayment.md)\n- [CFPaymentsEntityPaylater](docs/CFPaymentsEntityPaylater.md)\n- [CFPaymentsEntityPaylaterPayment](docs/CFPaymentsEntityPaylaterPayment.md)\n- [CFPaymentsEntityUPI](docs/CFPaymentsEntityUPI.md)\n- [CFPaymentsEntityUPIPayment](docs/CFPaymentsEntityUPIPayment.md)\n- [CFRefund](docs/CFRefund.md)\n- [CFRefundRequest](docs/CFRefundRequest.md)\n- [CFRefundURLObject](docs/CFRefundURLObject.md)\n- [CFSavedInstrumentMeta](docs/CFSavedInstrumentMeta.md)\n- [CFSettlementURLObject](docs/CFSettlementURLObject.md)\n- [CFSettlementsEntity](docs/CFSettlementsEntity.md)\n- [CFUPI](docs/CFUPI.md)\n- [CFUPIAuthorizeDetails](docs/CFUPIAuthorizeDetails.md)\n- [CFUPIPayment](docs/CFUPIPayment.md)\n- [CFVendorSplit](docs/CFVendorSplit.md)\n- [LinkCancelledError](docs/LinkCancelledError.md)\n- [RefundSpeed](docs/RefundSpeed.md)\n\n## Documentation For Authorization\n\nAll endpoints do not require authorization.\n\n## Author\n\ndevelopers@cashfree.com\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Casfree Payments Payment Gateway Python SDK",
"version": "2.0.1",
"project_urls": {
"Homepage": "https://github.com/cashfree/cashfree-pg-sdk-python"
},
"split_keywords": [
"pg-sdk",
"cashfree-pg-sdk",
"cashfree",
"cashfree-python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "4244768d64c9cb3843b476e9e2fcb3d813241c3937245579f71e9d4b7e5c67fc",
"md5": "e5b5d0896d74208bd8e76dc0b926a3bd",
"sha256": "2964310824f446b2af70222a078f958484020ed503474570bd2e8f5985442bd7"
},
"downloads": -1,
"filename": "cashfree_pg_sdk_python-2.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e5b5d0896d74208bd8e76dc0b926a3bd",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 137065,
"upload_time": "2023-05-30T09:23:48",
"upload_time_iso_8601": "2023-05-30T09:23:48.000671Z",
"url": "https://files.pythonhosted.org/packages/42/44/768d64c9cb3843b476e9e2fcb3d813241c3937245579f71e9d4b7e5c67fc/cashfree_pg_sdk_python-2.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "583b25a12e97bc3ea43bba7b791ddd7df4612473045787021915aca67a2ee558",
"md5": "0ad8c50c3ad488ac4fd3d891caed3f47",
"sha256": "88c5a988d9faaf441aacf002c4c5bb538a04208f2c27320617cae6d23a6d926f"
},
"downloads": -1,
"filename": "cashfree_pg_sdk_python-2.0.1.tar.gz",
"has_sig": false,
"md5_digest": "0ad8c50c3ad488ac4fd3d891caed3f47",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 55073,
"upload_time": "2023-05-30T09:23:51",
"upload_time_iso_8601": "2023-05-30T09:23:51.826327Z",
"url": "https://files.pythonhosted.org/packages/58/3b/25a12e97bc3ea43bba7b791ddd7df4612473045787021915aca67a2ee558/cashfree_pg_sdk_python-2.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-30 09:23:51",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "cashfree",
"github_project": "cashfree-pg-sdk-python",
"github_not_found": true,
"lcname": "cashfree-pg-sdk-python"
}