Quickstart

Make your first test payment in a few minutes.

Make one test payment from start to finish. Nothing here moves real money.

Get a test API key

In the FlexPay dashboard, create a test API key with the payments.read and payments.write scopes. Copy the key when it is shown. It looks like fpk_test_… and is shown only once.

Get an access token

Exchange the key for an access token. Send the key in the X-Api-Key header.

curl -X POST "https://malipo.flex.co.tz/api/v1/oauth/token" \
  -H "X-Api-Key: fpk_test_your_key" \
  -d grant_type=client_credentials

The response holds access_token. It lasts five minutes. Send it as Authorization: Bearer <token> on the calls below.

Create a payment

Ask for a collection from the test number 255700000001, which always succeeds.

curl -X POST "https://malipo.flex.co.tz/api/v1/payments" \
  -H "Authorization: Bearer <token>" \
  -H "Idempotency-Key: 5f1c1e0a-3b7e-4c8e-9d1a-2f6b8a4c7e11" \
  -H "Content-Type: application/json" \
  -d '{
    "kind": "COLLECTION",
    "provider": "MPESA",
    "amount": 10000,
    "currency": "TZS",
    "customerPhoneNumber": "255700000001",
    "merchantReference": "order-1042"
  }'

You get 201 with the new payment, still pending.

Check the outcome

A few seconds later, retrieve the payment with the id from the last response.

curl "https://malipo.flex.co.tz/api/v1/payments/<id>" \
  -H "Authorization: Bearer <token>"

Its status is now SUCCEEDED, and net is what it added to your test balance.

Next

On this page