Quickstart
Get started with Moosyl in 5 minutes
Quickstart
How Moosyl Works
Moosyl enables seamless payments through Mauritania's popular banking apps (Bankily, Sedad, Masrivi). Here's the complete payment flow:
- Keys → Get your API keys from dashboard
- Backend → Create payment request via Moosyl API
- Frontend → Display payment interface with transaction ID
- Customer → Select banking app and complete payment
- Dashboard → View payments and requests in Moosyl dashboard
- Webhooks → Receive real-time notifications
1. Get Your API Keys
Get keys from dashboard and set them as environment variables.
MOOSYL_SECRET_KEY=sk_test_...
MOOSYL_PUBLISHABLE_KEY=pk_test_...2. Create Payment Request (Backend)
// POST /api/create-payment
const response = await fetch('https://api.moosyl.com/payment-request', {
method: 'POST',
headers: {
'Authorization': process.env.MOOSYL_SECRET_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({
amount: 1000, // Amount in MRU
transactionId: 'order_123', // Your unique ID
}),
});
const { transactionId } = await response.json();3. Display Payment Interface (Frontend)
Flutter
MoosylView(
publishableApiKey: 'pk_test_...',
transactionId: transactionId,
onPaymentSuccess: () => print('Payment completed!'),
)React
<MoosylProvider publishableKey="pk_test_...">
<PaymentForm transactionId={transactionId} />
</MoosylProvider>4. View in Dashboard
Log into your Moosyl dashboard to:
- Monitor payment requests
- Track payment status
- View transaction history
- Manage webhooks
5. Handle Webhooks (Backend)
// POST /api/webhooks
app.post('/webhooks', (req, res) => {
const signature = req.headers['x-webhook-signature'];
const event = req.headers['x-webhook-event'];
// Verify signature
if (!verifyWebhookSignature(req.body, signature, SECRET_KEY)) {
return res.status(401).json({ error: 'Invalid signature' });
}
if (event === 'payment-created') {
// Update order status
await updateOrderStatus(req.body.data.id, 'paid');
}
res.json({ received: true });
});6. Test Your Integration
# Test payment creation
curl -X POST https://api.moosyl.com/payment-request \
-H "Authorization: sk_test_..." \
-H "Content-Type: application/json" \
-d '{"amount": 100, "transactionId": "test_123"}'
# Test webhook (use ngrok for local testing)
ngrok http 3000
# Set webhook URL to: https://abc123.ngrok.io/webhooksGo Live
- Replace test keys with live keys (
sk_live_...,pk_live_...) - Update webhook URL to production endpoint
- Test with small amounts first
- Monitor webhook logs in dashboard
Next Steps
- API Keys - Detailed key management
- Flutter SDK - Mobile integration guide
- React SDK - Web integration guide
- Webhooks - Real-time notifications
- FAQ - Common questions