Amount limits

Read the smallest and largest amount of each network, and fix an amount that is refused.

Every mobile money network has a smallest and a largest amount, and a fee, for each of three operations: a collection, a payout and a refund. Test mode and live mode have their own values, and the call answers for the mode of your key.

Create a payment, Preview the fee, Create a refund and a checkout session refuse an amount outside the limits before anything is sent to the customer's phone.

Read the limits

Call List payment methods with a key that has the payments.read scope. You get one entry per network:

curl "https://api-malipo.flex.co.tz/api/v1/payment-methods" \
  -H "Authorization: Bearer <token>"
[
  {
    "type": "mobile_money",
    "network": "mpesa",
    "available": true,
    "enabled": true,
    "limits": [
      {
        "operation": "collection",
        "currency": "TZS",
        "minimum": 500,
        "maximum": 5000000,
        "pricing": { "percent": 0, "fixed": 0 }
      },
      {
        "operation": "payout",
        "currency": "TZS",
        "minimum": 5000,
        "maximum": 5000000,
        "pricing": { "percent": 0, "fixed": 0 }
      },
      {
        "operation": "refund",
        "currency": "TZS",
        "minimum": 0,
        "maximum": 5000000,
        "pricing": { "percent": 0, "fixed": 0 }
      }
    ]
  }
]

The numbers above only show the shape. Read your own values from the call.

FieldMeaning
networkmpesa (Vodacom M-Pesa) or mixx_by_yas (Mixx by Yas).
availabletrue when Flex Malipo offers the network to your account.
enabledtrue when you take payments on the network. It is always false when available is false.
limits[].operationcollection, payout or refund.
limits[].minimumThe smallest amount, an integer in the currency's minor unit. 0 means any amount above zero.
limits[].maximumThe largest amount, in the minor unit. null when there is none.
limits[].pricingThe fee: percent of the amount (2.5 means 2.5%) plus fixed in the minor unit.

Amounts are integers: 5000000 is TZS 5,000,000. See Money.

Preview an amount

Preview the fee with kind, amount and currency checks the amount against the same limits as creating the payment would, and answers with the fee and the net, without creating anything. Send network (mpesa or mixx_by_yas) when the networks have different limits or fees. Without it, and with different limits, the answer is 400 with the code parameter_missing.

When an amount is refused

An amount below the smallest is refused with 400 and the code amount_too_small. An amount above the largest is refused with 400 and the code amount_too_large. param is amount, and limit tells you what to send instead:

{
  "error": {
    "type": "invalid_request_error",
    "code": "amount_too_small",
    "message": "The smallest collection in TZS by M-Pesa is 500.",
    "param": "amount",
    "limit": {
      "minimum": 500,
      "currency": "TZS",
      "network": "mpesa",
      "operation": "collection"
    },
    "requestId": "req_0123456789abcdef0123456789abcdef"
  }
}
limit fieldMeaning
minimumThe smallest amount allowed. Present when the amount was too small.
maximumThe largest amount allowed. Present when the amount was too large.
currencyThe currency of both.
networkThe network the limit belongs to. Left out when the limit is not a network's.
operationcollection, payout or refund.

Nothing was stored or sent when a call is refused this way. Change the amount and send the call again with a new Idempotency-Key.

The same codes appear in three more places:

  • A checkout session for a payment below the smallest amount your networks accept answers amount_too_small. A session whose smallest quantity or period is above the largest payment answers amount_too_large, and limit shows the largest payment. A subscription above it can be collected by invoice: create it with collectionMethod send_invoice.
  • A payment you record on an invoice answers amount_too_large when it is more than what is still to pay, and amount_too_small when a part payment would leave less to pay than the smallest amount a customer can pay.
  • A refund is checked against the refund limits of the network.

Networks and switches

A payment to a number on a network that is not available to you, or that you have switched off, is refused with 422 and the code payment_method_unactivated. The message names the networks you can take. A live number that is on no network gets the same answer.

Switch a network on or off with Switch a network on or off, which needs the payments.write scope. It acts on the mode of your key, so a switch in test mode never reaches live mode. A network that is not available to you cannot be switched and answers 422 with the same code.

curl -X PUT "https://api-malipo.flex.co.tz/api/v1/payment-methods/mpesa" \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{ "enabled": false }'

The answer is the network's new setting, without limits.

On this page