项目作者: openpesa

项目描述 :
Python Pesa SDK
高级语言: Python
项目地址: git://github.com/openpesa/pypesa.git
创建时间: 2020-10-11T13:47:27Z
项目社区:https://github.com/openpesa/pypesa

开源协议:MIT License

下载


PyPesa

Python Pesa SDK

Installation

This package is available in Python Package Index and can be installed using pip

  1. pip install pypesa

The package comprise both original open API codes and refactored codes.

To use original open API code import open_api module

  1. from pypesa.open_api import APIContext, APIMethodType, APIRequest

To use refactored code import MPESA from vodacom module.

  1. from pypesa.vodacom import MPESA

Features

  • Customer to Business (C2B)
  • Business to Customer (B2C)
  • Business to Business (B2B)
  • Payment Reversal
  • Transaction Status
  • Direct debit creation and Payment

Pre-requisites

The following are required and are obtained from Vodacom Open Api portal

  • Api Key
  • Public Key

See more in documentation.

Examples

Customer to Business payment via vodacom m-pesa

  1. # vodacom M-PESA
  2. from pypesa.vodacom import MPESA
  3. api_key = '<your-api-key>'
  4. public_key = '<open-api-public-key>'
  5. m_pesa = MPESA(api_key=api_key, public_key=public_key)
  6. # Customer to Business payment
  7. parameters = {
  8. 'input_Amount': '1000', # amount to be charged
  9. 'input_Country': 'TZN',
  10. 'input_Currency': 'TZS',
  11. 'input_CustomerMSISDN': '000000000001',
  12. 'input_ServiceProviderCode': '000000',
  13. 'input_ThirdPartyConversationID': 'c9e794e10c63479992a8b08703abeea36',
  14. 'input_TransactionReference': 'T23434ZE3',
  15. 'input_PurchasedItemsDesc': 'Shoes',
  16. }
  17. response = m_pesa.customer2business(parameters)

Check more examples of methods and responses in docs

Credits

License

Code released under MIT LICENSE