Skip to content

URD: Payment & Transaction

ModuleCORE-08Versionv0.5
StatusIn-progressDate2026-06-04

Business documentation. This URD is Payment & Transaction's feature list - each feature below is one Functional Area (<AREA>). The same <AREA> keys the feature's PRDs (PRD-<AREA>-NNN) and tests (TC-<AREA>-NNN), and each feature is listed in the Delivery feature catalog. See the Feature Spine convention.

1. Purpose

Define the user-facing requirements for collecting payments and recording the resulting money. The module connects a merchant's payment providers to KICKO, surfaces live payment status, and books every completed payment, purchase, and stock movement into a double-entry finance ledger so owners can see balances and reconcile their books.

2. Scope

IncludedExcluded
Per-merchant payment provider credentials (VNPAY QR MMS, PhonePOS)Direct gateway integration code (developer concern)
Real-time payment status (webhook + WebSocket)Checkout / split-payment UX (Orders module)
Outbound webhook subscriptions per merchantCard-data / token storage
Finance accounts / wallets + control accountsMulti-currency conversion
Double-entry vouchers (RECEIPT / PAYMENT / TRANSFER / ADJUSTMENT)Tax invoice issuance (Tax & Invoice module)
Auto-posting from sale, purchase, and inventory eventsStructured provider refunds (Planned)
Category hierarchy (seeded + custom)Per-shift cash reconciliation (Planned)

3. Definitions

TermDefinition
Payment providerAn external service (e.g. VNPAY) that processes a customer's payment
WebhookAn outbound notification KICKO sends to a subscriber when a payment changes state
Account / WalletA place money sits: cash, bank, QR collection, mobile POS, or an internal control account
VoucherA balanced bookkeeping entry of one type (RECEIPT, PAYMENT, TRANSFER, ADJUSTMENT)
Transaction (ledger line)One DEBIT or CREDIT line within a voucher, affecting one account's balance
CategoryAn income or expense label classifying where money came from or went
Auto-postingA voucher created automatically by the system in reaction to a business event

4. Conceptual Model

Conceptual only - full schema lives in the payment and finance developer domain models.

5. Feature Catalog

The feature list of this module. Each row is one feature (a Functional Area). Detail in §6. Mirrored in the Delivery feature catalog.

Feature IDFeaturePhaseStatusPriority
PAYPayment LifecycleP1BuiltHigh
PRVProvider CredentialsP1BuiltHigh
WALAccounts & WalletsP2BuiltHigh
VCHVouchers & LedgerP2BuiltHigh
CATCategoriesP2BuiltHigh

Status: live from Plane where mapped, otherwise registry-declared. Vocabulary mirrors Plane (state-group / phase).

6. Features

