M-Pesa
Prompt a caller to pay with an M-Pesa STK push, then check whether they entered their PIN.
M-Pesa
Safaricom's M-Pesa, through the Daraja API's Lipa na M-Pesa Online. luftflow uses it two ways:
- Collect a payment sends an STK push to the caller's phone: M-Pesa asks them for their PIN to pay the amount to your paybill or till.
- Check a payment asks M-Pesa whether they entered it: paid, not yet, or declined.
The pattern the example flow shows: collect after the caller confirms, then a menu, "Enter your M-Pesa PIN on your phone, then press 1", whose first option checks. A caller who has not entered their PIN yet is asked again.
Keys
Create an app on the Daraja portal with Lipa na M-Pesa Online.
- For staging, use the app's sandbox consumer key and consumer secret, and the sandbox passkey from the test credentials page. The sandbox shortcode is
174379, filled in for you. - For live, Safaricom gives you the live keys and passkey when your paybill or till goes live on Daraja.
Paste each into Connectors → M-Pesa in luftflow. Give your business shortcode and paid to number: both are your paybill number for a paybill; for a till, the store number and the till number, with kind of account set to CustomerBuyGoodsOnline.
M-Pesa wants an address to report each payment to. luftflow asks M-Pesa itself how the payment went, so any https address of yours will do; nothing needs to answer there.
Amounts and time
Amounts are whole shillings. M-Pesa signs each request with the time in East Africa; luftflow uses the moment the call began, so the step is the same on every replay. A caller who leaves the prompt for many minutes is asked to try again rather than charged twice.