martinmogusu / django-daraja

A python django library for interacting with the MPESA Daraja API
MIT License
69 stars 75 forks source link

Default amount setting for the 'lipa na mpesa' #1

Closed Brightmuk closed 4 years ago

Brightmuk commented 4 years ago

django_daraja/mpesa.core In the stk_push function the amount variable is by default set to 1 Here is the rendered json data data = { 'BusinessShortCode': business_short_code, 'Password': password, 'Timestamp': timestamp, 'TransactionType': transaction_type, 'Amount': '1', 'PartyA': party_a, 'PartyB': party_b, 'PhoneNumber': phone_number, 'CallBackURL': callback_url, 'AccountReference': account_reference, 'TransactionDesc': transaction_desc }

labohkip81 commented 4 years ago

Encountered the same. Did you manage to change? or get a work around?

Brightmuk commented 4 years ago

I had to use the library as a django app. I simply moved the lib from my packages in the virtual environment then registered it as an app. Finally all you have to do is edit the core.py file at def stk_push function by changing amount to as follows: data = { 'BusinessShortCode': business_short_code, 'Password': password, 'Timestamp': timestamp, 'TransactionType': transaction_type, 'Amount': str(amount), 'PartyA': party_a, 'PartyB': party_b, 'PhoneNumber': phone_number, 'CallBackURL': callback_url, 'AccountReference': account_reference, 'TransactionDesc': transaction_desc } So instead of importing the library you just import the app.

labohkip81 commented 4 years ago

Thanks a lot mate. Cheers🍻

martinmogusu commented 4 years ago

Sorry for the delay, I've resolved the default amount tag issue. Sorted in version 1.1.2