Merchant app SDKs

WayaQuick — React Native merchant app SDK

Headless client with secure keychain storage for React Native apps.

  • React Native
Installnpm install @wayapay/react-native react-native-keychain

@wayapay/react-native is a headless TypeScript client for the WayaPay merchant API. No UI, no state-management opinion — plain promises that reject with typed exceptions, so it drops into any app regardless of your state-management choice.

#Overview

It's a thin wrapper: @wayapay/core (platform-agnostic — HTTP client, models, every domain) plus a single addition, a Keychain/Keystore-backed implementation of secure token storage.

#Requirements

React Native 0.71 or later.

react-native-keychain installed and linked in your app (peer dependency — used for secure token storage).

#Install

Terminal
npm install @wayapay/react-native react-native-keychain

#Initialize

Call this once, at app startup, before rendering your navigator:

TypeScript
import { WayaPaySdk, Environment, SecureTokenStorage } from '@wayapay/react-native';

await WayaPaySdk.initialize({
  environment: Environment.staging, // or Environment.prod
  clientId: 'YOUR_APP_NAME',        // identifies the calling app to the backend
  tokenStorage: new SecureTokenStorage(), // Keychain (iOS) / Keystore (Android)
});

From anywhere in your app, WayaPaySdk.instance.auth, .wallet, .invoices, .paymentLinks, .virtualAccounts, .disputes, .customers, and .kyc are ready to use. Reading WayaPaySdk.instance before initialize() resolves throws WayaPaySdkNotInitializedException — check WayaPaySdk.isInitialized first if you need to guard against that.

If you omit tokenStorage, the SDK falls back to an in-memory store — fine for a quick prototype, but the session won't survive an app restart. Real apps should always pass SecureTokenStorage.

#Authenticate

TypeScript
const session = await WayaPaySdk.instance.auth.login({
  identifier: 'merchant@example.com', // email, phone, or Business ID — same field, backend infers which
  password: 'secret',
});

New accounts are a three-step flow — signup() does not start a session:

TypeScript
const challenge = await WayaPaySdk.instance.auth.signup({
  firstName: 'Ada', surname: 'Obi', email: 'ada@example.com',
  organizationName: 'Obi Foods', password: 'secret', phoneNumber: '08012345678',
});
await WayaPaySdk.instance.auth.verifyOtp({ identifier: challenge.email!, otpCode: '123456' });
const session = await WayaPaySdk.instance.auth.login({ identifier: 'ada@example.com', password: 'secret' });

If the account has 2FA, login() rejects with WayaPayLoginOtpRequiredException on the first attempt (credentials were fine, but an OTP is required) — call auth.resendLoginOtp({ identifier }) if the merchant needs a new code, then call login() again with otpCode set.

Once logged in, the session is implicit — no method anywhere takes a merchantId. Call auth.logout() to clear it (this clears local token storage; the backend invalidates tokens on their own natural expiry).

Password reset, for a merchant who's locked out:

TypeScript
await WayaPaySdk.instance.auth.forgotPassword({ phoneNumber: '08012345678', businessId });
await WayaPaySdk.instance.auth.resetPassword({
  identifier: email, businessId, otpCode: 123456, newPassword: 'new-secret',
});

#Handle errors

Every failure — a bad request, an expired session, no connectivity, a backend outage — rejects with one of a small, fixed set of typed exception classes. Structure your error handling as one instanceof chain:

TypeScript
import {
  WayaPayValidationException,
  WayaPaySessionExpiredException,
  WayaPayNetworkException,
  WayaPayServerException,
} from '@wayapay/react-native';

try {
  await sdk.wallet.withdraw(request);
} catch (e) {
  if (e instanceof WayaPayValidationException) {
    // e.message — show it next to the form. e.code if the backend sent one.
  } else if (e instanceof WayaPaySessionExpiredException) {
    // route to login — token refresh already failed
  } else if (e instanceof WayaPayNetworkException) {
    // no connectivity / timeout — show "check your connection" + retry
  } else if (e instanceof WayaPayServerException) {
    // 5xx — show a generic error. e.statusCode for diagnostics.
  }
}

Register onSessionExpired once at startup instead of catching WayaPaySessionExpiredException everywhere just to redirect:

TypeScript
await WayaPaySdk.initialize({
  environment: Environment.staging,
  clientId: 'MY_APP',
  tokenStorage: new SecureTokenStorage(),
  onSessionExpired: async () => {
    navigationRef.current?.reset({ index: 0, routes: [{ name: 'Login' }] });
  },
});

This fires only when a refresh attempt is genuinely rejected by the backend. A dropped connection during a refresh attempt surfaces as WayaPayNetworkException on that one call instead — it does not sign the merchant out, since a network blip isn't the same thing as an invalid session.

#Wallet

TypeScript
const balance = await sdk.wallet.balance(); // .balance, .totalWithdrawn
const page = await sdk.wallet.transactions({ page: 0, size: 20 });
await sdk.wallet.withdraw({
  accountName: 'Ada Obi', accountNumber: '0123456789',
  bankCode: '058', bankName: 'GTBank',
  amount: '50000', transactionPin: '1234', // the merchant's WayaPay PIN, not their login password
});
const history = await sdk.wallet.withdrawalHistory(); // plain array, no reliable backend total

#Customers

Used as a buyer/recipient picker when creating invoices and payment links.

TypeScript
const customer = await sdk.customers.create({
  firstName: 'Ada', lastName: 'Obi',
  email: 'ada@example.com', phoneNumber: '+2348012345678',
});
const page = await sdk.customers.list({ search: 'ada' });
await sdk.customers.setAvoidance(customer.customerId!, true); // block this customer from future payments

