npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@codepunter-labs/mock-payaza

v0.2.0

Published

TODO

Readme

@codepunter-labs/mock-payaza

Mock SDK for Payaza API. Provides fully-typed mock implementations for testing Payaza integrations without making real API calls.

npm version GitHub

Installation

npm install @codepunter-labs/mock-payaza

Features

  • Transfers: Initiate transfers, query transaction status
  • Account Enquiry: Verify account names and bank details
  • Bank Codes: Retrieve list of supported banks
  • Payaza Account: View account details and balance
  • Subaccounts: Create and manage subaccounts
  • Type-safe: Full TypeScript support with accurate API types
  • Test Framework Agnostic: Works with Jest, Vitest, and other spy-based frameworks

Repository

  • GitHub: https://github.com/DERRICK-TORKORNOO/mock-sdks/tree/main/packages/mock-payaza
  • Source Code: src/
  • Tests: tests/

Usage

Basic Setup

import { vi } from 'vitest';
import { createMockPayaza } from '@codepunter-labs/mock-payaza';

const payaza = createMockPayaza({ spy: vi.fn });

Using with Jest

import { createMockPayaza } from '@codepunter-labs/mock-payaza';

const payaza = createMockPayaza({ spy: jest.fn });

Example: Transfer

// Default behavior - returns realistic mock data
const result = await payaza.initiateTransfer({
  transaction_type: 'nuban',
  service_payload: {
    payout_amount: 100,
    transaction_pin: 419374,
    account_reference: '1010000009',
    currency: 'NGN',
    country: 'NGA',
    payout_beneficiaries: [
      {
        credit_amount: 100,
        account_number: '9207067319',
        account_name: 'John Doe',
        bank_code: '000013',
        narration: 'Test',
        transaction_reference: 'TD93001234',
        sender: {
          sender_name: 'Jane Doe',
          sender_id: '',
          sender_phone_number: '01234595',
          sender_address: '123, Ace Street'
        }
      }
    ]
  }
});

Example: Override Mock Response

import { makeTransferResponse } from '@codepunter-labs/mock-payaza';

payaza.initiateTransfer.mockResolvedValue({
  response_code: 200,
  response_message: 'Request successfully submitted',
  response_content: makeTransferResponse({ amount: 5000 })
});

Example: Account Enquiry

const result = await payaza.accountNameEnquiry({
  account_number: '9207067319',
  bank_code: '000013',
  currency: 'NGN'
});

Example: Error Simulation

import { PayazaErrors } from '@codepunter-labs/mock-payaza';

payaza.initiateTransfer.mockRejectedValue(
  PayazaErrors.insufficientBalance()
);

API Reference

MockPayaza

| Method | Description | Source | |--------|-------------|--------| | initiateTransfer(request) | Initiate a transfer | mock-payaza.ts | | queryTransactionStatus(transactionReference) | Query transaction status | mock-payaza.ts | | accountNameEnquiry(request) | Verify account name | mock-payaza.ts | | getBankCodes(currencyCode) | Get list of banks | mock-payaza.ts | | getPayazaAccountDetails() | Get account details | mock-payaza.ts | | createSubaccount(request) | Create subaccount | mock-payaza.ts | | getSubaccountDetails(payazaSubAccountReference) | Get subaccount details | mock-payaza.ts |

Fixture Factories

| Factory | Description | Source | |---------|-------------|--------| | makeTransferResponse(options?) | Create transfer response | fixtures.ts | | makeBulkTransferResponse(options?) | Create bulk transfer response | fixtures.ts | | makeTransactionData(options?) | Create transaction data | fixtures.ts | | makeAccountEnquiryResponse(options?) | Create account enquiry response | fixtures.ts | | makeBank(options?) | Create bank object | fixtures.ts | | makePayazaAccountDetails(options?) | Create account details | fixtures.ts | | makeSubaccount(options?) | Create subaccount | fixtures.ts | | makeSender(options?) | Create sender object | fixtures.ts | | makePayoutBeneficiary(options?) | Create payout beneficiary | fixtures.ts |

Error Factories

| Error | Description | Source | |-------|-------------|--------| | PayazaErrors.unauthorized() | Unauthorized error | errors.ts | | PayazaErrors.invalidAccountNumber() | Invalid account number error | errors.ts | | PayazaErrors.insufficientBalance() | Insufficient balance error | errors.ts | | PayazaErrors.transferFailed() | Transfer failed error | errors.ts |

Testing Patterns

Test Success Path

test('should initiate transfer successfully', async () => {
  const payaza = createMockPayaza({ spy: vi.fn });
  
  const result = await payaza.initiateTransfer(request);
  
  expect(result.response_code).toBe(200);
  expect(result.response_message).toBe('Request successfully submitted');
});

Test Error Handling

test('should handle insufficient balance error', async () => {
  const payaza = createMockPayaza({ spy: vi.fn });
  
  payaza.initiateTransfer.mockRejectedValue(
    PayazaErrors.insufficientBalance()
  );
  
  await expect(payaza.initiateTransfer(request)).rejects.toMatchObject({ response_code: 400 });
});

Test with Custom Data

test('should use custom transfer amount', async () => {
  const payaza = createMockPayaza({ spy: vi.fn });
  
  payaza.initiateTransfer.mockResolvedValue({
    response_code: 200,
    response_message: 'Request successfully submitted',
    response_content: makeTransferResponse({ amount: 10000 })
  });
  
  const result = await payaza.initiateTransfer(request);
  expect(result.response_content.amount).toBe(10000);
});

License

MIT