Documentation
Financial API Layer

Smart QR & Payments

Build Napas-compliant VietQR financial payment solutions. Render standard SVG/PNG codes with designer gradients, custom cell distributions, and branding.

01

Napas Payload Builder

Structure VietQR-compatible codes by supplying the target Bank BIN code, Account Number, Account Owner Name, and Transfer Amount.

napas.js
import { napas } from 'kitwork';

const payment = napas
    .bank("970415", "1234567890")  // Bank BIN & Account Number
    .amount(150000)                // Amount in VND
    .receiver("NGUYEN VAN A")      // Account Holder Name
    .info("Thanh toan nuoc");         // Description
02

Designer QR Customization

Build beautiful premium codes by configuring custom cell template layouts (e.g. circular, rounded), embedded brand logos, color gradients, and independent eye coordinates.

qrcode.js
import { qrcode } from 'kitwork';

const svgCode = qrcode
    .napas(payment)
    .template("circular")                // Dot pattern type
    .logo("vietqr")                    // Center brand logo overlay
    .cell({
        gradient: { type: "linear", colors: ["#0f172a", "#38bdf8"], angle: 45 }
    })
    // Override top-left finder with a separate red gradient
    .finder("tl", {
        stroke: "#be123c",
        rounded: 3.5,
        gradient: { type: "linear", colors: ["#e11d48", "#f43f5e"], angle: 90 }
    })
    .svg();                              // Render to SVG string
03

PNG & SVG Outputs

Render codes as highly scalable SVG markup (perfect for frontend displays) or binary PNG byte arrays (ideal for file servers or image responses).

response-type.js
// 1. Serve SVG string directly
router.get("/qr/vector").handle((res) => {
    const code = qrcode.napas(payment).svg();
    return res.svg(code);
});

// 2. Serve PNG bytes as image stream
router.get("/qr/raster").handle((res) => {
    const pngBytes = qrcode.napas(payment).size(400).png();
    return res.image(pngBytes);
});
04

Bank BIN Reference Table

Common Vietnamese bank codes required for structural Napas validation payloads.

Bank Name BIN Code Transfer Type
Vietcombank (VCB) 970436 Instant / Napas247
VietinBank (VTB) 970415 Instant / Napas247
Techcombank (TCB) 970407 Instant / Napas247
MBBank (MB) 970422 Instant / Napas247
BIDV 970418 Instant / Napas247
05

Dynamic Payment Tutorial

Build a dynamic checkout screen that accepts payment quantities via URL queries and generates payment vector codes on the fly.

checkout.js
router.get("/checkout").handle((req, res) => {
    const amount = req.query("amount").text() || "10000";

    const payPayload = napas
        .bank("970415", "123456789")
        .amount(amount)
        .info("Order payment");

    const qrSvg = qrcode.napas(payPayload).svg();
    return res.svg(qrSvg);
});