How techhaha/mpay_v2 works
MPAY V2 is a multi-merchant payment platform. A business system submits a payment through the ePay or cashier APIs; the backend creates and routes payment orders to configured channels and plugins, then handles callbacks or queries, merchant notification, and—where applicable—settlement and account posting. Separate branches cover merchant/admin operations, refunds and transfers, receipt-watcher notifications, files, and recovery. The README documents these capabilities and the principal flow; sampled source confirms selected query, account, and storage behavior, but does not expose every runtime call path.
Main entry points: admin/controller Admin API · PayOrderService.php Order Runtime · PayOrderCallbackService.php Callback Lifecycle · mer/controller Merchant Portal
Components 25
API and Portals
- Payment APIs
app/http/api/controller/epay/EpayV2Controller.php - Cashier API
app/http/api/controller/cashier/CashierController.php - Admin API
app/http/admin/controller - Merchant Portal
app/http/mer/controller
Payment Runtime
- Order Runtime
app/service/payment/order/PayOrderService.php - Channel Routing
app/service/payment/order/PayOrderChannelDispatchService.php - Payment Plugins
app/common/payment - ePay Protocols
app/service/payment/epay/EpayV2ProtocolService.php - Callback Lifecycle
app/service/payment/order/PayOrderCallbackService.php
Funds and Orders
- Order Records
app/repository/payment/trade/PayOrderRepository.php - Refund Processing
app/service/payment/order/RefundDispatchService.php - Settlement
app/service/payment/settlement/SettlementOrderQueryService.php - Merchant Accounts
app/service/account/funds/MerchantAccountCommandService.php
Async Operations
- Merchant Notifications
app/queue/job/MerchantNotifyJob.php - Redis Queue
app/queue/redis - Receipt Watcher
app/process/ReceiptWatcherProcess.php
Platform Services
- Merchant Records
app/service/merchant/MerchantQueryService.php - Channel Configuration
app/service/payment/config/PaymentChannelQueryService.php - File Assets
app/service/file/FileRecordService.php - Storage Drivers
app/service/file/storage/StorageManager.php
Other components
- Business System
- Platform Operator
- Merchant User
- Payment Providers
- Object Storage
Connections 31
- Business System → Payment APIs: submits payment
- Payment APIs → ePay Protocols: handles protocol
- ePay Protocols → Order Runtime: creates orders
- Merchant User → Cashier API: uses cashier
- Cashier API → Order Runtime: confirms payment
- Order Runtime → Order Records: persists orders
- Order Runtime → Channel Routing: dispatches payment
- Channel Routing → Channel Configuration: resolves channels
- Channel Routing → Payment Plugins: invokes plugin
- Payment Plugins → Payment Providers: requests payment
- Payment Providers → Callback Lifecycle: sends callback
- Order Runtime → Callback Lifecycle: handles status
- Callback Lifecycle → Order Records: updates orders
- Callback Lifecycle → Redis Queue: queues notification
- Redis Queue → Merchant Notifications: dispatches job
- Callback Lifecycle → Settlement: triggers settlement
- Settlement → Merchant Accounts: posts funds
- Platform Operator → Admin API: manages platform
- Admin API → Merchant Records: manages merchants
- Admin API → Channel Configuration: configures channels
- Merchant User → Merchant Portal: manages account
- Merchant Portal → Merchant Records: reads merchant data
- Merchant Portal → Merchant Accounts: views funds
- Admin API → Refund Processing: manages refunds
- Merchant Portal → Refund Processing: requests refunds
- Refund Processing → Redis Queue: queues dispatch
- Admin API → Settlement: views settlement
- Admin API → File Assets: manages files
- File Assets → Storage Drivers: stores and retrieves
- Storage Drivers → Object Storage: uses remote storage
- Receipt Watcher → Redis Queue: queues receipt events