Skip to content

Moolre Payments

Moolre is a payment technology company providing seamless payment solutions across Ghana and Nigeria. This guide covers how to integrate Moolre payments using Voltax.

Before you begin, you’ll need:

  • A Moolre merchant account (sign up at moolre.com)
  • Your Moolre API credentials:
    • Public API Key
    • Moolre Username
    • Moolre Wallet Account Number

Initialize a Moolre provider with your credentials:

import Voltax from "@noelzappy/voltax";
const moolre = Voltax("moolre", {
apiUser: process.env.MOOLRE_USERNAME!,
apiPublicKey: process.env.MOOLRE_PUBLIC_API_KEY!,
accountNumber: process.env.MOOLRE_WALLET_ACCOUNT_NUMBER!,
});
import { Currency } from "@noelzappy/voltax";
const payment = await moolre.initiatePayment({
amount: 5000, // 5,000 GHS
email: "customer@example.com",
currency: Currency.GHS,
reference: `txn-${Date.now()}`,
callbackUrl: "https://yoursite.com/webhook/callback",
redirectUrl: "https://yoursite.com/payment/redirect",
});
// Redirect customer to complete payment
console.log(payment.authorizationUrl);
// "https://checkout.moolre.com/xxxxxxxxxx"

Attach Metadata. Moolre will automatically return this to you during their callback/webhook call to you.

import { Currency } from "@noelzappy/voltax";
const payment = await moolre.initiatePayment({
amount: 5000, // 5,000 GHS
email: "customer@example.com",
currency: Currency.GHS,
reference: `txn-${Date.now()}`,
callbackUrl: "https://yoursite.com/webhook/callback",
redirectUrl: "https://yoursite.com/payment/redirect",
metadata: {
customer_id: "12345",
order_id: "67890",
},
});
// Redirect customer to complete payment
console.log(payment.authorizationUrl);
// "https://checkout.moolre.com/xxxxxxxxxx"

Generate a reusable authorization URL that can be used to initiate payments without requiring user input.

import { Currency } from "@noelzappy/voltax";
const payment = await moolre.initiatePayment({
amount: 5000, // 5,000 GHS
email: "customer@example.com",
currency: Currency.GHS,
reference: `txn-${Date.now()}`,
callbackUrl: "https://yoursite.com/webhook/callback",
redirectUrl: "https://yoursite.com/payment/redirect",
linkReusable: true, // This controls whether the authorization URL can be reused for multiple payments. By default, it is set to false.
metadata: {
customer_id: "12345",
order_id: "67890",
},
});
// Redirect customer to complete payment
console.log(payment.authorizationUrl);
// "https://checkout.moolre.com/xxxxxxxxxx"
const payment = await moolre.initiatePayment({
amount: 250,
email: "customer@example.com",
currency: Currency.GHS,
reference: `order-${Date.now()}`,
description: "Order #12345 - Premium Package",
callbackUrl: "https://yoursite.com/webhooks/moolre",
redirectUrl: "https://yoursite.com/payment/redirect",
linkReusable: true,
accountNumberOverride: "1234567890",
metadata: {
customer_id: "12345",
order_id: "67890",
},
});

All Moolre-specific options are top-level fields in the payment DTO:

interface MoolrePaymentDTO {
// Base required fields
amount: number;
email: string;
currency: Currency;
reference: string; // Required for Moolre
callbackUrl: string; // Required for Moolre
// Moolre-specific required
redirectUrl: string; // Where to redirect after successful payment
// Optional fields
linkReusable?: boolean; // Whether the authorization URL can be reused
accountNumberOverride?: string; // Override the account/wallet number
description?: string;
metadata?: Record<string, any>;
}
URLPurpose
callbackUrlServer-to-server webhook URL for payment notifications
redirectUrlWhere to redirect the customer after successful payment

After the customer completes payment, verify the transaction:

import { PaymentStatus } from "@noelzappy/voltax";
const result = await moolre.verifyTransaction("123456");
console.log(result);
// {
// status: 'SUCCESS',
// reference: 'moolre-123456',
// externalReference: 'txn_xxxxxxxxxx',
// raw: { ... }
// }
if (result.status === PaymentStatus.SUCCESS) {
// Access detailed transaction data
console.log(result.reference);
}

Voltax maps Moolre statuses to standardized values:

Moolre StatusVoltax Status
1SUCCESS
0PENDING
2FAILED
OtherPENDING

For a quick status check:

const status = await moolre.getPaymentStatus("mool-123456");
if (status === PaymentStatus.SUCCESS) {
console.log("Payment successful!");
}