Skip to main content

Direct Charge

You can conveniently collect payments through cards, banks, or any of our supported ways with just one integration using Lipad Checkout. It however comes with the Lipad checkout experience.

There are occasions when you want additional control that works with your app. Direct charge enters the picture here. We supply the APIs for clients to be charged, but you are responsible for gathering their payment information and bringing your own UI and payment flow. You can control and modify the customer experience however you like.

There are three main stages in direct charge:

  1. Initiate the payment: Send the charge request to the appropriate charge endpoints.
  2. Authorize the charge: Customer interacts with the payment prompts and completes the paymnent.
  3. Post callback payment verification: As a failsafe, you'll call our Status API to verify that the payment was successful before giving value.

Lipad Direct charge Transaction Flow

Direct Charge Transaction Flow Description

  1. The charge request originator (Client) captures and sets the API required parameters and sends the request to the respective charge endpoint.
  2. The API receives the request, validates it and sends an acknowledgement response back to the originator (Client).
  3. A charge request is initiated via the Payments Partner responsible eg Airtel Money or M-Pesa
  4. The Customer authorizes the transaction.
  5. The Payments Partner debits the customer and Credits LIPAD Wallet, sends payment result to LIPAD
  6. LIPAD processes the result, credits the Originator's LIPAD Wallet with funds from the payment.
  7. LIPAD Charge Service then sends Payment Notification webhook to the webhook URL registered on our system. (Type: Payments Notifications)

Authentication

All requests made to LIPAD Direct Charge APIs will require token authentication. Authentication requests are send to: POST https://dev.lipad.io/v1/auth Authentication Request body

{
"consumer_key": "Xjpe948ixgdhlUrRNlOwc",
"consumer_secret": "hNjZK2JVm4Uc1whgskjsiY9G"
}

Response Body

{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjbGllbnRfaWQiOiIxNiIsImRlc2lnbmF0aW9uIjoiQXBpIFVzZXIiLCJhdXRob3JpemVkIjp0cnVlLCJpYXQiOjE2Nzc3MDY4ODgsImV4cCI6MTY3NzcxMjg4OH0.kADugWTjIrXokYYhDTXg4idmsLy6pUTv6N0Hi-ZMkrI",
"expiresIn": 6000
}

Use the token returned under access_token for all requests made to the Payouts APIs. The token should be passed as a Request Header x-access-token. The token will be valid for up to 1 hour.

Supported Payment Methods

Broadly we support the following payment method types in our Direct Charge Api:

  1. Mobile Money

Mobile Money

We support several MNOs(mobile network providers) across the continent. You can find several supported MNOs in the next section

The following table provides information about the Mobile Network Operators currently supported by our Direct Mobile Money Charge API.

Kenya

Mobile Network Operator(MNO)Lipad Short CodeCountryCurrency
Safaricom MPESAMPESA_KENKENKES
Airtel KenyaAIRTEL_KENKENKES

MPESA

This payment method allows you to receive KES payments via Mpesa.

POST https://dev.charge.lipad.io/v1/mobile-money/charge

The following is a payload structure expected by the mobile money charge endpoint;

{
"external_reference": "123456",
"origin_channel_code": "API",
"originator_msisdn": "2547****56",
"payer_msisdn": "254******56",
"service_code": "<client service code>",
"account_number": "123456789",
"invoice_number": "",
"currency_code": "KES",
"amount": "100",
"add_transaction_charge": false,
"transaction_charge": "0",
"payment_method_code": "<payment method code>",
"paybill": "123456",
"extra_data": {
},
"description": "Payment by 254700123456",
"notify_client": false,
"notify_originator": false
}

Request Body Parameters description

ParameterData TypeNullDescription
external_referencestringNOThis is the unique reference generated by the external/internal party requesting charge. It will be used to send a callback once charge is successful.
origin_channel_codestringYESThis is an optional parameter indicating where the request to charge originated from. It has to be a valid channel code (API, WEB, USSD, APP)
originator_msisdnstringNOThis is the mobile number of the individual initiating the request for charge.
payer_msisdnstringNOThis is the mobile number that will be debited. It will receive the USSD or STK push.
service_codestringNOThis is the service against which charge is being made. Once successful, a payment will be logged against this service.
account_numberstringNOThis is the account number against which the payment is being made.
invoice_numberstringYESThis is an internal invoice number to be used by the originating system.
currency_codestringYESThis is the currency to be used to charge the client.
amountstringNOThis is the service amount to be charged from the client.
add_transaction_chargebooleanNOIndicates whether the customer should be charged extra fees.
transaction_chargestringNOThe transaction charge amount to be applied if the addTransactionCharge parameter is set to true.
payment_method_codestringNOThe code to be used to identify the payment method. See LIPAD Short Codes on Supported MNOs section
paybillstringNOParameter to indicate the paybill or till number or business name/code to be used when invoking the respective telcos. Use LIPAD_DEFAULT if none is configured
extra_datajsonYESJSON array of any additional information to be captured during charge. The same information will be relayed back when sending payment callbacks.
descriptionstringYESDescription of the payment.
notify_clientbooleanNOTells charge whether to send an IPN to the owner client of the service using the callback URL configured under the client.
notify_originatorbooleanNOTells charge whether to send an IPN to the client who originated the charge request (Identified by credentials used to invoke charge). The IPN is sent using the callback URL configured under the client.

