Django MBills library wraps around python-mbills in order to provide Django functionality.
The library is pretty lightweight only containing one model and a few helper functions. APIs should be implemented by the main app as most of you use different frameworks and workflows.
$ pip install django-mbills
-
Add mbills to installed apps:
INSTALLED_APPS = [ ...
'mbills', ...
]
-
Run migrations
$ python manage.py migrate
-
Configure settings
There are 4 settings you have to configure before you can use the app.
In your settings.py
set the following variables:
- MBILLS_RSA_PUBLIC_KEY - public RSA key of the MBills API.
- MBILLS_API_KEY - your API key
- MBILLS_SECRET_KEY - your secret key
- MBILLS_API_ENDPOINT - MBills server endpoint. Defaults to their test server demo3.halcome.com/MBillsWS
- Implement your API
In your API calls or Views you can issue calls to:
- Generate a new transaction
tx = generate_new_transaction(amount, purpose, payment_reference=None, order_id=None, channel_id=None, capture=True)
- Update transaction status
tx = update_transaction_status(tx)
- Handle webhook received data (might raise SignatureValidationException and DoesNotExist)
tx = handle_webhook(json_data)
For more detailed documentation check the project source.
Boris Savic
- Twitter: @zitko
- Email: boris70@gmail.com