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 🙏

© 2025 – Pkg Stats / Ryan Hefner

aya-portal-merchant-api

v1.0.9

Published

MMQR, Master, Visa, JCB, MPU - Portal Integration Package

Readme

📘 AYA Portal Merchant API Integration Documentation (AGP)

A robust, dual-module (ESM and CJS) TypeScript SDK for interacting with the AYA Payment Merchant services. It provides methods for payment request, enquiry, service list retrieval, and callback verification.

📦 Installation

This package supports Node.js environments and is compatible with both import (ESM) and require (CJS) syntax.

npm install aya-merchant-api

🚀 Usage

1. Initialization

The SDK requires your merchant credentials (baseUrl, appKey, and secretKey) for initialization. I cannot disclose API links here for confidentiality reasons but please connect with AYA innovation team for api base URL.

import { AYAMerchantSDK, SDKOptions } from 'aya-merchant-api';

const options: SDKOptions = {
  baseUrl: 'https://api.example.com/payment', // Replace with actual base URL
  appKey: 'YOUR_APP_KEY',
  secretKey: 'YOUR_SECRET_KEY',
};

const merchantClient = AYAMerchantSDK(options);

// merchantClient is an instance of the AYAMerchant class

2. Loading Payment Methods (loadMethods)

Retrieves the list of available payment services. This endpoint is secured using a Checksum based on appKey, secretKey, and timestamp.

| Property | Type | Description | | :--- | :--- | :--- | | Request Payload | None (Generated Internally) | The SDK generates the timestamp and checkSum and sends the request body. | | Response Type | PaymentServiceResponse[] | An array of available payment services. |

PaymentServiceResponse Schema:

| Field | Type | Description | | :--- | :--- | :--- | | name | string | Display name of the service (e.g., "Visa/Master Card"). | | key | string | Unique key to be used in the createPayment method (e.g., "VISA"). | | image_url | string | URL for the service logo. | | methods | ('WEB' \| 'QR' \| 'NOTI')[] | Available transaction methods for this service. |

async function getMethods() {
  try {
    const methods = await merchantClient.loadMethods();
    console.log('Available Methods:', methods);
  } catch (error) {
    console.error(error);
  }
}

3. Creating a Payment Request (createPayment)

Initiates a payment transaction. The payload is sent as multipart/form-data. The SDK calculates and includes the checkSum automatically.

| Property | Type | Description | | :--- | :--- | :--- | | Request Payload | PaymentRequest | The required payment parameters. | | Response Type | PaymentResponse | The transaction result, including redirect or QR code URL. |

PaymentRequest Schema:

| Field | Type | Description | | :--- | :--- | :--- | | merchOrderId | string | Mandatory. Unique merchant order ID. | | amount | string | Mandatory. Transaction amount (e.g., "1000.00"). | | appKey | string | Mandatory. Your application key. | | timestamp | string | Mandatory. Current time in milliseconds. | | userRef1-userRef5 | string | Custom reference fields. | | description | string | A brief description of the order. | | currencyCode | string | Currency of the transaction (e.g., "MMK"). | | channel | string | Payment channel (e.g., "WEB"). | | method | string | Payment service key (e.g., "VISA" or key from loadMethods). | | overrideFrontendRedirectUrl | string | URL the user is redirected to after payment. |

PaymentResponse Schema:

| Field | Type | Description | | :--- | :--- | :--- | | success | boolean | true if payment request was successful (not status of payment). | | transactionId | string | Unique ID generated by the payment gateway. | | qrCodeUrl | string | URL for QR code (if method is QR-based). | | redirectUrl | string | URL to redirect the user for payment completion (if method is WEB-based). | | error | string | Error message if success is false. |

