Skip to content

abapayway/node

Repository files navigation

@abapayway/node

npm version License: MIT CI

Unofficial Node.js/TypeScript SDK for ABAPayWay — Cambodia's leading payment gateway by ABA Bank.

Zero runtime dependencies. Native fetch and Node.js crypto only.

Install

npm install @abapayway/node

Requires Node.js 18+.

Quick start

import { ABAPayWay, Currency, PaymentOption } from "@abapayway/node";

const payway = new ABAPayWay({
  merchantId: process.env.PAYWAY_MERCHANT_ID!,
  apiKey: process.env.PAYWAY_API_KEY!,
  sandbox: true,
});

const orderId = `ORDER-${Date.now()}`;

// Create checkout (returns HTML to render)
const { html } = await payway.checkout.create({
  orderId,
  amount: 10.5,
  currency: Currency.USD,
  paymentOption: PaymentOption.ABAPAY,
  returnUrl: "https://yoursite.com/payment/return",
  cancelUrl: "https://yoursite.com/payment/cancel",
});

// Check payment status (within 7 days of creation)
const status = await payway.checkout.checkTransaction(orderId);
console.log(status.data.payment_status);

Modules

Module Description
checkout Purchase, transaction details, close/check, list, exchange rates
transaction Lookup by merchant_ref (KHQR)
refund Full or partial refunds
webhook HMAC-SHA512 signature verification
credentials Link account/card, token payments, renew, remove
qr Generate payment QR codes
paymentLink Create and retrieve payment links
preAuth Create, complete, or cancel pre-authorizations
payout Funds routing and beneficiary management

Scheduled subscriptions

import { TokenType, SubscriptionFrequency } from "@abapayway/node";

// Register (CITR_FIX + frequency)
await payway.credentials.subscribe({
  ctid: "user-123",
  requestId: "sub-001",
  amount: 20,
  currency: Currency.USD,
  returnUrl: "https://yoursite.com/return",
  tokenFlag: TokenType.CITR_FIX,
  frequency: SubscriptionFrequency.MONTHLY,
});

// Bill each cycle (MITR_FIX)
await payway.credentials.chargeSubscription(token, {
  orderId: "bill-001",
  amount: 20,
  currency: Currency.USD,
  tokenType: TokenType.MITR_FIX,
});

Pre-authorization

const { html } = await payway.preAuth.create({
  orderId: "HOLD-001",
  amount: 100,
  currency: Currency.USD,
  returnUrl: "https://yoursite.com/return",
});

// Later: capture or cancel
await payway.preAuth.complete("HOLD-001", { amount: 100 });
await payway.preAuth.cancel("HOLD-001");

Webhook verification

app.post("/webhook", express.json(), (req, res) => {
  const signature = req.headers["x-payway-hmac-sha512"] as string;

  if (!payway.webhook.verify(req.body, signature)) {
    return res.status(401).send("Invalid signature");
  }

  // Process { tran_id, status, apv, return_params }
  res.json({ ok: true });
});

RSA-encrypted endpoints

Refund, pre-auth, payment link, and payout APIs require an RSA public key from PayWay:

const payway = new ABAPayWay({
  merchantId: "...",
  apiKey: "...",
  rsaPublicKey: process.env.PAYWAY_RSA_PUBLIC_KEY!,
  sandbox: true,
});

Environment URLs

Environment Base URL
Sandbox https://checkout-sandbox.ababank.com
Production https://checkout.payway.com.kh

Examples

Documentation

Contributing

See CONTRIBUTING.md.

License

MIT — unofficial community SDK, not affiliated with ABA Bank.

About

Unofficial Node.js / TypeScript SDK for ABAPayWay — Cambodia's leading payment gateway

Topics

Resources

License

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors