For a Kenya-optimised Paystack checkout: (1) include "mobile_money" as a channel — this enables M-Pesa STK push through Paystack; (2) amounts are in KES sent to Paystack in kobo/cents (multiply by 100); (3) set currency: "KES"; (4) include the customer phone number (07XXXXXXXX format) so Paystack can trigger the M-Pesa STK push to the right number; (5) do not restrict to card-only if you want Kenyan conversions.
// Kenya-optimised transaction initialization
var response = await fetch('https://api.paystack.co/transaction/initialize', {
method: 'POST',
headers: {
Authorization: 'Bearer ' + process.env.PAYSTACK_SECRET_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
email: customer.email,
phone: customer.phone, // e.g., '0712345678' or '+254712345678' — required for M-Pesa STK push
amount: Math.round(orderAmountKES * 100), // KES to smallest unit
currency: 'KES',
reference: generateReference(),
channels: ['mobile_money', 'card', 'bank'], // M-Pesa first in the list
metadata: {
order_id: order.id,
},
callback_url: 'https://yourapp.com/payment/callback',
}),
});
M-Pesa STK push flow via Paystack:
charge.success webhook to your serverThe STK push requires a live Safaricom number — test mode simulates it automatically.
Get weekly developer tips
Join 25,000+ developers. Practical guides, job tips, and new content — straight to your inbox.
No spam. Unsubscribe anytime.
This guide is part of the Paystack by country guide.
KES 2,999
The definitive guide to building payment systems with Paystack — from your first transaction to production-grade payment infrastructure across Africa. 9 modules, 47 lessons. Free preview available.
Start Paystack Course