Afriex SDK
API Reference

Checkout API

Create hosted payment sessions. Afriex handles the payment UI; you redirect customers to complete the transaction.

Create Checkout Session

const session = await afriex.checkout.createSession({
  amount: 500000,
  currency: "NGN",
  merchantReference: "order-2026-05-12-001",
  redirectUrl: "https://yourapp.com/checkout/return",
  customer: {
    name: "John Doe",
    email: "john@example.com",
    phone: "+2348192837465",
    countryCode: "NG",
  },
  channels: ["VIRTUAL_BANK_ACCOUNT"],
  metadata: {
    orderId: "order-456",
    cartId: "cart-123",
  },
});

// Redirect customer to session.checkoutUrl
console.log(session.checkoutUrl); // https://checkout.afriex.com/pay/...

Response:

{
  checkoutUrl: string; // Redirect customer here
}

Parameters

FieldTypeRequiredDescription
amountnumberYesAmount in minor currency units. Minimum value is 100
currencystringYesUppercase 3-letter ISO 4217 currency code, for example NGN
merchantReferencestringYesUnique merchant-supplied reference for the session
redirectUrlstringYesHTTPS URL to redirect the customer to after checkout
customer.namestringYesCustomer's full name
customer.emailstringYesCustomer's email address
customer.phonestringYesPhone number in E.164 format
customer.countryCodestringYesISO 3166-1 alpha-2 country code
channelsstring[]NoAllowed payment channels. Defaults to VIRTUAL_BANK_ACCOUNT
metadataobjectNoOptional flat key/value metadata with string values

Session Flow

  1. Create session with amount, customer details, merchantReference, and redirectUrl
  2. Redirect customer to checkoutUrl
  3. Customer completes payment on Afriex-hosted page
  4. Afriex redirects the customer back to redirectUrl
  5. Receive webhook on your configured callback URL for session updates

amount is denominated in minor units. For example, to charge NGN 5,000.00, send 500000.

Use merchantReference as your end-to-end identifier for lookup, reconciliation, and webhook matching.

Use Cases

Immediate payment collection
Customer pays now; funds settle to your balance.

Delayed payment processing
Create session in advance; send link to customer later.

Embedded checkout
Open checkoutUrl in iframe or webview for in-app payment.

On this page