Documentation Index
Fetch the complete documentation index at: https://docs.moflay.com/llms.txt
Use this file to discover all available pages before exploring further.
Use these examples after you have installed the SDK and created an API key with the express.pay permission. Add transactions.read when your app also reads payment or transaction status.
Basic payment
import { Moflay } from "@moflay/sdk";
const moflay = new Moflay({
token: process.env.MOFLAY_API_KEY!,
});
const payment = await moflay.express.pay({
phoneNumber: "254712345678",
amount: 1000,
description: "Order 1001",
accountReference: "ORDER1001",
});
console.log(payment.paymentId, payment.transactionId, payment.status);
Payment with customer details
const payment = await moflay.express.pay({
phoneNumber: "254712345678",
customerName: "Jane Doe",
amount: 250000,
description: "Plan",
accountReference: "SUB202604",
metadata: {
orderId: "SUB-2026-04",
plan: "premium",
},
});
Payment for an existing customer
When you send customerId, do not include extra customer fields in the same request.
const payment = await moflay.express.pay({
customerId: "cus_GqfKXLmg61LURZhB",
amount: 5000,
description: "Invoice",
accountReference: "INV1001",
});
Handle payment creation errors
try {
const payment = await moflay.express.pay({
phoneNumber: "254712345678",
amount: 1000,
description: "Order 1001",
accountReference: "ORDER1001",
});
console.log(payment.paymentId);
} catch (error) {
console.error("Payment request failed", error);
}
Request limits
| Field | Limit |
|---|
amount | Integer in minor currency units from 1 to 250000 |
description | Up to 13 characters |
accountReference | Up to 12 alphanumeric characters |
For example, amount: 1000 means KES 10.00.
Related pages