MAA INVEST Pay Docs
API reference

Create a payment

The signed POST to /pay/start.php: fields, rules and limits.

Request#

POST https://maainvest.co.ke/pay/start.php  ·  Content-Type: application/x-www-form-urlencoded  ·  sent from the customer's browser. On success the customer is redirected (303) to the hosted checkout. Errors are shown to the customer as a page (see Errors).

Fields#

FieldRequiredDescription
merchant_idyesYour Merchant ID (MRT… sandbox, MRC… live).
invoice_idyesYour order or invoice reference. 1 to 64 characters: letters, digits, . _ -.
amountyesKES, e.g. 1500.00. Between 1 and 250,000. M-Pesa only takes whole shillings, so cents are rounded up when the prompt is sent (1500.50 becomes a KES 1,501 prompt).
currencyyesMust be KES.
descriptionyesShown to the customer at checkout (keep it under 200 characters).
return_urlyesWhere the customer goes after paying. http or https, no credentials in the URL.
cancel_urlyesWhere the customer goes if they cancel or the checkout expires.
notify_urlyesPublic HTTPS URL that receives the webhook (no private or local addresses, no redirects).
customer_phoneyes, may be emptyPre-fills the checkout. Send an empty string if unused.
customer_emailyes, may be emptyStored with the checkout. Send an empty string if unused.
timestampyesUnix seconds. Requests more than 30 minutes away from our clock are rejected.
signatureyesHMAC-SHA256 hex, see Signing.

All fields must be present in the form, even the optional ones (as empty strings), because they are all part of the signature.

Rules to know#

  • A checkout stays payable for 1 hour. A customer gets up to 5 prompts per checkout, at least 15 seconds apart.
  • Posting the same invoice_id and amount again returns the existing open (or already paid) checkout instead of creating a duplicate. A different amount creates a new checkout.
  • Only the secret holder can create a checkout: never put the API secret in browser code or a mobile app. Sign on your server.
Stuck on an integration? Open a ticket from the Support page in your account and include your invoice_id, the time, and the HTTP status you returned.