Go to file
Joseph Le e6cecef60e Update link 2026-07-02 16:12:08 +10:00
data first commit 2026-07-02 10:31:13 +07:00
public Update link 2026-07-02 16:12:08 +10:00
scripts first commit 2026-07-02 10:31:13 +07:00
.env.example first commit 2026-07-02 10:31:13 +07:00
.gitignore Update link 2026-07-02 16:12:08 +10:00
README.md first commit 2026-07-02 10:31:13 +07:00
db.js first commit 2026-07-02 10:31:13 +07:00
package-lock.json first commit 2026-07-02 10:31:13 +07:00
package.json first commit 2026-07-02 10:31:13 +07:00
payment-api.js first commit 2026-07-02 10:31:13 +07:00
server.js Update link 2026-07-02 16:12:08 +10:00

README.md

Quick Payment

Server HTML đơn giản để tạo payment link và lưu lịch sử bằng SQLite.

Chạy

npm install
npm start        # hoặc: npm run dev  (auto-reload)

Mở http://localhost:3000

  1. Copy .env.example thành .env.
  2. Điền PAYMENT_API_URLPAYMENT_API_KEY.
  3. Mở payment-api.js và chỉnh 2 chỗ có đánh dấu TODO:
    • Request body — map dữ liệu form sang đúng field API mong đợi.
    • Response — lấy đúng field chứa payment link trả về.

Nếu chưa cấu hình PAYMENT_API_URL, server chạy chế độ mock: trả về link demo để test luồng UI + lưu lịch sử. Ghép API thật sau bằng cách sửa payment-api.js.

Cấu trúc

File Vai trò
server.js Express server + REST endpoints
payment-api.js Adapter gọi API payment — nơi duy nhất cần sửa khi ghép API thật
db.js SQLite (better-sqlite3), bảng payments
public/ Frontend (form + bảng items + lịch sử)
data/payments.db File database (tự tạo)

API nội bộ

  • POST /api/payments — tạo payment link, lưu lịch sử, trả { link, payment }.
  • GET /api/payments — danh sách lịch sử (mới nhất trước).