All URIs are relative to https://sandbox.safaricom.co.ke
| Method | HTTP request | Description |
|---|---|---|
| mpesa_b2b_v1_paymentrequest_post | POST /mpesa/b2b/v1/paymentrequest | Make a B2B Payment Request |
| mpesa_c2b_v1_simulate_post | POST /mpesa/c2b/v1/simulate | Simulate a C2B Payment |
| mpesa_c2b_v2_registerurl_post | POST /mpesa/c2b/v2/registerurl | Register C2B Confirmation and Validation URLs |
| mpesa_stkpush_v1_processrequest_post | POST /mpesa/stkpush/v1/processrequest | Initiate a Lipa na M-Pesa Online Payment |
B2BPaymentResponse mpesa_b2b_v1_paymentrequest_post(body)
Make a B2B Payment Request
from __future__ import print_function
import time
import mpesa_client
from mpesa_client.rest import ApiException
from pprint import pprint
# Configure API key authorization: bearerAuth
configuration = mpesa_client.Configuration()
configuration.api_key['Authorization'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['Authorization'] = 'Bearer'
# create an instance of the API class
api_instance = mpesa_client.PaymentsApi(mpesa_client.ApiClient(configuration))
body = mpesa_client.B2BPaymentRequest() # B2BPaymentRequest |
try:
# Make a B2B Payment Request
api_response = api_instance.mpesa_b2b_v1_paymentrequest_post(body)
pprint(api_response)
except ApiException as e:
print("Exception when calling PaymentsApi->mpesa_b2b_v1_paymentrequest_post: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| body | B2BPaymentRequest |
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
C2BPaymentSimulationResponse mpesa_c2b_v1_simulate_post(body)
Simulate a C2B Payment
from __future__ import print_function
import time
import mpesa_client
from mpesa_client.rest import ApiException
from pprint import pprint
# Configure API key authorization: bearerAuth
configuration = mpesa_client.Configuration()
configuration.api_key['Authorization'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['Authorization'] = 'Bearer'
# create an instance of the API class
api_instance = mpesa_client.PaymentsApi(mpesa_client.ApiClient(configuration))
body = mpesa_client.C2BPaymentSimulationRequest() # C2BPaymentSimulationRequest |
try:
# Simulate a C2B Payment
api_response = api_instance.mpesa_c2b_v1_simulate_post(body)
pprint(api_response)
except ApiException as e:
print("Exception when calling PaymentsApi->mpesa_c2b_v1_simulate_post: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| body | C2BPaymentSimulationRequest |
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
C2BURLRegistrationResponse mpesa_c2b_v2_registerurl_post(body)
Register C2B Confirmation and Validation URLs
from __future__ import print_function
import time
import mpesa_client
from mpesa_client.rest import ApiException
from pprint import pprint
# Configure API key authorization: bearerAuth
configuration = mpesa_client.Configuration()
configuration.api_key['Authorization'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['Authorization'] = 'Bearer'
# create an instance of the API class
api_instance = mpesa_client.PaymentsApi(mpesa_client.ApiClient(configuration))
body = mpesa_client.C2BURLRegistrationRequest() # C2BURLRegistrationRequest |
try:
# Register C2B Confirmation and Validation URLs
api_response = api_instance.mpesa_c2b_v2_registerurl_post(body)
pprint(api_response)
except ApiException as e:
print("Exception when calling PaymentsApi->mpesa_c2b_v2_registerurl_post: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| body | C2BURLRegistrationRequest |
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
StkPushResponse mpesa_stkpush_v1_processrequest_post(body)
Initiate a Lipa na M-Pesa Online Payment
from __future__ import print_function
import time
import mpesa_client
from mpesa_client.rest import ApiException
from pprint import pprint
# Configure API key authorization: bearerAuth
configuration = mpesa_client.Configuration()
configuration.api_key['Authorization'] = 'YOUR_API_KEY'
# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['Authorization'] = 'Bearer'
# create an instance of the API class
api_instance = mpesa_client.PaymentsApi(mpesa_client.ApiClient(configuration))
body = mpesa_client.StkPushRequest() # StkPushRequest |
try:
# Initiate a Lipa na M-Pesa Online Payment
api_response = api_instance.mpesa_stkpush_v1_processrequest_post(body)
pprint(api_response)
except ApiException as e:
print("Exception when calling PaymentsApi->mpesa_stkpush_v1_processrequest_post: %s\n" % e)| Name | Type | Description | Notes |
|---|---|---|---|
| body | StkPushRequest |
- Content-Type: application/json
- Accept: application/json
[Back to top] [Back to API list] [Back to Model list] [Back to README]