digitalpaye-node
v1.0.0
Published
Official Node.js SDK for the DigitalPaye API — Mobile Money payments (Orange Money, MTN MoMo, Moov Flooz, Wave) in Côte d'Ivoire.
Maintainers
Readme
digitalpaye-node
Official Node.js SDK for the DigitalPaye API — accept and send Mobile Money payments (Orange Money, MTN MoMo, Moov Flooz, Wave) in Côte d'Ivoire.
Zero dependencies. Works with Node.js 14+.
Installation
npm install digitalpaye-nodeQuick start
const DigitalPaye = require('digitalpaye-node');
const dp = new DigitalPaye({
publicKey: process.env.DIGITALPAYE_PUBLIC_KEY,
secret: process.env.DIGITALPAYE_SECRET,
});
// Directly collect a Mobile Money payment
const { data } = await dp.transactions.collect({
amount: 5000,
currency: 'XOF',
operator_code: 'ORANGE_MONEY_CI',
external_ref: 'INV-2026-001',
otp: '3378', // required for Orange Money
payer_phone: '0777101308',
payer_first_name: 'Jean',
payer_last_name: 'Konan',
payer_email: '[email protected]',
});
console.log(data.status, data.reference);The SDK handles the Basic → Bearer token exchange automatically (and
caches/renews it) — you never need to call the /v1/auth/token endpoint
yourself.
Usage examples
Orders (cart-style checkout)
const order = await dp.orders.create({
currency: 'XOF',
items: [
{ name: 'T-shirt', quantity: 2, unit_price: 5000 },
{ name: 'Shipping', quantity: 1, unit_price: 1000 },
],
url_success: 'https://my-shop.com/thank-you',
url_error: 'https://my-shop.com/cart',
});
await dp.orders.pay(order.data.reference, {
operator_code: 'MTN_MONEY_CI',
external_ref: 'ORDER-PAY-001',
payer_phone: '0546123456',
payer_first_name: 'Awa',
payer_last_name: 'Touré',
payer_email: '[email protected]',
});Payment links
const link = await dp.paymentLinks.create({
label: 'Support our school',
amount: 10000,
currency: 'XOF',
});
console.log(link.data.url); // share this URLPayouts (send money out)
await dp.payouts.create({
amount: 25000,
currency: 'XOF',
operator_code: 'WAVE_MONEY_CI',
external_ref: 'PAYOUT-001',
recipient_phone: '0707112233',
});Balance
const { data } = await dp.balance.retrieve();
console.log(data.balance, data.currency);Beneficiaries, Invoices, Bulk transfers, Scheduled transfers, Escrow, Contactless
All follow the same list / create / retrieve / update / delete
pattern — see index.d.ts for the full list of methods and parameters, or
browse src/resources/*.js (each file is self-contained and documented
with JSDoc).
Error handling
Every failed request throws a DigitalPayeError:
const { DigitalPayeError } = require('digitalpaye-node');
try {
await dp.transactions.collect({ amount: 50, currency: 'XOF', /* ... */ });
} catch (err) {
if (err instanceof DigitalPayeError) {
console.error(err.code, err.status, err.message, err.details);
}
}Pagination
List endpoints accept a params object forwarded as the query string
(e.g. { page: 2, limit: 50, status: 'successful' }) and return
{ data, meta } where meta contains pagination info.
const { data, meta } = await dp.transactions.list({ page: 1, limit: 20 });TypeScript
Type definitions are bundled (index.d.ts) — no @types package needed.
License
MIT