// Note: Interfaces are defined in src/index.ts and are auto-exported
const paymentPayload = {
  merchOrderId: 'ORD-' + Date.now(),
  amount: '1000.00',
  appKey: options.appKey,
  timestamp: Date.now().getTime(),
  userRef1: 'user-123',
  userRef2: 'ref-2',
  userRef3: 'ref-3',
  userRef4: 'ref-4',
  userRef5: 'ref-5',
  description: 'Product Purchase',
  currencyCode: 'MMK',
  channel: 'WEB', // or other valid channel
  method: 'VISA', // or other valid method key
  overrideFrontendRedirectUrl: 'https://your-site.com/callback',
  checkSum: '' // Checksum is generated internally by the SDK
};

async function initiatePayment() {
  try {
    const response = await merchantClient.createPayment(paymentPayload);
    console.log('Payment Response:', response);
  } catch (error) {
    console.error(error);
  }
}

4. Enquiry Payment Status (enquiryPayment)

Checks the final status of a transaction using the merchant order ID. The response payload is Base64 encoded and contains the full transaction details. The SDK handles decoding and parsing this payload automatically.

| Property | Type | Description | | :--- | :--- | :--- | | Request Payload | EnquiryRequest | Contains the merchOrderId for lookup. | | Response Type | EnquiryDecodedResponse | The decoded JSON object containing transaction status and details. |

EnquiryRequest Schema:

| Field | Type | Description | | :--- | :--- | :--- | | merchOrderId | string | The ID of the order to enquire about. |

EnquiryDecodedResponse Schema (Key Fields):

| Field | Type | Description | | :--- | :--- | :--- | | merchOrderId | string | Merchant's order ID. | | tranId | string | Gateway transaction ID. | | amount | string | Actual processed amount. | | statusCode | string | Final status code (e.g., "0000" for success). | | paymentCardNumber | string | Masked card number (if applicable). | | dateTime | string | Date and time of the transaction. |

async function checkStatus(orderId: string) {
  try {
    const enquiry = await merchantClient.enquiryPayment({ merchOrderId: orderId });
    console.log('Decoded Enquiry Data:', enquiry);
    // enquiry is of type EnquiryDecodedResponse
  } catch (error) {
    console.error(error);
  }
}

5. Verifying Callbacks (verifyCallback)

Verifies the integrity of a payment notification sent from the payment gateway to your callback URL.

| Property | Type | Description | | :--- | :--- | :--- | | Request Payload | CallbackRequest | The entire body received from the payment gateway. | | Response Type | boolean | true if the checkSum is valid (data integrity confirmed). |

CallbackRequest Schema:

| Field | Type | Description | | :--- | :--- | :--- | | payload | string | Base64 encoded JSON string containing transaction details. | | merchOrderId | string | Merchant's order ID. | | checkSum | string | Signature provided by the gateway for verification. |

// This data typically comes from the HTTP request body of the callback endpoint
async function handleCallback(callbackData: { payload: string, merchOrderId: string, checkSum: string }) {
  const isValid = await merchantClient.verifyCallback(callbackData);

  if (isValid) {
    console.log('Callback signature is valid. Processing payment update...');
    // Decode and process the payload if verification passes
    const decodedPayload = JSON.parse(Buffer.from(callbackData.payload, 'base64').toString('utf-8'));
    // Further logic to update database...
  } else {
    console.log('Callback signature is INVALID. Rejecting request.');
  }
}

🛠️ Developer Setup & Build

This project uses a TypeScript configuration designed for modern dual-module support.

Prerequisites

  • Node.js
  • TypeScript (package.json handles installation)

Build Commands

The build script executes a multi-step process to produce the necessary files for both CJS and ESM consumers:

| Output File | Module Type | Configuration | | :--- | :--- | :--- | | dist/index.js | ES Module (import) | tsconfig.json | | dist/index.cjs | CommonJS (require) | tsconfig.cjs.json | | dist/index.d.ts | TypeScript Definitions | tsconfig.json |

To build the project, run:

npm run build

This sequence ensures the CJS file is compiled, renamed, and then the final ESM and type definition files are generated.