One sub-section per feature, in catalog order. Each feature keeps its description, requirements, and acceptance together. Priority = MoSCoW (Must / Should / Could / Won't).

PAY - Payment Lifecycle Built

Feature ID: payment/PAY · Phase: P1 · PRDs: - · Dev: @nx/payment

What it does for users: a payment moves from pending to paid, failed, or expired in real time; the cashier sees the change live and the sale that owns the order is notified the moment a payment succeeds.

Requirements

IDPRequirement
URD-PAY-001MThe system receives payment results from the provider and updates the payment's status
URD-PAY-002MOn a successful payment, the system notifies subscribers (e.g. the sale that settles the order)
URD-PAY-003MPayment status is broadcast live to the cashier (pending → paid / failed / expired)
URD-PAY-004MThe same payment result is applied only once, even if delivered multiple times (idempotent)
URD-PAY-005SAn owner can subscribe webhook endpoints by event type, with retries on delivery failure
URD-PAY-006WStructured refund back through the original provider (Planned - see §7)

Acceptance

AC-PAY-01: Payment status updates
GivenWhenThen
A pending paymentThe provider reports successStatus becomes paid, subscribers are notified, cashier sees the update live
A pending paymentThe provider reports failure / expiryStatus becomes failed / expired; the order stays open
An already-applied resultThe same result is redeliveredIt is ignored; no duplicate effect

PRV - Provider Credentials Built

Feature ID: payment/PRV · Phase: P1 · PRDs: - · Dev: @nx/payment

What it does for users: an owner connects a payment provider (VNPAY QR MMS, PhonePOS) per merchant; credentials are stored encrypted, masked in responses, and never usable by another merchant.

Requirements

IDPRequirement
URD-PRV-001MAn owner can connect a payment provider (VNPAY QR MMS, PhonePOS) per merchant
URD-PRV-002MProvider credentials are stored encrypted and never shown in full
URD-PRV-003SCredentials are scoped per merchant so one merchant cannot use another's

Acceptance

AC-PRV-01: Connect a provider securely
GivenWhenThen
An owner of a merchantConnects a payment providerCredentials are stored encrypted and masked in responses
Another merchantAttempts to use those credentialsAccess is denied; credentials are scoped per merchant

WAL - Accounts & Wallets Built

Feature ID: payment/WAL · Phase: P2 · PRDs: - · Dev: @nx/finance

What it does for users: an owner creates accounts where money sits - cash, bank, QR collection, mobile POS - each tracking an opening and running balance; the system also keeps internal control accounts automatically, and one default account receives auto-posted sale income.

Requirements

IDPRequirement
URD-WAL-001MAn owner can create accounts of type CASH, BANK, QR code, or mobile POS
URD-WAL-002MThe system maintains internal control accounts (e.g. inventory, COGS) automatically
URD-WAL-003MEach account tracks an opening balance and a running current balance
URD-WAL-004MA default account per merchant receives auto-posted sale income
URD-WAL-005SNon-owner roles see only the accounts of merchants they are granted access to

Acceptance

AC-WAL-01: Accounts and balances
GivenWhenThen
An ownerCreates an account with an opening balanceThe account shows that opening balance as current
A posted voucherIt debits/credits an accountThe account's running balance updates accordingly

VCH - Vouchers & Ledger Built

Feature ID: payment/VCH · Phase: P2 · PRDs: - · Dev: @nx/finance

What it does for users: every movement of money is a balanced double-entry voucher (RECEIPT, PAYMENT, TRANSFER, ADJUSTMENT); completed sales, received purchase orders, and stock movements auto-post once each, and an owner can create or void vouchers manually without ever deleting financial history.

Requirements

IDPRequirement
URD-VCH-001MEvery voucher is balanced: total DEBIT equals total CREDIT
URD-VCH-002MVoucher types are RECEIPT, PAYMENT, TRANSFER, ADJUSTMENT
URD-VCH-003MA completed sale payment auto-posts a RECEIPT voucher to the default account
URD-VCH-004MReceiving a purchase order auto-posts a PAYMENT voucher
URD-VCH-005MA stock issue/adjustment auto-posts the matching ledger voucher
URD-VCH-006MEach voucher records its source event so the same event posts only once (idempotent)
URD-VCH-007MVouchers are numbered per merchant and type (e.g. PT / PC / PCK / PKT)
URD-VCH-008SAn owner can create a manual voucher (draft → issue)
URD-VCH-009SAn owner can void a voucher via a balanced reversal (no hard delete)
URD-VCH-010CTransfer between two accounts is recorded as a zero-sum voucher

Acceptance

AC-VCH-01: Auto-posting from events
GivenWhenThen
A successful sale paymentThe event is processedA balanced RECEIPT voucher posts to the default account
A received purchase orderThe event is processedA balanced PAYMENT voucher posts
The same source eventIt is delivered againNo second voucher is created (idempotent)
AC-VCH-02: Manual voucher and void
GivenWhenThen
An ownerCreates and issues a manual voucherA balanced voucher appears in the ledger with a sequence number
An issued voucherThe owner voids itA balanced reversal voucher is posted; the original is preserved

CAT - Categories Built

Feature ID: payment/CAT · Phase: P2 · PRDs: - · Dev: @nx/finance

What it does for users: income and expense are classified by category; 14 system categories are seeded and protected, and an owner can add merchant-specific custom categories, including a parent hierarchy.

Requirements

IDPRequirement
URD-CAT-001M14 system categories are seeded and cannot be removed
URD-CAT-002MCategories are typed as INCOME or EXPENSE
URD-CAT-003SAn owner can add merchant-specific custom categories, including a parent hierarchy

Acceptance

AC-CAT-01: Seeded and custom categories
GivenWhenThen
A new merchantThe finance ledger initializes14 typed (INCOME / EXPENSE) system categories exist and cannot be removed
An ownerAdds a merchant-specific custom categoryIt is available for classifying money, optionally under a parent

7. Constraints & Non-Goals

Constraints

IDConstraint
C-01Every voucher must be balanced (DEBIT total = CREDIT total)
C-02The 14 seeded categories cannot be removed
C-03Provider credentials are encrypted at rest and masked in responses
C-04Each business event posts at most one voucher (idempotent via source event id)
C-05Records use soft-delete / reversal - no hard delete of financial history
C-06One default account per merchant for auto-posted sale income

Non-Goals

  • SoftPOS / NFC tap-to-pay flow
  • Additional e-wallet providers (Momo, ZaloPay)
  • Structured refund / reversal of external provider charges
  • Multi-currency conversion and cross-currency reconciliation
  • Per-shift cash reconciliation dashboard

8. Version History

DateAuthorDescriptionVer
2026-02-26P. Do - Product OwnerInitial user storiesv0.1
2026-04-16P. Do - Product OwnerFinance wallets, transactions, categoriesv0.3
2026-05-30MigrationRestructured to module convention; aligned areas (PAY/PRV/WAL/VCH/CAT) to two-package reality; refund + reconciliation marked Plannedv0.4
2026-06-04Claude (AI pair)Reorganize by feature (Feature Spine); each feature carries its own requirements + acceptance; CON moved to Constraintsv0.5

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.