Skip to main content

Standard Checkout

Initiate Payment Checkout


Overview

The Standard Checkout API allows merchants to initiate payment transactions. This endpoint creates a new checkout session and returns a redirect URL for customers to complete their payment through a hosted checkout page.


Endpoint

POST /v2/checkout/initiate

Authentication

All requests to this endpoint must include the following header:

Header: x-access-token
Value: <your_access_token>

The access token must be included in the request headers for authentication. Invalid or expired tokens will result in an authentication error.


Request Parameters

Submit a JSON payload with the following fields:

FieldTypeRequiredMax LengthDescription
merchant_transaction_idStringYes64Unique transaction ID (UUID recommended) for idempotency
amountIntegerYes-Transaction amount
payer_nameStringYes100Customer's full name
payer_emailStringYes100Customer's email address
payer_msisdnStringYes25Customer's phone number with country code (e.g., 254718192689)
service_codeStringYes32Service/product code (must be valid and active)
account_numberStringYes50Merchant's account number in the payment gateway
expires_inIntegerYes-Session expiry duration in minutes
narrationStringYes255Transaction description/purpose
callback_urlStringYes500Webhook URL for payment notifications (must be HTTPS)
redirect_urlStringYes500URL to redirect customer after payment completion

Request Example

cURL

curl -X POST https://sandbox.api.gateway.lipad.io/v2/checkout/initiate \
-H "Content-Type: application/json" \
-H "x-access-token: your_access_token_here" \
-d '{
"merchant_transaction_id": "5eb251eb-93c3-4e9b-a530-a39a3b300871",
"amount": 1000,
"payer_name": "John Doe",
"payer_email": "[email protected]",
"payer_msisdn": "25470000000",
"service_code": "DEMCHE1",
"account_number": "25470000000",
"expires_in": 60,
"narration": "Checkout redirect test",
"callback_url": "",
"redirect_url": ""
}'

Successful Response

Status Code: 200 OK

When the checkout is successfully created, the API returns a JSON object with the following fields:

{
"merchant_transaction_id": "5eb251eb-93c3-4e9b-a530-a39a3b300871",
"checkout_reference": "CYGCTLY3ZI8H9ZD609QTZ",
"currency": "KES",
"amount": 1000,
"expires_at": "2026-04-29T11:35:33.008Z",
"redirect_url": "https://sandbox.pay.lipad.io/checkout/CYGCTLY3ZI8H9ZD609QTZ"
}

Response Fields

FieldTypeDescription
merchant_transaction_idStringYour original transaction ID (for tracking)
checkout_referenceStringUnique checkout session identifier from payment gateway
currencyStringTransaction currency code (e.g., "KES")
amountIntegerTransaction amount in base units
expires_atString (ISO 8601)Session expiration timestamp in UTC
redirect_urlStringHosted checkout page URL where customer completes payment

Error Response

Status Code: 400 Bad Request or other 4xx/5xx depending on error

When a request fails, the API returns an error object:

{
"status_code": 172,
"status_description": "Invalid Service Code",
"message": "Request declined"
}

Error Response Fields

FieldTypeDescription
status_codeIntegerError code indicating the type of failure
status_descriptionStringShort description of the error
messageStringAdditional details about the error

Status Query

GET /v2/checkout/status/{{merchant_transaction_id}}

cURL

curl --location 'https://sandbox.api.gateway.lipad.io/v2/checkout/status/5eb251eb-93c3-4e9b-a530-a39a3b300871' \
--header 'x-access-token:your-access-token'

Success Response

Same as under callbacks

Error Response

{
"status_code": 120,
"status_description": "Transaction not found",
"message": "Checkout reference 5eb251eb-93c3-4e9b-a530-a39a3b30087 not found"
}

Callback

After the customer completes payment, you will receive a notification at your configured callback_url.

Success Callback Example

{
"amount": "1000",
"checkout_reference": "CYGCTLY3ZI8H9ZD609QTZ",
"currency": "KES",
"merchant_transaction_id": "5eb251eb-93c3-4e9b-a530-a39a3b300871",
"narration": "Checkout redirect test",
"payments": [
{
"event": "successful_payment",
"amount": "1000.00",
"extra_data": {},
"client_code": "DEMO",
"country_code": "KEN",
"payer_msisdn": "25470000000",
"payment_date": "2026-04-29T10:40:55.006Z",
"service_code": "DEMCHE1",
"currency_code": "KES",
"account_number": "25470000000",
"payment_status": 700,
"transaction_id": "10644",
"payer_narration": "Checkout redirect test",
"charge_request_id": "7845",
"external_reference": "5eb251eb-93c3-4e9b-a530-a39a3b300871",
"receiver_narration": "Payment processed successfully",
"payment_method_code": "MPESA_KEN",
"payer_transaction_id": "GBR1FNEAGOTV",
"payment_account_reference": "GBR1FNEAGOTV"
}
],
"status": 801,
"timestamp": "2026-04-29T10:40:55.449Z"
}

Callback Fields

FieldTypeDescription
amountStringPayment amount received
checkout_referenceStringCheckout session reference
currencyStringCurrency code (e.g., "KES")
merchant_transaction_idStringYour original transaction ID
narrationStringTransaction description
paymentsArrayArray of payment records
statusIntegerOverall transaction status (801 = successful)
timestampString (ISO 8601)When payment was processed

Payment Record Fields

FieldTypeDescription
eventStringEvent type (e.g., "successful_payment")
amountStringPayment amount with decimal places
extra_dataObjectAdditional payment data
client_codeStringClient identifier
country_codeStringCountry code (e.g., "KEN")
payer_msisdnStringCustomer phone number
payment_dateString (ISO 8601)Payment timestamp
service_codeStringService code
currency_codeStringCurrency code
account_numberStringMerchant account number
payment_statusIntegerPayment status code (700 = successful)
transaction_idStringInternal transaction ID
payer_narrationStringPayer's description of payment
charge_request_idStringCharge request identifier
external_referenceStringExternal reference (merchant transaction ID)
receiver_narrationStringReceiver's description of payment
payment_method_codeStringPayment method used (e.g., "MPESA_KEN")
payer_transaction_idStringPayer's transaction reference
payment_account_referenceStringPayment account reference

Integration Flow

Follow these steps to integrate the Standard Checkout API:

Step 1: Collect Customer Information

Gather the customer's details and order information on your application.

Step 2: Generate Unique Transaction ID

Create a unique merchant_transaction_id for each checkout (UUID recommended):

Step 3: Initiate Checkout

Call the /v2/checkout/initiate endpoint with all required fields.

Step 4: Handle Response

  • Success: Redirect the customer to the redirect_url
  • Error: Display error message and allow customer to retry

Step 5: Customer Completes Payment

Customer is redirected to hosted checkout page to enter payment details.

Step 6: Receive Webhook Notification

Your callback_url receives payment status notification.

Step 7: Update Order Status

Fetch status after receiving callback. (Do not rely on callbacks alone). Process the payment notification and update your database accordingly.

Step 8: Fulfill Order

Once payment is confirmed, proceed with order fulfillment.


Status Codes

Checkout Status Codes

StatusDescription
801Full payment received - Complete.
802Partial Payment received - Incomplete.
803Unpaid i.e failed payments, no payments.
820Expired with no payments.
840Payment reversed.
841Payment refunded.
850Jammed.
851Pending.

Payment Status Codes

StatusDescription
700Successful payment made.
701Failed payment made
702Payment was Reversed
703Payment is Pending Processing
704Payment is Jammed. Requires manual intervention to continue processing
705Payment is Refunded
706Payment has been accepted for processing by operator
707Payment is being reprocessed
708Payment is pending approval (maker-checker payments)

Error Response Codes

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

Troubleshooting

Issue: "Invalid Service Code"

Error: Status code 172

Causes:

  • Service code doesn't exist
  • Service code is disabled
  • Service code doesn't belong to your account

Solution: Verify the service code with your account manager

Issue: "Unauthorized"

Error: Status code 401

Causes:

  • Missing x-access-token header
  • Invalid or expired token

Solution: Check your access token and ensure it's correctly included in the header

Issue: "Webhook Not Received"

Causes:

  • Callback URL is not publicly accessible
  • Server is behind a firewall
  • Webhook handler is returning error status

Solution:

  • Ensure callback URL is HTTPS and publicly accessible
  • Ensure webhook handler returns 200 status
  • Check server logs for errors

Issue: "Duplicate Webhooks"

Cause: Webhook delivery retries

Solution: Implement idempotency using merchant_transaction_id to safely handle duplicate callbacks