Nylon PayNylon Pay

Get Status

Check transaction status directly via API

getStatus(request)

Retrieves the current status of a transaction. Returns a Result object.

const result = await nylonpay.getStatus({ reference });

When to Use

  • Webhook verification: Confirm payment status before fulfilling orders
  • Your own dashboards: Display payment status to customers or operators
  • Fallback: Verify status if the event-driven flow fails or times out

Request

type GetStatusInput = {
  reference: string; // the reference used in collectPayment()
};

Response

type StatusResponse = {
  reference: string;
  status: TransactionStatus;
  amount: number;
  currency: Currency;
  id: string;
  operatorTid: string | null;
  failureReason: string | null;
  failureCategory?: FailureCategory | null;
  failureCode?: FailureCode | null;
  statusText?: string;
  delayed?: boolean;
  updatedAt: string;
};
FieldDescription
idNylon transaction ID
operatorTidID on the customer's operator or bank receipt. null until it is reported
failureReasonHuman sentence when the payment failed or was cancelled, otherwise null
failureCategoryBroad class: provider, customer, internal, validation
failureCodeNylon code such as insufficient_balance
statusTextExtra human sentence. For on_hold, why the payout is in review
delayedtrue when the payment has been waiting longer than a few minutes
type TransactionStatus =
  | 'pending'
  | 'processing'
  | 'on_hold'
  | 'successful'
  | 'failed'
  | 'cancelled';

Result Pattern

All SDK methods return the Result pattern. Always check result.isOk before accessing data.

const result = await nylonpay.getStatus({ reference });

if (result.isOk) {
  const { reference, status, amount, currency } = result.value;
  console.log(`${reference}: ${status} (${amount} ${currency})`);
} else {
  console.error('Failed to get status:', result.error);
}

Example

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

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

async function verifyPayment(reference: string) {
  const result = await nylonpay.getStatus({ reference });

  if (result.isErr) {
    return { valid: false, reason: result.error };
  }

  const tx = result.value;

  return {
    valid: tx.status === 'successful',
    reason:
      tx.status === 'successful' ? 'Payment confirmed' : `Payment ${tx.status}`,
    transaction: tx,
  };
}

Webhook Verification

Always verify webhook payloads with getStatus() before fulfilling orders. The transaction reference lives inside the payload object of the webhook body:

app.post('/webhooks/nylonpay', async (req, res) => {
  const { reference } = req.body.payload;

  const result = await nylonpay.getStatus({ reference });

  if (result.isErr || result.value.status !== 'successful') {
    return res.status(400).json({ error: 'Invalid payment' });
  }

  res.status(200).json({ received: true });
});

vs Event-Driven Approach

AspectgetStatus()Event-Driven (on/wait)
ControlPull modelPush model
LatencyOn-demandReal-time
Use caseVerification, adminUser-facing flows
ComplexitySimplerEvent-driven

When to Use Which

ScenarioRecommended
You need to confirm a payment after a timeoutgetStatus()
You're building an admin dashboardgetStatus()
Your webhook received a notificationBoth, use webhook plus verify with getStatus()
You need real-time UI updates during paymentEvent-driven (on/wait)
You're writing a simple scriptEvent-driven (wait())

getTransaction(input)

Retrieves the full transaction record. Requires at least one of id or reference.

const result = await nylonpay.getTransaction({ reference });

if (result.isOk) {
  const tx = result.value;
  console.log(tx.id, tx.status, tx.amount);
}
FieldTypeRequiredDescription
idstringnoTransaction ID. Either id or reference required
referencestringnoThe reference used at creation. Either id or reference required

Unlike getStatus(), which returns a lightweight summary, getTransaction() returns the complete transaction record (customer, method, tags, timestamps, and more).

verifyPhone(input)

Confirms a phone number and returns the registered name. Use it to verify customer identity before you initiate a collection or payout.

const result = await nylonpay.verifyPhone({ phoneNumber: '+256700000000' });

if (result.isOk) {
  console.log(result.value.customerName); // confirmed account name
}
FieldTypeRequiredDescription
phoneNumberstringyesPhone number in any common format, auto-normalized
purpose"collection" or "payout"noWhether you plan to collect or disburse

Returns { phoneNumber, customerName, verified }. When verification succeeds, customerName holds the registered name and verified is true; when the number can't be matched, verified is false.

On this page