View as Markdown llms.txt

Payments#

Collecting money from a customer. These are the flows where the customer approves a prompt on their own phone, so a person is always in the loop.

stk_push#

money

Send an M-Pesa payment prompt (STK push) to a customer. Returns immediately with an acknowledgement; it does NOT confirm payment. Use stk_push_and_wait if you need the outcome.

ParameterTypeNotes
phoneNumber requiredstringCustomer phone number. Accepts 07..., +2547..., or 2547... and is normalised.
amount requirednumberAmount in KES. Whole numbers only.
accountReferencestringAccount identifier shown on the customer statement. Max 12 characters.
transactionDescstringShort description. Max 13 characters.
shortCodestringOverrides DARAJA_SHORTCODE.
callbackUrlstringOverrides the built-in receiver URL.
transactionType"CustomerPayBillOnline" | "CustomerBuyGoodsOnline"PayBill or Buy Goods. Must match the shortcode type. Defaults to "CustomerPayBillOnline".

stk_push_and_wait#

money waits for callback

Send an M-Pesa payment prompt and wait for the customer to accept or decline. Returns the settled outcome including the receipt number on success. Use this when you need to know whether the payment actually completed.

ParameterTypeNotes
phoneNumber requiredstringCustomer phone number. Accepts 07..., +2547..., or 2547... and is normalised.
amount requirednumberAmount in KES. Whole numbers only.
accountReferencestringAccount identifier shown on the customer statement. Max 12 characters.
transactionDescstringShort description. Max 13 characters.
shortCodestringOverrides DARAJA_SHORTCODE.
callbackUrlstringOverrides the built-in receiver URL.
transactionType"CustomerPayBillOnline" | "CustomerBuyGoodsOnline"PayBill or Buy Goods. Must match the shortcode type. Defaults to "CustomerPayBillOnline".
timeoutSecondsnumberHow long to wait for the customer. Prompts expire after about 60 seconds. Defaults to 90.

stk_query#

control

Query the status of a previous STK push using its CheckoutRequestID.

ParameterTypeNotes
checkoutRequestId requiredstringThe CheckoutRequestID returned by stk_push.
shortCodestring

ratiba_create#

money gated in production

Create an M-Pesa Ratiba standing order for recurring collection: subscriptions, loan repayments, insurance premiums, SACCO contributions. The customer approves via an M-Pesa prompt. The standing order name must be unique per customer.

ParameterTypeNotes
standingOrderName requiredstringName of the standing order. Must be unique for this customer; a repeat name is rejected.
phoneNumber requiredstringCustomer phone number. Accepts 07..., +2547..., or 2547... and is normalised.
amount requirednumberAmount in KES. Whole numbers only.
startDate requiredstringFirst execution date, yyyymmdd or yyyy-mm-dd.
endDate requiredstringFinal execution date, yyyymmdd or yyyy-mm-dd.
frequency required"one-off" | "daily" | "weekly" | "bi-weekly" | "monthly" | "bi-monthly" | "quarterly" | "half-yearly" | "yearly"How often the standing order executes.
receiverType"paybill" | "till"Whether the shortcode is a PayBill or a Buy Goods till. Defaults to "paybill".
accountReferencestring
transactionDescstring
shortCodestring
callbackUrlstring

ratiba_create_and_wait#

money waits for callback gated in production

Create an M-Pesa Ratiba standing order and wait for the customer to approve it. Returns the settled outcome including the reminder schedule id.

ParameterTypeNotes
standingOrderName requiredstringName of the standing order. Must be unique for this customer; a repeat name is rejected.
phoneNumber requiredstringCustomer phone number. Accepts 07..., +2547..., or 2547... and is normalised.
amount requirednumberAmount in KES. Whole numbers only.
startDate requiredstringFirst execution date, yyyymmdd or yyyy-mm-dd.
endDate requiredstringFinal execution date, yyyymmdd or yyyy-mm-dd.
frequency required"one-off" | "daily" | "weekly" | "bi-weekly" | "monthly" | "bi-monthly" | "quarterly" | "half-yearly" | "yearly"How often the standing order executes.
receiverType"paybill" | "till"Whether the shortcode is a PayBill or a Buy Goods till. Defaults to "paybill".
accountReferencestring
transactionDescstring
shortCodestring
callbackUrlstring
timeoutSecondsnumberDefaults to 90.

generate_qr#

money

Generate a dynamic M-Pesa QR code for a specific amount and till or paybill.

ParameterTypeNotes
merchantName requiredstringName shown to the customer scanning the code.
refNo requiredstringYour reference for the transaction.
amount requirednumberAmount in KES. Whole numbers only.
trxCode required"BG" | "WA" | "PB" | "SM" | "SB"BG buy goods, WA withdraw agent, PB paybill, SM send money, SB send to business.
cpi requiredstringTill, paybill, or phone number the payment goes to.
sizestringQR image size in pixels. Defaults to "300".