waarie
v1.0.0
Published
Official Node.js & TypeScript SDK for Waarie Payment Gateway (Pan-African Mobile Money & Cards)
Maintainers
Readme
waarie
Official Node.js & TypeScript library for the Waarie Payment Gateway (Pan-African Mobile Money & Cards: MTN MoMo, Wave, Orange Money, Moov Africa).
📦 Installation
npm install waarie
# or
pnpm add waarie
# or
yarn add waarie🚀 Quickstart
1. Initialize Client
import { WaarieClient } from 'waarie';
const waarie = new Waarie({
apiKey: process.env.WAARIE_SECRET_KEY!, // 'sk_live_...' or 'sk_test_...'
sandbox: false // Defaults to true if using sk_test_...
});2. Create Mobile Money Checkout
const payment = await waarie.payments.create({
amount: 5000,
currency: 'XOF',
merchant_reference: `ORDER-${Date.now()}`,
operator: 'orange', // 'wave', 'mtn', 'orange', 'moov', 'cards'
customer_phone: '+22507000000',
customer_name: 'Adjoua N\'Guessan',
customer_email: '[email protected]',
return_url: 'https://yoursite.com/orders/success',
cancel_url: 'https://yoursite.com/orders/cancel',
metadata: {
cart_id: 4821
}
});
console.log('Redirect user to:', payment.payment.checkout_url);3. Verify Express / Next.js Webhook
import express from 'express';
import { Webhook } from '@waarie/sdk';
const app = express();
app.post('/webhooks/waarie', express.raw({ type: 'application/json' }), (req, res) => {
const signature = req.headers['x-waarie-signature'] as string;
const webhookSecret = process.env.WAARIE_WEBHOOK_SECRET!;
const isValid = Webhook.verifySignature(req.body, signature, webhookSecret);
if (!isValid) {
return res.status(401).json({ error: 'Signature verification failed' });
}
const event = JSON.parse(req.body.toString());
if (event.event === 'payment.successful') {
const payment = event.data.payment;
console.log(`Payment confirmed: ${payment.payment_code}`);
}
return res.status(200).json({ received: true });
});🛡️ License
MIT License — Waarie Technologies Inc.
