M-Pesa Integration

Integrate M-Pesa with a single line of code!

All you need to do:
  1. Make a single API call to initiate the payment
  2. Expose an endpoint to receive charge notifications.

Simple as that!

In order to initiate M-Pesa payment with [CentiliPaymentAPI], you need to send request as HTTPS POST with Content-Type: application/json composed of parameters with associated values.

URL to which request should be posted:

https://api.centili.com/api/payment/1_4/transaction

POST payment request

POST https://api.centili.com/api/payment/1_4/transaction HTTP/1.1
Host: api.centili.com:443
Content-Type: application/json

{
  "apikey":"7346b125eecdd199c26898e959cdb974",
  "price":"1.00",
  "msisdn":"25466xxxxxx"
}

Initiation parameters:

ParameterDescriptionExampleRequired as
apikeyCentili issued service key, unique for every payment service. Consists of alphanumeric characters and counts up to 32 characters.f31a355df6dad07e49ba474db7ff9b07 mandatory
priceEnd user price for an ongoing
transaction.
1.00 mandatory

Look for Keep in mind callout box underneath this table.
msisdnCustomer mobile phone number.
NOTE: The number must be in E.164 format, excluding the plus ("+") character.
254708374149 mandatory
clientidUnique identification parameter under your system (pass-through variable).appID1optional
useridIdentification of the customer.usrId1983

NOTE: If the value is not set within payment request, this field will contain MSISDN of the particular customer.
optional

🚧

Keep in mind:

"price" parameter can only be an integer as per M-Pesa regulations

POST payment response

Once request is received, Centili will synchronously respond with POST response containing appropriate HTTP response and a list of parameters and values in JSON format:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "status": "ACCEPTED",
  "transactionid": "123456789",
  "clientid": "xxxxxxxxx",
  "sessionStatus": "PENDING",
  "operatorCode": "KE_SAFARICOM",
  "countryCode": "ke",
  "msisdn": "25466xxxxxx",
  "apiKey": "7346b125eecdd199c26898e959cdb974"
}

Response parameters:

ParameterDescriptionExample
statusIndicates status of the current request.Possible values:
ACCEPTED
CHARGING_FAILED
INVALID_REQUEST
INVALID_SERVICE
UNAUTHORIZED
INACTIVE
INVALID_MSISDN
INVALID_OPERATOR_CODE
INVALID_MCCMNC
INVALID_PRICE
DAILY_LIMIT_EXCEEDED
MONTHLY_LIMIT_EXCEEDED
errorMessageError description in case of failed transaction request.Bad request
transactionIdUnique identifier of transaction in Centili system.123456789
apikeyCentili issued service key, unique for every payment service. Consists of alphanumeric characters and counts up to 32 characters.f31a355df6dad07e49ba474db7ff9b07
clientIdUnique identification parameter under your system (pass-through variable reference; max length: 256 characters).appID1
priceEnd user price for specific transaction.1.00
countryCodeTwo-letter ISO 31661 international standard code.ke
(for Kenya)
operatorCodeCode of Mobile Network Operator in Centili’s system which end user belongs to.KE_SAFARICOM
(for Safaricom Kenya)
mccMobile country code.639
(example for Kenya)
mncMobile network code.02
msisdnCustomer mobile phone number.
NOTE: The number must be in E.164 format, excluding the plus ("+") character.
254708374149
actionSignifies type of flow for the initiated transaction.Possible values:

URL_REDIRECT
PREMIUM
PIN
HANDSHAKE

NOTE: look for these instructions how to regulate further flow according to data received in our response (underneath this table).
sessionStatusIndicatior of current state of transaction.Possible values:

PENDING
FAILED
* COMPLETED
urlRedirectURL to which user should be redirected in order to continue with payment process (delivered only if action=URL_REDIRECT).
premiumInstructionsInstruction containing keyword and shortcode user needs to configure a confirmation MO message before sending (delivered only if action=PREMIUM)."Please send GO to 1234 in order to confirm purchase."

NOTE: instruction is displayed in a local language. Check our country coverage.
shortCodeShortcode contained in premium instruction (delivered only if action=PREMIUM).1234
smsBodyKeyword contained in premium instruction (delivered only if action=PREMIUM).GO
handshakeInstructionsText instructing user to reply to the received MT message in order to confirm payment (delivered only if action=HANDSHAKE)."Please send YES to 1234 in order to confirm purchase."

NOTE: message is sent in a local language. Check our country coverage.

Payment Result Notification

Once transaction reaches a final state Payment Result Notification will be delivered to your system.

Payment Result Notification: https://dev.centili.com/v1.1/docs/payment-result-notification