Giao diện
Thanh toán
Trang sinh tự động
Phần nghiệp vụ viết tay; API, dữ liệu, quyền, đường dẫn và file nguồn do bộ sinh điền từ source tại ad83b0aea.
Làm gì
Cọc và phần còn lại, qua MoMo hoặc COD, cộng Pi-Point. Mỗi lần thanh toán là một intent có phiên riêng; nhà cung cấp trả lời không dứt khoát thì trạng thái là UNKNOWN và có vòng quét hồi phục, chứ không coi là thất bại. Có đối soát với nhà cung cấp và quy trình hoàn tiền maker/checker.
Quy mô
| Domain API | payment |
| Query / Mutation | 17 / 17 |
| Nguồn dữ liệu | payment |
| Bảng | 44 |
| Luật phân quyền | 8 |
| Đường dẫn Web Admin | 17 |
Thao tác (mutation)
| Mutation | Domain | Mô tả |
|---|---|---|
approveVoucher | payment | A different person approves exactly what they reviewed: APPROVED, immutable, one cashbook entry (VCH-04, MFA). |
cancelPaymentSession | payment | #479 T14. Closes the provider session of the buyer's own open payment |
cancelVoucher | payment | Cancel an own DRAFT or SUBMITTED voucher (VCH-02). |
confirmRefundTransfer | payment | Xac nhan da hoan tien (DH-US-07 AC04): the order's payment becomes REFUNDED, logged, the customer is notified. order.refund.process. Errors: validation_failed (transactionCode, transferredOn, note), stale_version, conflict (refund_not_waiting, profile_required, transfer_already_recorded, transaction_code_reuse, legs_in_progress, case_not_approved), forbidden. |
recordCodCollection | payment | Legacy order-level manual COD collection (A-FF-03). Requires cod.collect. No web caller since U19-P4-02. |
recordCodRemittance | payment | Remittance evidence of a COLLECTED COD. Requires cod.remit (COD-02, Finance). |
recordReturnNoRefund | payment | #479 B. Operations record that a returned unit paid in full (a Mua chung order in Hoàn hàng, or one Mua định kỳ |
rejectVoucher | payment | A different person sends a SUBMITTED voucher back to its maker with a reason; the voucher returns to DRAFT (VCH-04, MFA). |
requestRefundInfoUpdate | payment | Bao khach cap nhat lai (DH-US-16): the payment goes back to WAITING_REFUND_REQUEST; the customer sees the refund as REJECTED with the reason code (and the note when visible) and gets an in-app notice. order.refund.process. Errors: validation_failed (reasonCode, reason, customerNote), stale_version, conflict (refund_not_waiting, profile_required, profile_locked), forbidden. |
resolveDiscrepancy | payment | PRC-02 reconcile.resolve (Finance): handle one payment discrepancy item. |
retryRefundBranch | payment | Recovers a REJECTED leg (never an UNKNOWN one). Requires refund.recover (RFD-02). |
saveVoucherDraft | payment | Create or revise a DRAFT voucher (VCH-02). |
selectRemainingPaymentMethod | payment | U19-P2-21. The buyer chooses or changes the remaining payment method of |
startDepositCheckout | payment | Starts (or, with the same requestId, re-checks) the whole deposit |
startRemainingPayment | payment | P3-05. Starts (or re-checks, same requestId) the ONE full online remaining |
submitRefundRequest | payment | APP_USER (refund.submit, own order): sends or sends again the refund request while the payment status is WAITING_REFUND_REQUEST; it becomes WAITING_REFUND. #479 C: with refundCaseId, the request of one cọc dư claim while OrderRefund.excessClaim.canSubmitRequest (the payment status does not move). Errors: forbidden (another customer's order), validation_failed (field), stale_version, conflict (refund_not_requestable, no_cash_to_transfer, profile_locked). |
submitVoucher | payment | Maker submits with evidence; the FUNDS_VOUCHER policy is evaluated and frozen (VCH-03, MFA). |
Phép đọc (query)
| Query | Domain | Mô tả |
|---|---|---|
cancellationDecision | payment | |
cashbookEntries | payment | Automatic receipts and reversals, latest first. Requires cashbook.read (RCP-01, Finance). |
cashbookFundView | payment | Read-only deposit-fund view; model-governed figures are POLICY_UNDECIDED. Requires cashbook.read. |
codCollection | payment | One COD collection with its evidence. Requires payment.read (Finance). |
codCollections | payment | COD collections, latest change first. Requires payment.read (Finance). |
codReconciliation | payment | PRC-01 reconcile.read (Finance): every COD run version of one VN date, newest first. |
funds | payment | The funds vouchers may use: the cash fund and one per company bank account (VCH-01). |
momoReconciliation | payment | PRC-01 reconcile.read (Finance): every run version of one VN date, newest first. |
orderPayments | payment | payment.read (F-01 Finance): the tenders, transactions, allocations and periods of one order. |
paymentObligations | payment | payment.read (F-01 Finance): every payment obligation, newest first. |
paymentsNeedingAttention | payment | payment.read (F-01 Finance): payments that need a person (#479). Read only. |
paymentTransactions | payment | payment.read (F-01 Finance): provider captures and refunds with their attempt and obligation, newest first. |
refundCase | payment | One refund case with its legs and history. Requires refund.read (RFD-01). |
refundCases | payment | Refund cases, newest first. Requires refund.read (RFD-01, Finance). orderCode (#479): exact business order code, any letter case; an unknown code matches nothing. |
unappliedPayments | payment | PRC-01 reconcile.read (Finance): captured money not applied to an obligation. Read only (GAP-149 / GAP-1620). |
voucher | payment | |
vouchers | payment | Manual vouchers, newest first (VCH-01). |
Dữ liệu
- Domain
payment— 44 bảng, 8 nhóm con: payment (13) · order (7) · refund (6) · cod (5) · mock (4) · finance (2) · voucher (2) · bảng đơn lẻ (5) (5)
Bảng được tham chiếu nhiều nhất trong module:
| Bảng | Cột | Được trỏ tới | RLS |
|---|---|---|---|
payment_intents | 19 | 9 | ✓ |
payment_obligations | 18 | 8 | ✓ |
provider_transactions | 18 | 7 | ✓ |
refund_cases | 35 | 6 | ✓ |
cod_collections | 28 | 3 | ✓ |
cashbook_entries | 18 | 2 | ✓ |
cod_reconciliation_runs | 20 | 2 | ✓ |
vouchers | 29 | 2 | ✓ |
cancellation_decisions | 23 | 1 | ✓ |
finance_policy_kinds | 5 | 1 | ✓ |
Quyền
| Mã | Quyền | Ứng dụng | Vai trò | Phạm vi | Trạng thái |
|---|---|---|---|---|---|
F-01 | payment.read | WEB_ADMIN | finance | ALL | PROPOSED |
FRM-02 | refund.read | WEB_ADMIN | finance_manager | ALL | PROPOSED |
ORD-03 | refund.submit | APP_USER | user | OWN | DEFINED |
ORD-04 | payment.method_select | APP_USER | user | OWN | DEFINED |
RFD-01 | refund.read | WEB_ADMIN | finance | ALL | PROPOSED |
RFD-02 | refund.recover | WEB_ADMIN | finance | ALL | PROPOSED |
U-04 | payment.read | APP_USER | user | OWN | DEFINED |
U-05 | payment.start | APP_USER | user | OWN | PROPOSED |
Danh sách đầy đủ và cách đọc các cờ: Ma trận quyền.
Giao diện Web Admin
| Đường dẫn | Hằng số |
|---|---|
/cashbook/deposits | CASHBOOK_DEPOSITS |
/cashbook/revenue | CASHBOOK_REVENUE |
/cashbook/vouchers | CASHBOOK_VOUCHERS |
/cashbook/vouchers/:id | CASHBOOK_VOUCHER_DETAIL |
/cashbook/vouchers/:id/edit | CASHBOOK_VOUCHER_EDIT |
/cashbook/vouchers/new | CASHBOOK_VOUCHER_NEW |
/payments | PAYMENTS |
/payments/:id | PAYMENT_DETAIL |
/payments/attention | PAYMENT_ATTENTION |
/payments/momo-simulator | PAYMENT_MOMO_SIMULATOR |
/payments/refund-requests | PAYMENT_REFUND_REQUESTS |
/payments/refund-requests/:id | PAYMENT_REFUND_DETAIL |
/payments/unapplied | PAYMENT_UNAPPLIED |
/reconciliation/discrepancies | RECONCILIATION_DISCREPANCIES |
/reconciliation/discrepancies/:id | RECONCILIATION_DISCREPANCY_DETAIL |
/reconciliation/gateway | RECONCILIATION_GATEWAY |
/reconciliation/gateway/:date/:runId | RECONCILIATION_GATEWAY_RUN |
File nguồn
Backend:
code/apps/api/supabase/functions/graphql/domains/payment/
Dữ liệu: bảng thuộc domain payment — xem Cơ sở dữ liệu.