This package provides bindings for the Lipisha Payments API (https://developer.lipisha.com/)
Project description
This package provides bindings for the Lipisha Payments API (https://developer.lipisha.com/)
Free software: MIT License
Documentation: https://lipisha-python-sdk.readthedocs.org.
Features
Request Money
Send Money
Send SMS
Get Float
Get Balance
Acknowledge Transaction
Examples
IPN callback examples are in the examples directory:
https://github.com/lipisha/lipisha-python-sdk/tree/master/examples
Quick start
>>> from lipisha import Lipisha
>>> api_key = "YOUR API KEY"
>>> api_signature = "YOUR API SIGNATURE"
>>> lipisha = Lipisha(api_key, api_signature)
>>> lipisha.api_base_url
'https://api.lypa.io/v2/api'
>>> lipisha = Lipisha(api_key, api_signature, api_environment='test')
>>> lipisha.api_base_url
'https://developer.lipisha.com/index.php/v2/api/'
>>> lipisha = Lipisha(api_key, api_signature, api_environment='live')
>>> lipisha.api_base_url
'https://api.lypa.io/v2/api'
>>> lipisha.request_money(account_number="09876", mobile_number="07XXYYYZZZ", amount=50, reference="INV00001")
{u'content': {u'transaction': u'ZXYA123D56',
u'method': u'Paybill (M-Pesa)',
u'account_number': u'09876',
u'mobile_number': u'07XXYYYZZZ',
u'reference': u'INV00001'},
u'status': {u'status': u'SUCCESS',
u'status_code': u'0000',
u'status_description': u'Payment Requested'}}
>>> lipisha.send_money(account_number="098777", mobile_number="07XXYYYZZZ", amount=50)
{u'content': {u'amount': u'50',
u'customer_name': u'',
u'mobile_number': u'07XXYYYZZZ',
u'reference': u'SP01ZXA45'},
u'status': {u'status': u'SUCCESS',
u'status_code': u'0000',
u'status_description': u'Payout Scheduled'}}
>>> lipisha.send_airtime(account_number="03160", mobile_number="07XXYYYZZZ", amount="50", network="SAF")
{u'content': {u'amount': u'50',
u'mobile_number': u'07XXYYYZZZ',
u'reference': u'MF0QKVD9W'},
u'status': {u'status': u'SUCCESS',
u'status_code': u'0000',
u'status_description': u'Airtime purchased successfully'}}
>>> lipisha.get_balance()
{u'content': {u'balance': u'246.2500', u'currency': u'KES'},
u'status': {u'status': u'SUCCESS',
u'status_code': 0,
u'status_description': u'Balance Found'}}
>>> lipisha.get_float(account_number="098000")
{u'content': {u'account_number': u'098000',
u'currency': u'KES',
u'float': u'0.00'},
u'status': {u'status': u'SUCCESS',
u'status_code': 0,
u'status_description': u'Float Found'}}
>>> lipisha.confirm_transaction(transaction='YYYE9WWWW0')
{u'content': {u'transaction': u'YYYE9WWWW0',
u'transaction_account_name': u'Primary',
u'transaction_account_number': u'098777',
u'transaction_amount': u'200.0000',
u'transaction_date': u'2015-08-14 16:51:00',
u'transaction_email': u'',
u'transaction_method': u'Paybill (M-Pesa)',
u'transaction_mobile_number': u'2547XXYYYZZZ',
u'transaction_name': u'Test User Names',
u'transaction_reference': u'99',
u'transaction_status': u'Completed',
u'transaction_type': u'Payment'},
u'status': {u'status': u'SUCCESS',
u'status_code': 0,
u'status_description': u'Transaction Found'}}
>>> lipisha.get_transactions()
{u'content': [{u'code': None,
u'transaction': u'JJ99X9TC0',
u'transaction_account_name': u'Primary',
u'transaction_account_number': u'098777',
u'transaction_amount': u'50.0000',
u'transaction_date': u'2015-08-06 10:39:00',
u'transaction_email': u'',
u'transaction_method': u'Paybill (M-Pesa)',
u'transaction_mobile_number': u'2547XXYYYZZZ',
u'transaction_name': u'Test User Names',
u'transaction_reference': u'',
u'transaction_reversal_status': u'None',
u'transaction_reversal_status_id': u'1',
u'transaction_status': u'Completed',
u'transaction_type': u'Payment'},
{u'code': None,
u'transaction': u'JJ99X9TC0',
u'transaction_account_name': u'Primary',
u'transaction_account_number': u'098777',
u'transaction_amount': u'-0.7500',
u'transaction_date': u'2015-08-06 10:39:00',
u'transaction_email': u'',
u'transaction_method': u'Paybill (M-Pesa)',
u'transaction_mobile_number': u'2547XXYYYZZZ',
u'transaction_name': u'Test User Names',
u'transaction_reference': u'',
u'transaction_reversal_status': u'None',
u'transaction_reversal_status_id': u'1',
u'transaction_status': u'Completed',
u'transaction_type': u'Fee'},
{u'code': None,
u'transaction': u'YYYE9WWWW0',
u'transaction_account_name': u'Primary',
u'transaction_account_number': u'098777',
u'transaction_amount': u'200.0000',
u'transaction_date': u'2015-08-14 16:51:00',
u'transaction_email': u'',
u'transaction_method': u'Paybill (M-Pesa)',
u'transaction_mobile_number': u'2547XXYYYZZZ',
u'transaction_name': u'Test User Names',
u'transaction_reference': u'99',
u'transaction_reversal_status': u'None',
u'transaction_reversal_status_id': u'1',
u'transaction_status': u'Completed',
u'transaction_type': u'Payment'},
{u'code': None,
u'transaction': u'YYYE9WWWW0',
u'transaction_account_name': u'Primary',
u'transaction_account_number': u'098777',
u'transaction_amount': u'-3.0000',
u'transaction_date': u'2015-08-14 16:51:00',
u'transaction_email': u'',
u'transaction_method': u'Paybill (M-Pesa)',
u'transaction_mobile_number': u'2547XXYYYZZZ',
u'transaction_name': u'Test User Names',
u'transaction_reference': u'99',
u'transaction_reversal_status': u'None',
u'transaction_reversal_status_id': u'1',
u'transaction_status': u'Completed',
u'transaction_type': u'Fee'}],
u'status': {u'status': u'SUCCESS',
u'status_code': 0,
u'status_description': u'Transactions Found'}}
>>> lipisha.get_transactions(transaction="JJ99X9TC0")
{u'content': [{u'code': None,
u'transaction': u'JJ99X9TC0',
u'transaction_account_name': u'Primary',
u'transaction_account_number': u'098777',
u'transaction_amount': u'50.0000',
u'transaction_date': u'2015-08-06 10:39:00',
u'transaction_email': u'',
u'transaction_method': u'Paybill (M-Pesa)',
u'transaction_mobile_number': u'2547XXYYYZZZ',
u'transaction_name': u'Test User Names',
u'transaction_reference': u'',
u'transaction_reversal_status': u'None',
u'transaction_reversal_status_id': u'1',
u'transaction_status': u'Completed',
u'transaction_type': u'Payment'},
{u'code': None,
u'transaction': u'JJ99X9TC0',
u'transaction_account_name': u'Primary',
u'transaction_account_number': u'098777',
u'transaction_amount': u'-0.7500',
u'transaction_date': u'2015-08-06 10:39:00',
u'transaction_email': u'',
u'transaction_method': u'Paybill (M-Pesa)',
u'transaction_mobile_number': u'2547XXYYYZZZ',
u'transaction_name': u'Test User Names',
u'transaction_reference': u'',
u'transaction_reversal_status': u'None',
u'transaction_reversal_status_id': u'1',
u'transaction_status': u'Completed',
u'transaction_type': u'Fee'}],
u'status': {u'status': u'SUCCESS',
u'status_code': 0,
u'status_description': u'Transactions Found'}}
>>> lipisha.get_customers()
{u'content': [{u'customer_average': u'125.00000000',
u'customer_email': u'',
u'customer_first_payment_date': u'2015-08-06 10:39:00',
u'customer_last_payment_date': u'2015-08-14 16:51:00',
u'customer_mobile_number': u'2547XXYYYZZZ',
u'customer_name': u'Test User Names',
u'customer_payments': u'2',
u'customer_total': u'250.0000'}],
u'status': {u'status': u'SUCCESS',
u'status_code': 0,
u'status_description': u'Customers Found'}}
>>> lipisha.get_customers(customer_mobile_number="2547XXYYYZZZ")
{u'content': [{u'customer_average': u'125.00000000',
u'customer_email': u'',
u'customer_first_payment_date': u'2015-08-06 10:39:00',
u'customer_last_payment_date': u'2015-08-14 16:51:00',
u'customer_mobile_number': u'2547XXYYYZZZ',
u'customer_name': u'Test User Names',
u'customer_payments': u'2',
u'customer_total': u'250.0000'}],
u'status': {u'status': u'SUCCESS',
u'status_code': 0,
u'status_description': u'Customers Found'}}
>>> lipisha.authorize_card_transaction(account_number="098000",
card_number="4242424242424242",
address1="PO BOX 11111 99999",
address2="",
expiry="082020",
name="Lipsha Test Account",
country="KENYA",
state="NAIROBI",
zip="00200",
security_code="999",
amount=100,
currency='KES')
{u'content': {u'transaction_index': u'{CDD55BEB-F74A-4A8B-8D5C-2FC77FF14E7B}',
u'transaction_reference': 111111},
u'status': {u'status': u'SUCCESS',
u'status_code': u'0000',
u'status_description': u'Transaction Authorized Successfully'}}
>>> lipisha.complete_card_transaction(transaction_reference=11111, transaction_index="{CDD55BEB-F74A-4A8B-8D5C-2FC77FF14E7B}")
{u'content': {u'transaction_index': u'{CDD55BEB-F74A-4A8B-8D5C-2FC77FF14E7B}',
u'transaction_reference': u'11111'},
u'status': {u'status': u'SUCCESS',
u'status_code': u'0000',
u'status_description': u'Transaction Completed Successfully'}}
>>> lipisha.reverse_card_transaction(transaction_reference=11111, transaction_index="{CDD55BEB-F74A-4A8B-8D5C-2FC77FF14E7B}")
{u'content': None, u'status': None}
>>> lipisha.create_payment_account(transaction_account_type=1,
transaction_account_name="MPESA Payments",
transaction_account_manager="test_account")
{u'content': {u'transaction_account_manager': u'test_account',
u'transaction_account_name': u'MPESA Payments',
u'transaction_account_number': u'09999',
u'transaction_account_type': u'1'},
u'status': {u'status': u'SUCCESS',
u'status_code': 0,
u'status_description': u'Account Created'}}
>>> lipisha.create_withdrawal_account(transaction_account_type="1",
transaction_account_name="Settlement Bank A/C",
transaction_account_number="0100555555555",
transaction_account_bank_name="AZY Bank",
transaction_account_bank_branch="HQ",
transaction_account_bank_address="PO BOX 900032 - 99999 Nairobi, Kenya",
transaction_account_swift_code="ABCXYXXXX",
transaction_account_manager="test_account")
{u'content': {u'transaction_account_bank_address': u'PO BOX 900032 - 99999 Nairobi, Kenya',
u'transaction_account_bank_branch': u'HQ',
u'transaction_account_bank_name': u'AZY Bank',
u'transaction_account_manager': u'test_account',
u'transaction_account_name': u'Settlement Bank A/C',
u'transaction_account_number': u'0100555555555',
u'transaction_account_swift_code': u'ABCXYXXXX',
u'transaction_account_type': u'1'},
u'status': {u'status': u'SUCCESS',
u'status_code': 0,
u'status_description': u'Account Created'}}
Installation
At the command line:
$ pip install lipisha Or using easy_install $ easy_install lipisha Manual installation $ git clone https://github.com/lipisha/lipisha-python-sdk.git $ cd lipisha-python-sdk $ python setup.py install Or, if you have virtualenvwrapper installed:: $ mkvirtualenv lipisha $ pip install lipisha
See documentation for detailed API. Refer to Lipisha API for parameters required for each method.
History
0.3.0 (2020-11-03)
Reflect all round updates on API, License and Docs.
0.2.5 (2020-11-02)
Updated API Base URLs
0.2.4 (2016-09-15)
Added request_money API (See Request Money API <http://developer.lipisha.com/index.php/app/launch/api_request_money>)
0.2.3 (2016-04-20)
Encoding bugfix (See Issue 1 <https://github.com/lipisha/lipisha-python-sdk/issues/1>).
0.2.1 /0.2.2 (2015-08-14)
Documentation updates
PYPI releases
0.2.0 (2015-08-14)
Bytes handling fixes (Python3.3/Python3.4)
Sandbox testing
- Implemented new api endpoints
Card authorization and settlement
Transactions listing
Customers listing
Settlement accounts setup
Transaction acccounts setup
Improved documentation
0.1.0 (2015-08-12)
First release on PyPI.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file lipisha-0.3.0.tar.gz
.
File metadata
- Download URL: lipisha-0.3.0.tar.gz
- Upload date:
- Size: 22.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39c5e6a5ea742dd642b17534ed41837fe600cd9e71c07096c4538256df6a56bf |
|
MD5 | b667886d5a07b1a24ff526be9e4ac1d6 |
|
BLAKE2b-256 | d1fd516011c8d9204b4947f5815ca937d6475f493ca1780cae4f4e0d444964d5 |
File details
Details for the file lipisha-0.3.0-py2.py3-none-any.whl
.
File metadata
- Download URL: lipisha-0.3.0-py2.py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2984bfd214d006b79eb65f968db469c3be8dc17af467a02735ebcca1808aa013 |
|
MD5 | 9cc9fdbf372604797d1c46f1a7197a96 |
|
BLAKE2b-256 | 014d4759b07b121a13d6255aeb0dc6e991255dd8d533dc2c8a3d449916a7f077 |