Payment Gateway
api_payment is the centralized payment gateway of Bot Ban Hang, integrating multiple payment platforms through a unified SDK pattern.
Supported platforms
| Platform | Folder | Description |
|---|---|---|
| MoMo | services/payment/momo/ | MoMo e-wallet |
| ZaloPay | services/payment/zalopay/ | ZaloPay e-wallet |
| VNPay | services/payment/vnpay/ | VNPay payment gateway |
| Stripe | services/payment/stripe/ | International payments |
| Square | services/payment/square/ | POS |
| MPOS | services/payment/mpos/ | Mobile POS |
| SePay | services/payment/sepay/ | Automatic bank transfer |
| Bank transfer | services/payment/transfer/ | Bank |
| Cash | services/payment/cash/ | COD |
SDK Pattern
Each platform SDK follows a common interface:
$PAYMENT.createTransaction(params)
$PAYMENT.queryTransaction(params)
$PAYMENT.refundTransaction(params)
$PAYMENT.handleWebhook(params)
Folder structure
services/payment/
├── core/ # Shared abstraction, factory, logger
├── momo/
│ ├── index.ts # Main code
│ ├── provider.ts # Adapter to common payment contract
│ ├── example.ts # Sample data
│ ├── index.spec.ts # Service tests
│ ├── provider.spec.ts # Provider tests
│ └── document.md # Flow documentation
├── zalopay/
├── vnpay/
├── stripe/
├── square/
├── mpos/
├── sepay/
├── transfer/
└── cash/
API Modules
api/transaction/— Transaction CRUDapi/webhook/— Receive callbacks from payment gatewaysapi/setting/— Platform configuration for merchantsapi/public/— Public APIapi/private/— Internal API