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.
npm install @abapayway/nodeRequires Node.js 18+.
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);| 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 |
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,
});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");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 });
});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 | Base URL |
|---|---|
| Sandbox | https://checkout-sandbox.ababank.com |
| Production | https://checkout.payway.com.kh |
- Security & network access — why Socket/supply-chain tools flag
fetch - PayWay Developer Suite
- API Endpoints
- Ecommerce Checkout
See CONTRIBUTING.md.
MIT — unofficial community SDK, not affiliated with ABA Bank.