Request Response Body

Once the mobile money charge is requested, an acknowledgement is sent back to the initiating channel or customer. The response could be successful or failed.

*Note: Be sure to checkout the status codes section to see the various statusCodes that can be returned.*

The payload structure shown below demonstrates a successful charge response;

{
"status_code": 102,
"status_description": "Request to charge customer was successfully placed",
"total_amount": "1900",
"service_amount": "1800",
"transaction_charge": "100",
"charge_request_id": 123456789,
"external_reference":123456
}

The following table describes the response payload above.

ParameterData TypeNullDescription
status_codeintNOStatus of the charge request.
status_descriptionstringNODescription of the charge status.
total_amountstringNOTotal amount charged from the customer.
service_amountstringNOService amount from the total amount paid.
transaction_chargestringNOCharge amount from the total amount paid.
charge_request_idintNOInternal Charge request ID.
external_referencestringNOThis is the unique reference generated by the external/internal party that requested the charge.

Error Response Body

{
"status_code": 172,
"status_description": "Could not initiate Charge Request",
"message": "Missing or Invalid access token"
}

Error Response Parameters Description

ParameterDescription
status_codeStatus of the charge request. See Status Codes Section
status_descriptionDescription of the charge status
messageError specific description

AIRTEL MONEY

This payment method allows you to receive payments via Airtel Money.

POST https://dev.charge.lipad.io/v1/mobile-money/charge

The following is a payload structure expected by the mobile money charge endpoint;

{
"external_reference": "123456",
"origin_channel_code": "API",
"originator_msisdn": "2547****56",
"payer_msisdn": "254******56",
"service_code": "<client service code>",
"account_number": "123456789",
"invoice_number": "",
"currency_code": "KES",
"amount": "100",
"add_transaction_charge": false,
"transaction_charge": "0",
"payment_method_code": "<payment method code>",
"extra_data": {
},
"description": "Payment by 254700123456",
"notify_client": false,
"notify_originator": false
}

Request Body Parameters description

ParameterData TypeNullDescription
external_referencestringNOThis is the unique reference generated by the external/internal party requesting charge. It will be used to send a callback once charge is successful.
origin_channel_codestringYESThis is an optional parameter indicating where the request to charge originated from. It has to be a valid channel code (API, WEB, USSD, APP)
originator_msisdnstringNOThis is the mobile number of the individual initiating the request for charge.
payer_msisdnstringNOThis is the mobile number that will be debited. It will receive the USSD or STK push.
service_codestringNOThis is the service against which charge is being made. Once successful, a payment will be logged against this service.
account_numberstringNOThis is the account number against which the payment is being made.
invoice_numberstringYESThis is an internal invoice number to be used by the originating system.
currency_codestringYESThis is the currency to be used to charge the client.
amountstringNOThis is the service amount to be charged from the client.
add_transaction_chargebooleanNOIndicates whether the customer should be charged extra fees.
transaction_chargestringNOThe transaction charge amount to be applied if the addTransactionCharge parameter is set to true.
payment_method_codestringNOThe code to be used to identify the payment method. See LIPAD Short Codes on Supported MNOs section
paybillstringNOParameter to indicate the paybill or till number or business name/code to be used when invoking the respective telcos. Use LIPAD_DEFAULT if none is configured
descriptionstringYESDescription of the payment.
notify_clientbooleanNOTells charge whether to send an IPN to the owner client of the service using the callback URL configured under the client.
notify_originatorbooleanNOTells charge whether to send an IPN to the client who originated the charge request (Identified by credentials used to invoke charge). The IPN is sent using the callback URL configured under the client.

Request Response Body

Once the mobile money charge is requested, an acknowledgement is sent back to the initiating channel or customer. The response could be successful or failed.

*Note: Be sure to checkout the status codes section to see the various statusCodes that can be returned.*

The payload structure shown below demonstrates a successful charge response;

{
"status_code": 102,
"status_description": "Request to charge customer was successfully placed",
"total_amount": "1900",
"service_amount": "1800",
"transaction_charge": "100",
"charge_request_id": 123456789,
"external_reference":123456
}

The following table describes the response payload above.

ParameterData TypeNullDescription
status_codeintNOStatus of the charge request.
status_descriptionstringNODescription of the charge status.
total_amountstringNOTotal amount charged from the customer.
service_amountstringNOService amount from the total amount paid.
transaction_chargestringNOCharge amount from the total amount paid.
charge_request_idintNOInternal Charge request ID.
external_referencestringNOThis is the unique reference generated by the external/internal party that requested the charge.

Error Response Body

{
"status_code": 172,
"status_description": "Could not initiate Charge Request",
"message": "Missing or Invalid access token"
}

Error Response Parameters Description

ParameterDescription
status_codeStatus of the charge request. See Status Codes Section
status_descriptionDescription of the charge status
messageError specific description

Callbacks

Once payment is made against a charge request by the customer, a callback shall be sent back to the client of the service or originator of the payment request. This payment notification is sent back to the client depending on the notify_client or notify_originator parameters that were sent during charge initiation.

NOTE:

  1. All callbacks from LIPAD employ Basic authentication with the username and password registered alongside the callback url. See Basic Authentication rfc for guidance.
  2. Do not rely entirely on webhooks for Charge request status. Use the LIPAD Charge Status API to verify a Payout Status
  3. Acknowledge webhook receipt with the following response

Payment result acknowledgement Response Body

{
"charge_request_id": "123",
"acknowledgement_code": "900",
"acknowledgement_description": "payment accepted",
"payment_id": "12345"
}

Payment result acknowledgement Response Body Parameters description

ParameterDescription
charge_request_idThe incoming charge request ID
acknowledgement_codeA status code that indicates whether a request was accepted or rejected.
  • 900 - Accepted
  • 901 - Rejected
acknowledgement_descriptionCallback receipt acknowledgement status description
payment_idThe incoming IPN payment ID

NOTE: Unacknowledged callbacks will be retried 3 times over the next 48 hours after which no further webhooks will be sent.

Payment Result Body

{
"event": "successful_payment",
"amount": "2.00",
"extra_data": "extraData",
"client_code": "ATL-6815O1F",
"country_code": "KEN",
"payer_msisdn": "2547XXXXXXXX",
"payment_date": "2023-02-21T10:15:47.862Z",
"service_code": "EATZ_CHECKOUT",
"currency_code": "KES",
"account_number": "2547XXXXXXXX",
"payment_status": 700,
"transaction_id": "2019",
"payer_narration": "2547XXXXXXXX",
"charge_request_id": "873",
"external_reference": "1431",
"receiver_narration": "The service request is processed successfully.",
"payment_method_code": "MPESA_KEN",
"payer_transaction_id": "RBL35TKMUH"
}

Result Parameters description

NameTypeDescription
eventStringIndicates payment event e.g failed_payment or successful_payment
amountStringAmount paid by customer.
extra_dataStringExtra data passed during redirect
client_codeStringMerchant client code
country_codeStringThe 3 digit ISO of the country which the payment was made from.
payer_msisdnStringThis is the mobile number that will be debited. It will receive the USSD or STK push.
payment_dateStringDate which payment was made.
service_codeStringThe service for which the payment request was made.
currency_codeStringThis is the currency to be used to charge the client.
account_numberStringThis is the account number against which the payment is being made.
payment_statusStringIndicates payment status i.e
  • 700 - Successful payment received
  • 701 - Failed transaction
transaction_idStringUnique transaction id generated by Lipad.
payer_narrationStringRequest description initally sent by Merchant.
charge_request_idStringUnique charge id generated by Lipad.
external_referenceStringUnique charge id generated by Checkout.
receiver_narrationStringNarration generated by payment gateway.
payment_method_codeStringThe payment method to be used to charge customer.
payer_transaction_idStringId generated by payment gateway.

Charge Request Status

For status verification or in the event when result callbacks fail, the Charge Request Status API can be employed. Requests to check payout status are sent to:

GET <https://dev.charge.lipad.io/v1/transaction/{charge_request_id}/status

NOTE: For charge status Response Body and Parameters description, see Callbacks section.

Charge Request-Result Payment Status Codes

This flag indicates the individual payment status i.e successful or failed.

StatusDescription
700Successful payment made.
701Failed payment made
702Payment was Reversed
703Payment is Pending Processing
704Payment is Jammed. Requires manual intervention to continue processing

Charge Request-Response Status Codes

The status codes below will be used to indicate the status of the charge request made.

Status CodeStatus MessageComment
176CHARGE POSTED SUCCESSFULLYThis is the success code for posting a charge request.
173GENERIC SUCCESSGENERIC SUCCESS
174GENERIC FAILUREGENERIC FAILURE
172GENERIC VALIDATION FAILUREThis is the generic code to be returned for generic validations.
132Invalid Credentials. Authentication failedInvalid Credentials. Authentication failed
131Authentication was a successAuthentication was a success
120INVOICE ACCOUNT NUMBER NOT SPECIFIEDThis is the error code for when the invoice account number is not specified.
110INVALID CUSTOMER MSISDNThis is the error code for a failed msisdn
109CUSTOMER MSISDN MISSINGMissing Payer MSISDN
115INVALID CURRENCY CODECurrency error