Developers guide

Your first integration, step 4 of 5

Take payments from your app

Charge a customer by M-Pesa with one request and follow it to the end.

Before you start

  • A secret test key (see API keys).

  1. Step 1.

    Tap Introduction to open the menu

    The developer guide is open. The menu lists every topic.

    Step 1: Tap Introduction to open the menu
  2. Step 2.

    Tap Payments API

    The request that charges a customer by M-Pesa.

    Step 2: Tap Payments API
  3. Step 3.

    Send the amount, the customer's phone and your own reference

    Your server posts them to the payments endpoint with your secret key. The customer gets an M-Pesa prompt.

    Tap Initiate Payment

    Step 3: Send the amount, the customer's phone and your own reference
  4. Step 4.

    Add an Idempotency-Key header

    Send a new unique value with each payment. A retry after a network drop then never charges twice.

    Tap Headers

    Step 4: Add an Idempotency-Key header
  5. Step 5.

    Tap Payments API at the top to open the menu

    Step 5: Tap Payments API at the top to open the menu
  6. Step 6.

    Tap Payment Status to follow the payment

    Read the status with the reference you got back, or wait for a webhook.

    Step 6: Tap Payment Status to follow the payment
  7. Step 7.

    Tap Payment Status at the top to open the menu

    Step 7: Tap Payment Status at the top to open the menu
  8. Step 8.

    Or tap Checkout Sessions for a hosted page

    Send the customer to a CitaPay payment page instead, and they choose how to pay.

    Step 8: Or tap Checkout Sessions for a hosted page
  • Send line items with a payment and each one is fiscalised for eTIMS at its own tax rate.

Sign in to try it in your account.

Sign in

Next in your first integration

Webhooks

Hear about every payment as it happens.

Related guides