Logo Lanfrica

paymentsds/mpesa-python-sdk

Domaine:

digital infrastructure

Type de record:

software
Créateur:
pay
Hôte:
A Python library aiming to help developers integrating their products with M-Pesa Platform # PYTHON M-Pesa SDK This is a library willing to help you to integrate the Vodacom M-Pesa operations to your application. ### Features Using this library, you can implement the following operations: - Receive money from a mobile account to a business account (C2B) - Send money from a business account to a mobile account (B2C) - Send money from a business account to another business account (B2B) - Revert any of the transactions above mentioned ## Requirements - Valid credentials obtained from the Mpesa Developer portal - Port 18352 open on your server (usually open on local env) - Python 3.5+ - PIP ## Installation ### Using PIP ```bash $ pip install paymentsds-mpesa $ cd paymentsds-mpesa $ pip install -r requirements.txt ``` ## Usage Using this SDK is very simple and fast, let us see some examples: #### C2B Transaction (Receive money from mobile account) ```python from paymentsds.mpesa import Client client = Client( api_key=' ', # API Key public_key=' ', # Public Key service_provider_code=' ' # input_ServiceProviderCode ) try: payment_data = { 'from': '841234567', # input_CustomerMSISDN 'reference': '11114', # input_ThirdPartyReference 'transaction': 'T12344CC', # input_TransactionReference 'amount': '10' # input_Amount } result = client.receive(payment_data) except: print('Operation failed') ``` #### B2C Transaction (Sending money to mobile account) ```python from paymentsds.mpesa import Client client = Client( api_key=' ', # API Key public_key=' ', # Public Key service_provider_code=' ' # input_ServiceProviderCode ) try: payment_data = { 'to': '841234567', # input_CustomerMSISDN 'reference': '11114', # input_ThirdPartyReference 'transaction': 'T12344CC', # input_TransactionReference 'amount': '10' # input_Amount } result = client.send(payment_data) except: print('Operation failed') ``` #### B2B Transaction (Sending money to …

Languages

Tags

Licenses