Moosyl logo

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:

  1. Keys → Get your API keys from dashboard
  2. Backend → Create payment request via Moosyl API
  3. Frontend → Display payment interface with transaction ID
  4. Customer → Select banking app and complete payment
  5. Dashboard → View payments and requests in Moosyl dashboard
  6. 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_...

Learn more about API keys →

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();

Learn more about the API →

3. Display Payment Interface (Frontend)

Flutter

MoosylView(
  publishableApiKey: 'pk_test_...',
  transactionId: transactionId,
  onPaymentSuccess: () => print('Payment completed!'),
)

Flutter SDK guide →

React

<MoosylProvider publishableKey="pk_test_...">
  <PaymentForm transactionId={transactionId} />
</MoosylProvider>

React SDK guide →

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 });
});

Webhooks guide →

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/webhooks

Go Live

  1. Replace test keys with live keys (sk_live_..., pk_live_...)
  2. Update webhook URL to production endpoint
  3. Test with small amounts first
  4. Monitor webhook logs in dashboard

Next Steps

Quickstart