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

payway-ts

v0.1.5

Published

A non-official TypeScript SDK for ABA PayWay

Readme

payway-ts

TypeScript SDK for ABA PayWay payment integration - Supports both client-side form submission and server-to-server API calls

npm version License: MIT

An unofficial, type-safe TypeScript SDK for ABA PayWay payment integration. This SDK provides two integration patterns:

  1. Payload Builder - Build signed payloads for client-side form submission (recommended for abapay)
  2. Server-to-Server - Execute API calls directly from your server (for other payment options)

[!WARNING]
This is not a product of ABA Bank. This is an unofficial implementation based on https://www.payway.com.kh/developers/

Credits

This package is built upon and inspired by the excellent work of Seanghay Yath and the original payway-js package. We've extended it with:

  • Full TypeScript support with comprehensive type definitions
  • Pre-Authorization transactions (complete, cancel, with payout)
  • RSA encryption for sensitive operations
  • Dual integration patterns (payload builder + execute)
  • Enhanced error handling with detailed API responses
  • Extensive documentation and examples

Special thanks to the original contributors for laying the foundation!

Features

Core Features (from original payway-js)

  • Create transactions
  • Check transaction status
  • List transactions
  • HMAC-SHA512 request signing

New Features in payway-ts

  • Full TypeScript Support - Complete type definitions with autocomplete
  • Pre-Authorization Transactions - Complete, cancel, and payout support with RSA encryption
  • Dual Integration Modes - Client-side form submission OR server-to-server API calls
  • Enhanced Error Handling - Detailed API error responses with status codes and bodies
  • RSA Encryption - Secure data encryption for sensitive operations (117-byte chunking)
  • Server-Side Security - Build payloads securely on your server (Node.js 18+)
  • ES Modules - Native ESM support
  • Minimal Dependencies - Only date-fns for date formatting
  • Next.js Ready - Works seamlessly with Next.js API routes
  • Smart Validation - Prevents common mistakes (e.g., using abapay with server-to-server)

Installation

npm install payway-ts

Requirements

  • Node.js 18.0.0 or higher
  • ABA Bank merchant account with API credentials

Quick Start

Pattern 1: Client-Side Form Submission (for abapay)

Use this when the browser needs to submit directly to ABA PayWay.

// Server: Build signed payload
import { PayWayClient } from 'payway-ts';

const client = new PayWayClient(
  process.env.PAYWAY_BASE_URL!,
  process.env.PAYWAY_MERCHANT_ID!,
  process.env.PAYWAY_API_KEY!
);

const payload = client.buildTransactionPayload({
  amount: 100,
  tran_id: 'ORDER-123',
  payment_option: 'abapay',
  return_url: 'https://yoursite.com/callback'
});

// Send payload to client
return Response.json(payload);
// Client: Create and submit form
const form = document.createElement('form');
form.method = payload.method;
form.action = payload.url;

for (const [key, value] of Object.entries(payload.fields)) {
  const input = document.createElement('input');
  input.type = 'hidden';
  input.name = key;
  input.value = String(value);
  form.appendChild(input);
}

document.body.appendChild(form);
form.submit();

See detailed guide →

Pattern 2: Server-to-Server (for other payment options)

Use this when your server communicates directly with the ABA API.

import { PayWayClient } from 'payway-ts';

const client = new PayWayClient(
  process.env.PAYWAY_BASE_URL!,
  process.env.PAYWAY_MERCHANT_ID!,
  process.env.PAYWAY_API_KEY!
);

// Create transaction
const result = await client.execute(
  client.buildTransactionPayload({
    amount: 100,
    tran_id: 'ORDER-123',
    payment_option: 'cards',  // NOT 'abapay'
    return_url: 'https://yoursite.com/callback'
  })
);

// Check transaction status
const status = await client.execute(
  client.buildCheckTransactionPayload('ORDER-123')
);

// List transactions
const transactions = await client.execute(
  client.buildTransactionListPayload({
    from_date: '20240101000000',
    to_date: '20240131235959'
  })
);

See detailed guide →

Documentation

Comprehensive guides for every use case:

Environment Variables

Create a .env.local file:

# Sandbox
PAYWAY_BASE_URL=https://checkout-sandbox.payway.com.kh/
PAYWAY_MERCHANT_ID=your_sandbox_merchant_id
PAYWAY_API_KEY=your_sandbox_api_key

# Production
# PAYWAY_BASE_URL=https://checkout.payway.com.kh/
# PAYWAY_MERCHANT_ID=your_production_merchant_id
# PAYWAY_API_KEY=your_production_api_key

# Optional: For pre-authorization
# ABA_RSA_PUBLIC_KEY=your_rsa_public_key

NEXT_PUBLIC_APP_URL=https://yoursite.com

TypeScript Support

All methods are fully typed:

import type { 
  PayWayClient,
  CreateTransactionParams,
  PayloadBuilderResponse,
  TransactionStatus,
  PaymentOption,
  ExecuteOptions,
  CompletePreAuthParams,
  CompletePreAuthWithPayoutParams,
  CancelPreAuthParams,
  PreAuthResponse,
  PayWayAPIError
} from 'payway-ts';

const params: CreateTransactionParams = {
  amount: 100,
  tran_id: 'ORDER-123',
  currency: 'USD',
  payment_option: 'abapay'
};

const payload: PayloadBuilderResponse = client.buildTransactionPayload(params);

Testing

npm test
npm run test:coverage

Building

npm run build
npm run typecheck

License

MIT License - see LICENSE file for details

Disclaimer

This is an unofficial SDK and is not affiliated with or endorsed by ABA Bank. Use at your own risk.

For ABA PayWay API documentation and support, please contact ABA Bank directly or visit https://www.payway.com.kh/developers/

Author

tykealy

Links