sinhsac.github.io / auto-payment

Auto Payment

Self-hosted, zero-fee automated bank transfer checkout built with Nuxt 4, Vue 3, and Nitro Server Routes — paired with auto-payment-android for instant SSE confirmation.

Nuxt 4.7 · Vue 3.5 Node.js 22+ Offline EMVCo / NAPAS 247 QR Real-Time SSE MIT License
Auto Payment End-to-End Walkthrough

How the Zero-Fee Architecture Works

Instead of paying percentage fees to third-party payment gateways, Auto Payment connects your own web checkout directly to bank push notifications arriving on your Android phone:

1

Create Order & Local QR

The Nuxt server assigns a unique reference code (e.g. AP123456) and renders an offline EMVCo / NAPAS 247 QR code locally using server/utils/bankQr.ts with exact amount & CRC-16.

2

Android Listens to Bank Alerts

auto-payment-android reads incoming bank/wallet notifications, matches the order code & credit amount, and posts to POST /api/webhooks/bank-notify.

3

Instant SSE Order Confirmation

The server verifies the order code and amount, marks the order PAID (or UNDERPAID on partial transfers), and pushes an instant SSE event to the buyer's browser.

Screenshots & Walkthrough

Storefront and Product Catalog
1. Storefront & Built-in Demo Product Catalog
Real-Time Payment QR and SSE Listener
2. Offline EMVCo Transfer QR & Live SSE Listener
Auto-Confirmed Order Receipt
3. Auto-Confirmed Order Receipt (/orders/:code)
Admin Dashboard and Webhook Simulator
4. Admin Dashboard, Manual Fallback & Webhook Tester

Key Capabilities

  • Offline EMVCo / NAPAS 247 QR Generator: Zero external QR API dependencies — builds CRC-16/CCITT-FALSE validated QR payloads directly on your server.
  • 12 Supported Vietnamese Banks & Wallets: Parses credit alerts from Vietcombank, Techcombank, MBBank, VPBank, BIDV, ACB, TPBank, VietinBank, Sacombank, Timo, MoMo, and ZaloPay.
  • Debit & Duplicate Protection: Automatically rejects outgoing debits (-150,000VND), deduplicates repeated notifications idempotently, and tracks partial payments (UNDERPAID) until paid in full.
  • Zero-Config Persistence + Optional Elasticsearch: Ships with 12 demo products and atomic JSON persistence (data/store.json) out of the box; switches to Elasticsearch automatically when NUXT_ELASTICSEARCH_BASE_URL and NUXT_ELASTICSEARCH_TOKEN are provided.
  • Admin Dashboard (/admin): Live revenue KPIs, filterable order table, manual staff approval/cancellation fallback, webhook audit logs, and an interactive webhook simulator.

Quick Start (Local Development)

git clone https://github.com/sinhsac/auto-payment.git
cd auto-payment
npm install
npm run dev

Open http://localhost:3000 in your browser:

  1. Add any product to the cart and proceed to checkout.
  2. Fill in customer info, select QR Auto Transfer, and place the order.
  3. On /orders/APxxxxxx, scan the QR code or click the built-in simulator button to watch the screen auto-confirm via SSE.
  4. Open http://localhost:3000/admin to monitor revenue KPIs, order states, and webhook audit logs.

Bank Account & Webhook Configuration

Copy local.env to .env and set your bank credentials and webhook secret:

NUXT_BANK_BIN=970436
NUXT_BANK_NAME=Vietcombank
NUXT_BANK_ACCOUNT_NO=0123456789
NUXT_BANK_ACCOUNT_NAME=YOUR ACCOUNT NAME
NUXT_ORDER_PREFIX=AP
NUXT_ORDER_EXPIRY_MINUTES=15

NUXT_PUBLIC_BANK_NAME=Vietcombank
NUXT_PUBLIC_BANK_ACCOUNT_NO=0123456789
NUXT_PUBLIC_BANK_ACCOUNT_NAME=YOUR ACCOUNT NAME

# Recommended in production:
NUXT_WEBHOOK_SECRET=replace-with-a-strong-random-secret
NUXT_PUBLIC_ENABLE_DEMO_SIMULATOR=false
Production Hardening

Always set a strong NUXT_WEBHOOK_SECRET (verified in constant time via X-Webhook-Secret or Authorization: Bearer) and set NUXT_PUBLIC_ENABLE_DEMO_SIMULATOR=false before exposing the site publicly.

Connecting auto-payment-android

Configure PushingWorker.kt inside auto-payment-android to POST incoming bank notifications to:

POST https://your-domain.com/api/webhooks/bank-notify
Android Integration Guide Screen
Built-in Android Webhook Integration Reference inside /admin

Test the Webhook with curl

curl -X POST http://localhost:3000/api/webhooks/bank-notify \
  -H "Content-Type: application/json" \
  -H "X-Webhook-Secret: your-secret" \
  -d '{
    "groupKey": "0|com.VCB|123",
    "strPostTime": "2026-11-27 17:30:00",
    "title": "Vietcombank",
    "msg": "SD TK 0123456789 +150,000VND luc 27/11/2026. ND: AP123456",
    "pck": "com.VCB"
  }'

API Reference

Method Endpoint Description
GET/api/categoriesLists product categories (Elasticsearch or built-in demo catalog).
GET/api/categories/:idReturns a single category by catid.
GET/api/productsLists/filters products by category, q, and lastId.
POST/api/ordersCreates a new order (qr, bank_transfer, or cod) with offline bank QR.
GET/api/ordersLists orders (?status=, ?q=) and summary KPIs for /admin.
GET/api/orders/:codeReturns live order state (auto-expires unpaid QR orders past deadline).
GET/api/orders/:code/streamServer-Sent Events (SSE) stream pushing instant payment updates.
POST/api/orders/:code/actionManual staff confirmation (confirm_by_staff) or cancellation (cancel).
GET/api/healthHealth check for server monitoring and Android connectivity verification.
POST/api/webhooks/bank-notifyReceives auto-payment-android XInfo or generic JSON bank credit webhooks.
GET/api/webhooks/logsReturns recent webhook audit logs and matching outcomes.

Testing & Production Deployment

# Run automated unit & integration tests (EMVCo CRC16, bank parser, OrderStore)
npm test

# Build production Nitro bundle
npm run build

# Start production server directly
node .output/server/index.mjs

# Or run under PM2 (port 3030)
pm2 start ecosystem.config.cjs