Skip to content

Commit 9b2d959

Browse files
authored
Update URLs in documentation (#10)
1 parent 1159a26 commit 9b2d959

File tree

5 files changed

+21
-32
lines changed

5 files changed

+21
-32
lines changed

README.md

+4-8
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ An example, to send an STK push prompt to customer phone, then display response
3737
amount = 1
3838
account_reference = 'reference'
3939
transaction_desc = 'Description'
40-
callback_url = request.build_absolute_uri(reverse('mpesa_stk_push_callback'))
40+
callback_url = 'https://api.darajambili.com/express-payment'
4141
response = cl.stk_push(phone_number, amount, account_reference, transaction_desc, callback_url)
4242
return HttpResponse(response)
4343
```
4444

45-
On your browser, you will receive a message `Success. Request accepted for processing` on success of the STK push. You will also receive a notification on the callback endpoint (In this case the URL with the name `mpesa_stk_push_callback`), having the results of the STK push.
45+
On your browser, you will receive a message `Success. Request accepted for processing` on success of the STK push, and on the phone number specified you will receive an MPESA PIN prompt. Once the transaction is complete, you will receive a notification on the callback URL you provided. If you used the exact callback URL in the example above (i.e. https://api.darajambili.com/express-payment), you can head over to https://darajambili.com to view the notification received
4646

4747
### B2C Payment
4848

@@ -57,16 +57,12 @@ An example, to perform a BusinessPayment B2C (Business to Customer) transaction
5757
amount = 1
5858
transaction_desc = 'Business Payment Description'
5959
occassion = 'Test business payment occassion'
60-
callback_url = request.build_absolute_uri(reverse('mpesa_business_payment_callback'))
60+
callback_url = 'https://api.darajambili.com/b2c/result'
6161
response = cl.business_payment(phone_number, amount, transaction_desc, callback_url, occassion)
6262
return HttpResponse(response)
6363

6464
```
6565

66-
On your browser, you will receive a message `Accept the service request successfully.` on success of the transaction. You will also receive a notification on the callback endpoint (In this case the URL with the name `mpesa_business_payment_callback`), having the results of the Business Payment Transaction.
67-
68-
## Note
69-
70-
You need a callback URL connected to the internet to receive the asynchronous result. In case you don't have one you can head over to https://darajambili.com and grab a callback URL to test the result.
66+
On your browser, you will receive a message `Accept the service request successfully.` on success of the transaction. Once the transaction is complete, you will receive a notification on the callback URL you provided. If you used the exact callback URL in the example above (i.e. https://api.darajambili.com/b2c/result), you can head over to https://darajambili.com to view the notification received
7167

7268
The full documentation of all supported API's can be found at https://django-daraja.readthedocs.io

docs/pages/apis/b2c_payment.rst

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Business Payment
2525
amount = 1
2626
transaction_desc = 'Description'
2727
occassion = 'Occassion'
28-
callback_url = request.build_absolute_uri(reverse('mpesa_business_payment_callback'))
28+
callback_url = 'https://api.darajambili.com/b2c/result'
2929
response = self.cl.business_payment(phone_number, amount, transaction_desc, self.callback_url, occassion)
3030
3131
Salary Payment
@@ -39,7 +39,7 @@ Salary Payment
3939
amount = 1
4040
transaction_desc = 'Description'
4141
occassion = 'Occassion'
42-
callback_url = request.build_absolute_uri(reverse('mpesa_salary_payment_callback'))
42+
callback_url = 'https://api.darajambili.com/b2c/result'
4343
response = self.cl.business_payment(phone_number, amount, transaction_desc, self.callback_url, occassion)
4444
4545
Promotion Payment
@@ -53,7 +53,7 @@ Promotion Payment
5353
amount = 1
5454
transaction_desc = 'Description'
5555
occassion = 'Occassion'
56-
callback_url = request.build_absolute_uri(reverse('mpesa_promotion_payment_callback'))
56+
callback_url = 'https://api.darajambili.com/b2c/result'
5757
response = self.cl.promotion_payment(phone_number, amount, transaction_desc, self.callback_url, occassion)
5858
5959
@@ -62,4 +62,4 @@ This will assign the ``response`` variable with an ``MpesaResponse`` object cont
6262
.. note::
6363
- Test credentials to use for this scenario can be found at the developer portal (https://developer.safaricom.co.ke/test_credentials)
6464
- Use `shortcode 1` as the shortcode, and the test MSISDN as the B2C phone number
65-
- This example will work if your site is already hosted, since the callback URL needs to be accessible via internet. For local testing purposes, you can use an endpoint hosted outside your site to check the notification received on the callback URL. There is a test listener hosted at https://darajambili.com, which you can use to view logs of notifications received. You can head over there to pick a callback URL to use for B2C Payments.
65+
- Once the transaction is complete, you will receive a notification on the callback URL you provided. If you used the exact callback URL in the example above (i.e. https://api.darajambili.com/b2c/result), you can head over to https://darajambili.com to view the notification received

docs/pages/apis/stk_push.rst

+3-4
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,11 @@ Example:
1515
amount = 1
1616
account_reference = 'reference'
1717
transaction_desc = 'Description'
18-
callback_url = request.build_absolute_uri(reverse('mpesa_stk_push_callback'))
18+
callback_url = 'https://api.darajambili.com/express-payment'
1919
response = cl.stk_push(phone_number, amount, account_reference, transaction_desc, callback_url)
2020
2121
This will assign the ``response`` variable with an ``MpesaResponse`` object containing the response returned from the STK Push API call.
2222

2323
.. note::
24-
- Use a Safaricom number that you have access to for the ``phone_number`` parameter, so as to be able to receive the prompt on your phone.
25-
- You will need to define a url with the name ``mpesa_stk_push_callback``, and this is where MPESA will send the results of the STK push once the customer enters the PIN or cancels the transaction, or in case the prompt times out.
26-
- This example will work if your site is already hosted, since the callback URL needs to be accessible via internet. For local testing purposes, you can use an endpoint hosted outside your site to check the notification received on the callback URL. There is a test listener hosted at https://darajambili.com, which you can use to view logs of notifications received. You can head over there to pick a callback URL to use for STK push.
24+
- Use a Safaricom number that you have access to for the ``phone_number`` parameter, so as to be able to receive the M-PESA prompt on your phone.
25+
- Once you have entered the PIN, you will receive a notification on the callback URL you provided. If you used the exact callback URL in the example above (i.e. https://api.darajambili.com/express-payment), you can head over to https://darajambili.com to view the notification received.

docs/pages/introduction.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ An example, to send an STK push prompt to customer phone, then display response
3030
amount = 1
3131
account_reference = 'reference'
3232
transaction_desc = 'Description'
33-
callback_url = request.build_absolute_uri(reverse('mpesa_stk_push_callback'))
33+
callback_url = 'https://api.darajambili.com/express-payment'
3434
response = cl.stk_push(phone_number, amount, account_reference, transaction_desc, callback_url)
3535
return HttpResponse(response)
3636
37-
On your browser, you will receive the API response message. You will also receive a notification on the callback endpoint (In this case the URL with the name ``mpesa_stk_push_callback``), having the results of the STK push.
37+
On your browser, you will receive the API response message and on the phone number specified you will receive an MPESA PIN prompt. Once you have entered the PIN, you will receive a notification on the callback URL you provided. If you used the exact callback URL in the example above (i.e. https://api.darajambili.com/express-payment), you can head over to https://darajambili.com to view the notification received.

docs/pages/quick_start.rst

+8-14
Original file line numberDiff line numberDiff line change
@@ -137,25 +137,24 @@ Python 2:
137137
:caption: my_app/urls.py
138138
:name: my_app_urls_python_2
139139
140-
from django.urls import re_path as url, include
140+
from django.urls import re_path as url
141+
141142
from . import views
142143
143144
urlpatterns = [
144-
url(r'^$', views.index, name='index'),
145-
url(r'^daraja/stk-push$', views.stk_push_callback, name='mpesa_stk_push_callback'),
145+
url(r'^$', views.index, name='index')
146146
]
147147
148148
Python 3:
149149
.. code-block:: python
150150
:caption: my_app/urls.py
151151
:name: my_app_urls_python_3
152152
153-
from django.urls import path, include
153+
from django.urls import path
154154
from . import views
155155
156156
urlpatterns = [
157-
path('', views.index, name='index'),
158-
path('daraja/stk-push', views.stk_push_callback, name='mpesa_stk_push_callback'),
157+
path('', views.index, name='index')
159158
]
160159
161160
7. Create a view
@@ -178,18 +177,13 @@ In ``my_app/views.py`` Create a test index view
178177
amount = 1
179178
account_reference = 'reference'
180179
transaction_desc = 'Description'
181-
callback_url = request.build_absolute_uri(reverse('mpesa_stk_push_callback'))
180+
callback_url = 'https://api.darajambili.com/express-payment'
182181
response = cl.stk_push(phone_number, amount, account_reference, transaction_desc, callback_url)
183182
return HttpResponse(response)
184183
185-
def stk_push_callback(request):
186-
data = request.body
187-
# You can do whatever you want with the notification received from MPESA here.
188-
189184
.. note::
190-
- Use a Safaricom number that you have access to for the ``phone_number`` parameter, so as to be able to receive the prompt on your phone.
191-
- You will need to define a url with the name ``mpesa_stk_push_callback``, and this is where MPESA will send the results of the STK push once the customer enters the PIN or cancels the transaction, or in case the prompt times out.
192-
- This example will work if your site is already hosted, since the callback URL needs to be accessible via internet. For local testing purposes, you can use an endpoint hosted outside your site to check the notification received on the callback URL. There is a test listener hosted at https://darajambili.com, which you can use to view logs of notifications received. You can head over there to pick a callback URL to use for STK push.
185+
- Use a Safaricom number that you have access to for the ``phone_number`` parameter, so as to be able to receive the M-PESA prompt on your phone.
186+
- Once you have entered the PIN, you will receive a notification on the callback URL you provided. If you used the exact callback URL in the example above (i.e. https://api.darajambili.com/express-payment), you can head over to https://darajambili.com to view the notification received.
193187

194188
8. Run Migrations
195189
-----------------

0 commit comments

Comments
 (0)