Skip to main content
This page walks through the shortest path to a real M-Pesa Express payment: create the payment, let the customer approve it on their phone, then poll until it settles.

Prerequisites

You need:
  • An API key from the Pesaswap dashboard.
  • A profile_id from the dashboard.
  • A phone number that can receive an M-Pesa STK prompt.
Creating a merchant account, generating an API key, and setting up a connector are covered elsewhere in these docs — this page assumes you already have all three.
1

Create and confirm the payment

Send a POST request to /payments with confirm: true. This creates the payment and immediately attempts to confirm it in one call, so a customer-facing STK prompt is triggered as soon as the request returns.
A successful call returns a 200 with a payment object. The fields that matter right now:
The money has not moved yet. status: requires_customer_action means the STK prompt is now on the customer’s phone, waiting for them to act. Nothing settles until they respond.
2

The customer approves

The customer sees the STK push notification on their handset and enters their M-Pesa PIN. Nothing else for you to build here — this happens on their phone, outside your API calls.
3

Poll for the result

Once the customer has approved (or rejected, or ignored) the prompt, retrieve the payment to find out what happened. Use force_sync=true so the request checks with the connector instead of returning a stale status.
force_sync defaults to false. Without it, this endpoint returns the last stored status — it does not contact the connector. If you omit force_sync=true, your polling loop will keep reading a stale requires_customer_action status and will never see the payment settle.

Status reference

You may also see other values from the full status set (requires_confirmation, requires_payment_method, requires_merchant_action, cancelled, requires_capture, partially_captured, partially_captured_and_capturable) depending on the payment method and configuration, but a straightforward M-Pesa Express flow moves through requires_customer_actionprocessingsucceeded or failed.

Next steps

Wallet payments

M-Pesa Express, Airtel Money, and MTN MoMo in one place.

Card payments and 3DS

Cards, redirects, and authentication.

Mandates and recurring

Save a payment method and charge it later.

Refunds

Send money back to a customer.

Payouts

Send money out to a recipient.