Authorizations
The API key to use for authentication
Body
The payment body details
Daraja Express Payment Request - flat structure combining customer and payment data
Customer phone number in format 254XXXXXXXXX (required if customerId is not provided)
"254712345678"
Amount transacted (KES). Only whole numbers are supported. Money that the customer pays to the Shortcode.
0 < x <= 250000
100
The description of the payment
1 - 13
"Invoice #1234"
Existing customer ID - if provided, other customer fields are ignored
255
"cus_GqfKXLmg61LURZhB"
Customer full name (ignored if customerId is provided)
1
"John Doe"
Customer email address (ignored if customerId is provided)
5
"johndoe@example.com"
Customer description (ignored if customerId is provided)
1 - 255
"VIP Customer"
Key-value object allowing you to store additional information.
Key Requirements:
- Must be a string
- Maximum length of 40 characters
Value Types:
- String (maximum 500 characters)
- Integer
- Floating-point number
- Boolean
Limits:
- Maximum of 50 key-value pairs Additional customer metadata (ignored if customerId is provided)
{
"user_preference": "dark_mode",
"last_login": 1640995200,
"is_premium": true,
"account_balance": 1250.75,
"notifications_enabled": false
}
Account reference for the payment
1 - 12
"moflay"
Key-value object allowing you to store additional information.
Key Requirements:
- Must be a string
- Maximum length of 40 characters
Value Types:
- String (maximum 500 characters)
- Integer
- Floating-point number
- Boolean
Limits:
- Maximum of 50 key-value pairs Additional payment metadata
{
"user_preference": "dark_mode",
"last_login": 1640995200,
"is_premium": true,
"account_balance": 1250.75,
"notifications_enabled": false,
"order_id": "ord_123456",
"invoice_number": "INV-2024-001",
"tax_amount": 16,
"discount_applied": false
}
Response
Payment Response
Daraja Express Payment Response
Current status of the transaction
pending
, completed
, failed
"completed"
Payment amount in the smallest currency unit (e.g., cents for KES)
x > 0
1000
Platform fee charged for the transaction
x >= 0
15
Amount received by business after fees (amount - fee)
x > 0
985
Transaction currency code
"KES"
Unique transaction identifier prefixed with 'trxn_'
"trxn_ABC123DEF456GHI"
Customer phone number used for payment
"254712345678"
Unique customer ID (existing or newly created) prefixed with 'cus_'
"cus_GqfKXLmg61LURZhB"
Environment where transaction was processed
sandbox
, production
"sandbox"
Transaction timestamp in ISO 8601 format
"2024-12-19T10:30:00.000Z"
Response message from M-Pesa
"Payment completed successfully"
Transaction description
"Payment for Order #12345"
Account reference for the transaction (provided in request or auto-generated)
"store_001"