M-Pesa icon

M-Pesa

Consume M-Pesa Daraja 3.0 APIs

Actions12

STK Push → Initiate

AI-generated

Summary

Initiate an STK Push payment prompting the specified phone number to authorize a transaction using M-Pesa's Lipa na M-Pesa Online payment API.

Inputs

  • Business Short Code (required) — The organization shortcode. For Buy Goods transactions, use the go-live organization shortcode and provide the till number separately as Party B.
  • Amount (required) — The amount to be transacted.
  • Phone Number (required) — The phone number (in format 2547xxxxxxxx) to receive the STK Push prompt.
  • Transaction Type (required) — The type of transaction: 'Pay Bill' for payment to a Paybill number, or 'Buy Goods' for payment to a Till number.
  • Till Number (Party B) (required) — The till number to send as Party B for Buy Goods transactions. Required only if Transaction Type is 'Buy Goods'.
  • Callback URL (required) — The URL where the payment results will be sent via callback.
  • Account Reference (required) — Account reference for the transaction.
  • Transaction Description (required) — Description of the transaction.

Output shape

a single JSON object containing the response from the M-Pesa STK Push initiation API call.

The output includes the response data from the M-Pesa API call which indicates whether the STK Push request was successfully initiated. The actual payment result is sent asynchronously to the specified Callback URL.

Examples

Example 1: Initiate a paybill STK Push payment

Set Business Short Code to your Paybill, Amount to the transaction amount, Phone Number to the customer's phone in 2547xxxxxxxx format, Transaction Type to 'Pay Bill', and provide Callback URL, Account Reference, and Transaction Description accordingly.

Example 2: Initiate a buy goods STK Push payment

Set Business Short Code to your organization shortcode, Transaction Type to 'Buy Goods', specify the Till Number as Party B, and provide the other required fields to prompt the customer for payment to the specified till number.

Links

Discussion