email and phoneNumber are required here even though the backend's own schema marks them optional — omitting either throws an unhandled server error instead of a clean validation message, so the SDK requires both up front to make that mistake impossible.

#Disputes

TypeScript
await sdk.disputes.create({
  disputeType: 'CHARGEBACK', // one of CHARGEBACK, AUTHCOMPLAINT, FRAUD, OTHERS
  reasonForDisputeInDetails: 'I did not authorize this.',
  disputeAmount: 25000, transactionCharge: 0, transactionDate: '2026-07-30',
});
const myDisputes = await sdk.disputes.list();

#Business KYC — the "can this merchant transact?" gate

Nothing money-related works until this is approved. Gate your app's navigation on status.approvalStatus === ApprovalStatus.approved, not just on being logged in.

The real flow is three steps — business details, then directors/shareholders, then certificates — plus a separate BVN verification. Each step can be saved as a draft repeatedly and submitted independently:

TypeScript
import { ApprovalStatus, approvalStatusRequiresAttention, KycBusinessType, KycRegistrationType } from '@wayapay/react-native';

const status = await sdk.kyc.status();
// status.approvalStatus, plus status.businessStepStatus / .directorStepStatus / .certificatesStepStatus

if (approvalStatusRequiresAttention(status.approvalStatus)) {
  const industries = await sdk.kyc.industries(); // lookup list for businessIndustry

  const logo = await sdk.kyc.uploadDocument({ bytes: logoBytes, fileName: 'logo.png' });

  await sdk.kyc.saveBusinessStep({
    businessName: 'Obi Foods',
    businessType: KycBusinessType.registered,
    businessRegistrationType: KycRegistrationType.incorporatedCompany,
    businessLogoUrl: logo.url,
  }, true); // submit: true

  await sdk.kyc.saveDirectorStep(
    [{ firstName: 'Ada', lastName: 'Obi', ninNumber: 12345678901, bvnNumber: 22152763963 }],
    true,
  );

  const certUrl = await sdk.kyc.uploadDocument({ bytes: certBytes, fileName: 'cac.jpg' });
  await sdk.kyc.saveCertificatesStep({
    incorporationCertificateUrl: certUrl.url, tin: '123456789',
  }, true);

  await sdk.kyc.finalSubmit();
  // ...poll status() until approvalStatus is approved or rejected
}

The submit boolean (second argument on each step method) marks that individual step as submitted for review instead of leaving it a draft — mirrors a real form's per-step "Save" vs "Submit". finalSubmit() only makes sense once all three steps are complete, and moves the overall record from draft/submitted to pending review.

BVN verification is a separate two-call flow:

TypeScript
const otpTarget = await sdk.kyc.verifyBvn('22152763963'); // sends an OTP, may return a masked phone
await sdk.kyc.verifyBvnOtp({ otp: '123456', phoneNumber: (otpTarget.phoneNumber as string) ?? '08012345678' });

A simpler, legacy single-call draft/submit pair (kyc.saveDraft() / kyc.submit()) still exists for integrations that don't need the step-by-step UX, but it doesn't drive the per-step statuses above — prefer the three step methods for anything matching a real onboarding experience.

#Uploading documents

kyc.uploadDocument() takes raw bytes, not a file path — read the file first (e.g. with react-native-fs or whatever your image/document picker already gives you) and pass a Uint8Array:

TypeScript
const result = await sdk.kyc.uploadDocument({ bytes: fileBytes, fileName: 'logo.png' });
console.log(result.url); // feed this into saveBusinessStep / saveDirectorStep / saveCertificatesStep

This is the SDK's only multipart (FormData) request — everything else is plain JSON. A 401 mid-upload is retried transparently like any other request; a JS FormData can safely be resent, unlike some other HTTP client ecosystems' multipart types.

#Pagination

The backend uses three different pagination shapes across its endpoints; every list method in this SDK normalizes to the same PagedResult<T> (items, page, pageSize, total) regardless of which shape is underneath — you never need to special-case an endpoint.

#Logging

TypeScript
await WayaPaySdk.initialize({
  environment: Environment.staging,
  clientId: 'MY_APP',
  tokenStorage: new SecureTokenStorage(),
  enableLogging: true, // best-effort — see below
});

Request/response traffic prints to the console when enableLogging is on. There's no compile-time constant that universally works across JS bundlers to gate this automatically — isDebugBuild() checks React Native's __DEV__ global first, then falls back to process.env.NODE_ENV. Treat enableLogging as a convenience, not a guarantee: pass enableLogging: false explicitly for production builds if you want to be certain. Password/OTP/API-secret-key body fields are redacted (***) at any nesting depth regardless.

#Testing code that uses this SDK

The domain clients aren't singletons — construct them directly in a test with a fake TokenStorage and an axios instance wired to axios-mock-adapter.

#Configuration reference

TypeScript
await WayaPaySdk.initialize({
  environment: Environment.staging,       // or Environment.prod — required
  clientId: 'MY_APP',                     // required, identifies the calling app
  clientType: 'CORPORATE',                // default
  tokenStorage: new SecureTokenStorage(), // optional, defaults to an in-memory store
  onSessionExpired: async () => { ... },  // optional
  enableLogging: true,                    // optional
  timeoutMs: 30_000,                      // optional, applied to every request
});

WayaPaySdk.isInitialized; // boolean, check before instance if you want to avoid the throw

#Good to know

A few places where the backend's documented contract diverges from what actually happens, worth knowing before you hit them yourself:

disputeType only accepts four real values: CHARGEBACK, AUTHCOMPLAINT, FRAUD, OTHERS — anything else is rejected.

Virtual accounts come in more than one shape. A MAIN wallet has a real bank accountNumber; a COLLECTION wallet only has a walletNumber instead. Use whichever field is present rather than assuming accountNumber is always populated.