Skip to content

Sell Airtime and Data in Your App

Let customers pay with Mobile Money and receive airtime or data bundles on MTN, Telecel, and AT within seconds.

Top-ups are one of the most frequent purchases customers make. This guide combines Mobile Money Collection with the Sales APIs to build a top-up shop: the customer pays, your server sells airtime or data from your wallet, and Sales Status confirms delivery.

Overview

This pattern fits anywhere customers already spend money with you:

  • Fintech and wallet apps adding a "Buy airtime" or "Buy data" screen.
  • Resellers and agents selling top-ups to walk-in customers.
  • Loyalty and survey platforms paying rewards as airtime or data.

Before you begin

Create a Sell on Our Platform Service in the Moolre App, and send its linked wallet as accountnumber on every Sales request. Special payment pricing is available for businesses selling airtime and data. See the Sales guide.

Top-up flow

  1. Customer picks a top-up

    Airtime for any amount from GHS 1.00, or a data bundle from the live Bundles catalogue.

  2. Collect payment

    Your server sends a Mobile Money Collection prompt to the customer’s phone.

  3. Payment confirmed

    The payment callback arrives with txstatus 1. Only now do you sell.

  4. Send airtime or data

    Call the Airtime or Data API from the wallet linked to your sales service.

  5. Confirm delivery

    Sales Status tells you whether the sale was sent, is pending, or was refunded.

Collect into the same wallet that is linked to your sales service, so each customer payment funds the sale it pays for. Keep enough float in that wallet for sales still waiting on a payment callback.

Show products and prices

For data, call Bundles with the recipient’s network and show the returned data, validity, and price. Cache the list for a few minutes, but always look the bundle up again on your server at checkout. Never trust a price sent from the browser.

For airtime, let the customer choose any amount from GHS 1.00. Then create the order with two references: one for the payment and one for the sale. Both come from your order ID.

const axios = require('axios');​// Wallet linked to your Sell on Our Platform Service. It pays for every sale.const SALES_WALLET = process.env.MOOLRE_SALES_WALLET;​const sales = axios.create({  baseURL: 'https://api.moolre.com',  headers: { 'X-API-USER': process.env.MOOLRE_USER, 'X-API-KEY': process.env.MOOLRE_API_KEY },});const payments = axios.create({  baseURL: 'https://api.moolre.com',  headers: { 'X-API-USER': process.env.MOOLRE_USER, 'X-API-PUBKEY': process.env.MOOLRE_PUB_KEY },});​// 1. Show the current bundles for the recipient's network (cache for a few minutes).async function listBundles(network) { // 'MTN' | 'TELECEL' | 'AT'  const { data } = await sales.post('/open/sales/bundles', { accountnumber: SALES_WALLET, network });  return data.data?.[network.toLowerCase()] ?? []; // [{ bundle, price, data, validity, category }]}​// 2. Create the order and send the payment prompt.async function checkout({ orderId, product, network, receiver, payer, payerChannel, bundle, amount }) {  // Never trust a price from the browser: look the bundle up again on the server.  if (product === 'data') {    const match = (await listBundles(network)).find((item) => item.bundle === bundle);    if (!match) throw new Error('Bundle is no longer available');    amount = match.price;  }​  await db.orders.insert({    id: orderId, product, network, receiver, bundle, amount,    paymentRef: `PAY-${orderId}`,    saleRef: `SALE-${orderId}`, // reused for every status check of this sale    status: 'awaiting_payment',  });​  await payments.post('/open/transact/payment', {    type: 1,    channel: payerChannel, // 13 = MTN, 6 = Telecel, 7 = AT    currency: 'GHS',    payer, // customer's 0-prefixed number, e.g. 0241234567    amount: String(amount),    externalref: `PAY-${orderId}`,    accountnumber: SALES_WALLET,  });}

Deliver after payment

Sell only when the payment callback reports txstatus 1. Then call Airtime or Data with the order’s sale reference.

A successful sale response is usually ASL11: the sale is in progress, not delivered. Queue a Sales Status check that looks the sale up by the same reference (idtype 1).

// 3. Payment callback: sell only after the payment succeeds.app.post('/webhooks/moolre', express.json(), async (req, res) => {  const payment = req.body?.data;  if (payment?.secret !== process.env.MOOLRE_CALLBACK_SECRET) return res.sendStatus(401);  res.sendStatus(200); // acknowledge quickly, then process​  const order = await db.orders.findOne({ paymentRef: payment.externalref });  if (!order || order.status !== 'awaiting_payment') return; // unknown or duplicate callback​  if (payment.txstatus !== 1) {    return db.orders.update(order.id, { status: 'payment_failed' });  }​  await db.orders.update(order.id, { status: 'selling' });  await sell(order);});​// 4. Send the airtime or data bundle from the linked sales wallet.async function sell(order) {  const body = {    type: 1,    channel: order.network, // MTN, TELECEL, or AT    receiver: order.receiver, // e.g. 233240000000    currency: 'GHS',    accountnumber: SALES_WALLET,    externalref: order.saleRef,  };  if (order.product === 'data') body.bundle = order.bundle; // price comes from the bundle  else body.amount = String(order.amount); // airtime: at least 1.00​  try {    const { data } = await sales.post(`/open/sales/${order.product}`, body);    await db.orders.update(order.id, { saleCode: data.code }); // ASL11 = in progress, not delivered  } finally {    // Even after a timeout or ASL06, never resend: check the status instead.    queue.add('check-sale', { orderId: order.id }, { delay: 15000 });  }}​// 5. Confirm the outcome with Sales Status, using the same sale reference.async function checkSale(orderId) {  const order = await db.orders.get(orderId);  const { data } = await sales.post('/open/sales/status', {    type: 1, accountnumber: SALES_WALLET, idtype: 1, id: order.saleRef,  });​  switch (data.data?.txstatus) {    case 1: return db.orders.update(orderId, { status: 'delivered' });    case 2: return db.orders.update(orderId, { status: 'refunded', refundId: data.data.refundid });    case 0: return queue.add('check-sale', { orderId }, { delay: 30000 }); // still pending    default: return db.orders.update(orderId, { status: 'needs_review', saleCode: data.code });  }}

Handle every outcome

Sales Status returns data.txstatus. Map each value to an order state your support team can act on:

0

Pending

Check Sales Status again later. Do not resend the sale.

1

Sent

Mark the order delivered and notify the customer, for example by SMS.

2

Failed and refunded

Your wallet was refunded (see refundid). Retry with a new sale reference or refund the customer.

3

Not found

No sale exists for that reference in the wallet. Flag the order for review.

Never double-sell

If a sale request times out or returns ASL06, the sale may still have gone through. Check Sales Status with the original reference first. Only a final txstatus of 2 (failed and refunded) makes it safe to sell again with a new reference.

Production checklist

  • Linked wallet: every Sales request uses the wallet linked to your Sell on Our Platform Service.
  • Server-side pricing: bundle prices come from Bundles at checkout. Airtime amounts are at least GHS 1.00.
  • Unique references: one payment reference and one sale reference per order, unique within the wallet.
  • Idempotent callbacks: verify the callback secret and ignore duplicate callbacks for orders already being processed.
  • Number formats: the payment payer uses the local 0-prefixed format; the sale receiver follows the format shown on the Airtime and Data pages.
  • Reconciliation: review orders left in needs_review daily, and alert when the sales wallet runs low.
  • Customer receipts: send an SMS once a sale is confirmed as sent.