- Make a single API call to initiate the payment
- Expose an endpoint to receive charge notifications.
Integrate M-Pesa with a single line of code!
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 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"
}
apikey
Centili issued service key, unique for every payment service. Consists of alphanumeric characters and counts up to 32 characters.
f31a355df6dad07e49ba474db7ff9b07
mandatory
price
End user price for an ongoing
transaction.
1.00
mandatory
Look for Keep in mind callout box underneath this table.
msisdn
Customer mobile phone number.
NOTE: The number must be in E.164 format, excluding the plus ("+") character.
254708374149
mandatory
clientid
Unique identification parameter under your system (pass-through variable).
appID1
optional
userid
Identification 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
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"
}
status
Indicates 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
errorMessage
Error description in case of failed transaction request.
Bad request
transactionId
Unique identifier of transaction in Centili system.
123456789
apikey
Centili issued service key, unique for every payment service. Consists of alphanumeric characters and counts up to 32 characters.
f31a355df6dad07e49ba474db7ff9b07
clientId
Unique identification parameter under your system (pass-through variable reference; max length: 256 characters).
appID1
price
End user price for specific transaction.
1.00
operatorCode
Code of Mobile Network Operator in Centili’s system which end user belongs to.
KE_SAFARICOM
(for Safaricom Kenya)
mcc
Mobile country code.
639
(example for Kenya)
mnc
Mobile network code.
02
msisdn
Customer mobile phone number.
NOTE: The number must be in E.164 format, excluding the plus ("+") character.
254708374149
action
Signifies 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).
sessionStatus
Indicatior of current state of transaction.
Possible values:
- PENDING
- FAILED
- COMPLETED
urlRedirect
URL to which user should be redirected in order to continue with payment process (delivered only if action=URL_REDIRECT).
premiumInstructions
Instruction 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.
shortCode
Shortcode contained in premium instruction (delivered only if action=PREMIUM).
1234
smsBody
Keyword contained in premium instruction (delivered only if action=PREMIUM).
GO
handshakeInstructions
Text 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.
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