Skip to Content
APITransactions

Transactions API

Create and manage money transfer transactions.

Create Transaction

Withdraw (default)

Send funds to a customer’s destination payment method:

const transaction = await afriex.transactions.create({ customerId: "customer-id", sourceAmount: "10", destinationAmount: "5000", sourceCurrency: "USD", destinationCurrency: "NGN", destinationId: "payment-method-id", meta: { reference: "ref-withdraw-001", idempotencyKey: "unique-key-123", narration: "Payment for services", }, });

Deposit

Pull funds from a customer’s source payment method:

const transaction = await afriex.transactions.create({ customerId: "customer-id", type: "DEPOSIT", sourceAmount: "10", destinationAmount: "5000", sourceCurrency: "USD", destinationCurrency: "NGN", sourceId: "source-payment-method-id", meta: { reference: "ref-deposit-001", idempotencyKey: "unique-key-456", }, });

Request Parameters:

FieldTypeRequiredDescription
customerIdstringYesID of the customer
sourceAmount${number}YesAmount in source currency
destinationAmount${number}YesAmount in destination currency
sourceCurrencystringYesSource currency code (e.g., USD)
destinationCurrencystringYesTarget currency code (e.g., NGN)
typestring-WITHDRAW (default), DEPOSIT, or SWAP
destinationIdstringYes for WITHDRAWPayment method ID to send funds to
sourceIdstringYes for DEPOSITPayment method ID to pull funds from
meta.referencestringYesYour internal reference (e.g., order ID)
meta.idempotencyKeystringYesUnique key to prevent duplicate transactions
meta.narrationstring-Transaction description
meta.invoicestring-Base64-encoded invoice document
meta.merchantIdstring-Your merchant/business identifier

Get Transaction

const transaction = await afriex.transactions.get("transaction-id");

List Transactions

const response = await afriex.transactions.list({ page: 1, limit: 20, }); console.log(response.data); // Transaction[]

Transaction Status

Transactions can have the following statuses:

StatusDescription
PENDINGTransaction created, awaiting processing
PROCESSINGTransaction is being processed
COMPLETEDTransaction completed successfully
SUCCESSTransaction successful
FAILEDTransaction failed
CANCELLEDTransaction was cancelled
REFUNDEDTransaction was refunded
RETRYTransaction is being retried
REJECTEDTransaction was rejected
IN_REVIEWTransaction is under review
UNKNOWNTransaction status is unknown