Mpesa Xpress and SMS Pay
End points for Mpesa Payment Confirmation and include payment details in the SMS.
Mpesa Express
The Mpesa Express feature allows users to initiate an instant STK Push to collect payments from a specified phone number. Unlike SMS Pay, which sends a payment link, Mpesa Express directly prompts the payer to input their Mpesa PIN and complete the transaction.
Use Case:
Suitable when the user knows the payer’s phone number and amount to be paid.
Ideal for scenarios requiring fast, immediate payments through Mpesa.
Endpoint: Mpesa Express
POST /api/payment/mpesa/express
Request Body:
Workflow:
The user provides the payer’s phone number and amount.
Tuku Pay initiates an STK Push request directly to the payer’s Mpesa app.
The payer receives a payment prompt on their phone and inputs their Mpesa PIN to authorize the transaction.
Tuku Pay sends the payment status to the
callbackUrl
provided by the user.
Response:
201 Created
400 Bad Request If required fields like
phoneNumber
oramount
are missing.
SMS Pay
The SMS Pay feature allows users to send SMS messages with embedded payment links, providing multiple payment options to the recipient. This feature supports Mpesa, Visa/MasterCard, PayPal, and Mcoop Cash payments, making it versatile for different payer preferences.
Use Case:
Ideal for situations where the payer may not have Mpesa funds but can pay via card, PayPal, or Mcoop Cash.
Can be used for general purposes such as product payments, donations, or subscription fees.
Endpoint: SMS Pay
POST /api/sms/pay
Request Body:
Sample SMS
"Dear Customer, Pay Kes 500 via one of the below methods:
Amount: Ksh 5000 Powered by Tuku Pay and Coop Bank."
Workflow:
Link Generation: Tuku Pay generates unique links for each payment method:
Mpesa Link: A URL for STK Push.
Online Checkout Link: Redirects to a hosted page for various payment methods.
Card Payment Link: A link for card payment through Visa/MasterCard.
Mcoop Cash Link: Prompts the payer to input their PIN in their Mcoop Cash app for Coop Bank users.
The links are shortened and dynamically replaced in the SMS body at the
{paymentLink}
placeholder.The SMS is sent to the recipient(s).
Payment notifications are sent to the
callbackUrl
.Transactions are recorded in the outbox with their statuses, timestamps, and costs.
Response:
201 Created
400 Bad Request If required fields like
amount
for Mpesa orcallbackUrl
are missing.
Additional Notes for Developers
Mpesa Express vs SMS Pay:
Use Mpesa Express for immediate, direct Mpesa payments where the phone number and amount are predetermined.
Use SMS Pay for flexible payments with multiple options, allowing payers to choose their preferred method.
Custom Payment Links: For online checkout, you can pass additional metadata (like order details) in the
callbackUrl
to receive enriched notifications.Shortened URLs: Tuku Pay automatically shortens URLs for better readability in SMS messages.
Mcoop Cash Integration: Coop Bank users can pay directly via their Mcoop Cash app. Ensure the payer has the app installed for this option to function.