Nylon PayNylon Pay

Make Payout

Send a disbursement to a mobile money wallet or bank account

makePayout(request)

Initiates a payout and returns a PaymentInstance immediately. Use the event listeners to track status changes in real time. A payout moves funds from your Nylon Pay balance to an external mobile money wallet or bank account.

const payout = await nylonpay.makePayout(request);

Request Fields

FieldTypeRequiredDescription
amountnumberyesPayout amount in smallest currency unit. Minimum 5000 UGX
currencyCurrencyyesISO 4217 currency code (e.g., "UGX")
descriptionstringyesPayout description
customer.namestringyesRecipient full name
customer.phoneNumberstringyesRecipient phone number. Any common format accepted, auto-normalized to 256XXXXXXXXX. See Phone Number Format
customer.emailstringnoRecipient email address
destination.accountHolderNamestringyesName on the receiving account
destination.accountNumberstringyesMobile money number or bank account number
destination.bankNamestringnoBank name, required for bank account payouts
destination.phonestringnoMobile money number when paying to a wallet. Any common format accepted, auto-normalized
referencestringnoUnique reference (any valid UUID). Auto-generated as UUID v4 if omitted
metadataRecord<string, string>noCustom key-value pairs attached to the transaction

Example

import { createNylonPay } from '@nile-squad/nylonpay-ts';

const nylonpay = createNylonPay({
  apiKey: 'npk_test_...',
  apiSecret: 'nps_test_...',
});

const payout = await nylonpay.makePayout({
  amount: 50000,
  currency: 'UGX',
  description: 'Supplier payment #4471',
  customer: {
    name: 'Jane Doe',
    phoneNumber: '+256700000000',
  },
  destination: {
    accountHolderName: 'Jane Doe',
    accountNumber: '1234567890',
  },
  reference: '550e8400-e29b-41d4-a716-446655440000', // UUID (any version accepted)
});

payout.on('success', ({ transaction }) => {
  console.log('Payout delivered:', transaction.id);
});

Resolve Variant

Use makePayoutAndResolve() when you prefer a single blocking call instead of event listeners. It waits until the payout reaches a terminal state and returns a Result.

const result = await nylonpay.makePayoutAndResolve({
  amount: 50000,
  currency: 'UGX',
  description: 'Supplier payment #4471',
  customer: { name: 'Jane Doe', phoneNumber: '+256700000000' },
  destination: { accountHolderName: 'Jane Doe', accountNumber: '1234567890' },
});

if (result.isOk) {
  console.log('Payout status:', result.value.status);
}

Idempotency

The reference field prevents duplicate payouts. If a request fails and you retry with the same reference, the SDK returns the existing payout instance instead of creating a new one.

A supplied reference must be a valid UUID of any version. The SDK generates a UUID v4 when you omit reference. Never reuse the same reference for different payouts.

Return Value

makePayout() returns a PaymentInstance with:

MethodDescription
.on(event, handler)Listen for events (processing, success, failed, cancelled, error)
.once(event, handler)Listen once, then auto-remove
.off(event, handler)Remove a handler
.wait()Promise that resolves Transaction on success, null on failure/cancel/error. Never rejects.
.referenceThe transaction reference
.statusCurrent transaction status

See Also

On this page