Package: cashfree-sdk
Cashfree SDK's are released in Beta. This is work in progress and we are continuously working on improving various aspects of it. It is released as learning aid and example kit for the API integrators. This is not recommended by Cashfree for direct use in production code. Please report any bugs to Cashfree attechsupport@cashfree.com.cashfree-sdk-pythonThe official Cashfree SDK for Python3,Get started quickly using Cashfree with the Cashfree SDK for python. The SDK helps take the complexity out of coding by providing Python objects for Cashfree services including Payouts, Payment Gateway, Marketplace and Autocollect. The single, downloadable package includes the Cashfree Python Library and documentation.Please refer to theCashfree Docsfor the complete API reference.InstallingIn Django or Flask Application for Python 3.5+The preferred way to install the Cashfree SDK for Python is to use thepippackage manager for pip. Simply type the following into a terminal window:pip3installcashfree-sdkGetting StartedPre-requisitesACashfree Merchant AccountAPI keys for different products. You can generate them from your DashboardIP Whitelisting and dynamic IPsYour IP has to be whitelisted to hit Cashfree's server. Or if you have a dynamic IP please pass in the public key parameter during the init method as shown below. For more information please gohere.UsagePayoutsThe package needs to be configured with your account's secret key which is available in your Cashfree Dashboard.
Init the package with your credentials and add the below code in your config.py of your package.In case of static IP (Your IP is whitelisted)fromcashfree_sdk.payoutsimportPayouts//InitializeCashfreePayoutPayouts.init("<client_id>","<client_secret>","PROD")In case of dynamic IP you will need a public key to generate a signature(which will be done by sdk itself)fromcashfree_sdk.payoutsimportPayouts//InitializeCashfreePayoutPayouts.init("<client_id>","<client_secret>","PROD",public_key_path='/User/Cashfree/file_path.pem')//ORPayouts.init("<client_id>","<client_secret>","PROD",public_key=b'public key')OptionDefaultDescriptionenvTESTEnvironment to be initialized. Can be set toTESTorPRODclient_id``client_idwhich can be generated on cashfree dashboard.client_secret``client_secretwhich can be found alongside generatedclient_id.public_key_path``public_key_pathspecify the path to your .pem public key file `.public_key``public_keyPass your Public Key to this parameter as an alternative topublic_key_path.Payout Library DocsWebHook VerificationTo verify the webhook received from Cashfree for different events and accept the webhook only when it returnsTrue.UsagePass the webhook received along with the payload type.OptionOptionspayload_typeJSONforapplication/json,FORMforapplication/x-www-form-urlencodedfromcashfree_sdkimportverificationwebhook_data='{"cashgramId": "5b8283182e0711eaa4c531df6a4f439b-28", "event": "CASHGRAM_EXPIRED", "eventTime": "2020-01-03 15:01:06", "reason": "OTP_ATTEMPTS_EXCEEDED", "signature": "TBpM+4nr1DsWsov7QiHSTfRJP4Z9BD8XrDgEhBlf9ss="}'verification.verify_webhook(webhook_data,'JSON')Using Python requestsEvery method returns a python request object which can be used:fromcashfree_sdk.payouts.beneficiaryimportBeneficiarybene_add=Beneficiary.add("kit_test6","ankur","ankur@cashfree.com","9999999999","aakjakjakja")- All Optional Arguments Should Be Passed As An Keyword (Named) ArgumentsReadmefor the exception thrown for invalid operation and how to handle the exceptions.For more information about the APIs go toPayouts.Complete list ofAPIs.TODOPGMarket PlaceAutocollect