Public
SePay → Base44 webhook: auto top-up wallet
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.

SePay → Base44 Webhook

Webhook trung gian nhận giao dịch từ SePay, trích xuất email từ nội dung chuyển khoản, và tự động cộng tiền vào ví (wallet) người dùng trên Base44 Shop.

Flow

Rendering mermaid diagram...

Cách hoạt động

  1. Khách chuyển khoản với nội dung chứa email:
    • minhduongceo102@gmail.com → nhận diện trực tiếp
    • minhduongceo102gmailcom hoặc minhduongceo102gmail.com → tự thêm @
    • minhduongceo102 (chỉ username) → tự thêm @gmail.com
    • napvi minhduongceo102 → bỏ từ banking, giữ username
  2. SePay gửi webhook POST tới Val Town
  3. Webhook trích xuất email, validate số tiền, tìm user trên Base44, cộng số dư
  4. Chống trùng lặp bằng sepay_id

Cấu hình

Env vars cần thiết

KeyMô tả
BASE44_APP_IDApp ID từ Base44 (trong URL editor)
BASE44_ADMIN_EMAILEmail admin user
BASE44_ADMIN_PASSWORDPassword admin user

SePay Dashboard

  • Webhook URL: Copy endpoint URL của file webhook.ts
  • Phương thức: POST
  • Content Type: JSON
  • Sự kiện: Chỉ tiền vào (In only)

Files

FileMô tả
webhook.tsHTTP handler - entry point
handler.tsXử lý logic webhook
base44-client.tsKết nối Base44 API
utils.tsTrích xuất email + validate payload
test-utils.tsUnit tests cho email extraction

⚠️ Lưu ý quan trọng

Bạn cần kiểm tra tên entities trong Base44 app của mình. File base44-client.ts giả định:

  • Entity User có trường email
  • Entity Wallet có trường balanceuser_id
  • Entity Transaction có các trường user_id, wallet_id, amount, type, description, reference, sepay_id

Nếu tên khác, cần chỉnh sửa trong base44-client.ts.