Sepay
Sepay là cổng thanh toán QR banking với webhook thời gian thực, cho phép xác nhận thanh toán tức thì.
Đăng ký tài khoản
-
Truy cập website
-
Đăng ký tài khoản
- Click “Đăng ký”
- Điền thông tin và xác minh email
-
Liên kết ngân hàng
- Vào Tài khoản → Ngân hàng
- Thêm tài khoản ngân hàng
- Xác minh bằng chuyển khoản test
-
Lấy API Key
- Vào API → Thông tin API
- Copy API Key
-
Cấu hình webhook
- Vào API → Webhook
- Nhập URL:
http://your-server-ip:8080/webhook/sepay - Nhập Webhook API Key (tự tạo, dùng cho xác thực)
- Lưu cấu hình
Cấu hình plugin
File: plugins/SimpPay/banking/sepay-config.yml
# SimpPay @ 2026# Made by typical.smc
enabled: true
# API Key từ Sepay dashboardapi-key: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
# Bank account infoaccount-number: "1234567890"account-name: "NGUYEN VAN A"bank-code: "VCB"
# Webhook settingswebhook-port: 8080webhook-path: "/webhook/sepay"webhook-api-key: "your_webhook_secret_key_here"
# Amount limitsmin-amount: 10000max-amount: 50000000Chi tiết cấu hình
api-key
- Kiểu:
string - Bắt buộc: Có
- Mô tả: API Key từ Sepay dashboard
Lấy từ: Sepay Dashboard → API → Thông tin API
account-number / account-name / bank-code
- Kiểu:
string - Bắt buộc: Có
- Mô tả: Thông tin tài khoản ngân hàng nhận tiền
Phải khớp với tài khoản đã liên kết trên Sepay.
webhook-port
- Kiểu:
integer - Mặc định:
8080 - Mô tả: Port cho HTTP webhook server
Plugin sẽ tạo HTTP server lắng nghe trên port này.
Lưu ý:
- Port phải được mở trên firewall
- Không được dùng bởi service khác
- Khuyến nghị:
8080,8081,9000
webhook-path
- Kiểu:
string - Mặc định:
"/webhook/sepay" - Mô tả: Đường dẫn endpoint webhook
Full URL sẽ là: http://your-server-ip:8080/webhook/sepay
webhook-api-key
- Kiểu:
string - Bắt buộc: Có
- Mô tả: API Key để xác thực webhook requests
Tự tạo một key bất kỳ (ví dụ: UUID) và cấu hình cả trong:
- Plugin config (
webhook-api-key) - Sepay dashboard (Webhook API Key)
Setup Webhook
-
Mở port trên firewall
Windows:
Terminal window netsh advfirewall firewall add rule name="SimpPay Webhook" dir=in action=allow protocol=TCP localport=8080Linux:
Terminal window sudo ufw allow 8080/tcp -
Kiểm tra IP public
Truy cập https://whatismyipaddress.com để lấy IP public.
-
Cấu hình webhook trên Sepay
- URL:
http://YOUR_PUBLIC_IP:8080/webhook/sepay - Webhook API Key: Copy từ
webhook-api-keytrong config - Lưu cấu hình
- URL:
-
Test webhook
Sepay dashboard có nút “Test Webhook”. Click để test.
-
Kiểm tra console
[SimpPay] WebhookService: HTTP server started on port 8080[SimpPay] WebhookService: Webhook endpoint: /webhook/sepay[SimpPay] [DEBUG] SepayWebhookListener: Received webhook from Sepay[SimpPay] [DEBUG] SepayWebhookListener: Validated webhook signature
Webhook Flow
-
Người chơi chuyển khoản
Quét QR và chuyển khoản qua app ngân hàng
-
Sepay nhận tiền
Sepay phát hiện giao dịch mới trong tài khoản
-
Sepay gửi webhook
POST http://your-server:8080/webhook/sepayAuthorization: Apikey your_webhook_api_keyContent-Type: application/json{"id": 123456,"gateway": "VCB","transaction_date": "2026-02-14 10:30:00","account_number": "1234567890","sub_account": null,"amount_in": 50000,"amount_out": 0,"accumulated": 1000000,"code": "FT12345678","transaction_content": "SP-1234567890","reference_number": "FT12345678","body": "..."} -
Plugin xử lý
- Validate webhook API key
- Parse transaction content để lấy order ID
- Fire
SepayWebhookReceivedEvent - Award coins cho người chơi
-
Người chơi nhận coins
Tức thì (< 1 giây)
API Endpoints
Create QR Code
POST https://my.sepay.vn/userapi/transactions/create-qrRequest:
{ "account_number": "1234567890", "account_name": "NGUYEN VAN A", "amount": 50000, "description": "SP-1234567890"}Response:
{ "status": 200, "messages": "Thành công", "data": { "qr_code": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA..." }}Webhook Security
Plugin xác thực webhook bằng Authorization header:
Authorization: Apikey your_webhook_api_keyNếu header không khớp với webhook-api-key trong config, request bị từ chối với 403 Forbidden.
Testing
-
Bật debug mode
main-config.yml:debug: true -
Reload plugin
/simppayadmin reload -
Kiểm tra webhook server
Console sẽ hiển thị:
[SimpPay] WebhookService: HTTP server started on port 8080[SimpPay] WebhookService: Webhook endpoint: /webhook/sepay -
Test webhook từ Sepay
Vào Sepay Dashboard → API → Webhook → Click “Test Webhook”
-
Kiểm tra console
[SimpPay] [DEBUG] SepayWebhookListener: Received webhook[SimpPay] [DEBUG] SepayWebhookListener: Transaction content: SP-1234567890[SimpPay] [DEBUG] SepayWebhookListener: Found payment for order SP-1234567890[SimpPay] [DEBUG] PaymentSuccessEvent fired -
Test thanh toán thật
/bank 50000Quét QR và chuyển khoản. Coins sẽ được cộng tức thì.
Troubleshooting
Webhook không nhận được
Webhook bị từ chối (403)
QR code không hiển thị
Port already in use
Performance
Sepay webhook sử dụng virtual threads (Java 21+) cho hiệu suất cao:
- Xử lý hàng trăm webhooks đồng thời
- Không block main thread
- Latency < 100ms
Best practices
-
Dùng domain thay vì IP: Nếu có domain, dùng
https://yourdomain.com/webhook/sepaythay vì IP -
SSL/TLS: Nếu có SSL cert, cấu hình HTTPS cho webhook (secure hơn)
-
Monitor webhook: Log tất cả webhook requests để troubleshoot
-
Backup gateway: Cấu hình PayOS làm backup khi Sepay down
-
Rate limiting: Sepay có rate limit, không spam API
So sánh với Polling
| Webhook (Sepay) | Polling (PayOS/Web2M) | |
|---|---|---|
| Tốc độ | < 1s | 5-30s |
| Tài nguyên | Thấp | Cao (nhiều API calls) |
| Setup | Khó (cần mở port) | Dễ |
| Reliability | Cao | Trung bình |
| Khuyến nghị | Server lớn | Server nhỏ/trung |
Xem thêm
- PayOS - Polling gateway
- Web2M - Alternative
- Cấu hình xu & phần thưởng