Skip to main content

Domain and data model

Status: Logical design, not a final Prisma schema. Business ownership is merchant-scoped; consumer identity and payment-method vault references are shared where consent permits.

DomainCore entitiesImportant rules
IdentityUser, Consumer, Merchant, MerchantUser, MerchantCustomerMerchant customer reference is unique within merchant; consumer matching must be verified
OnboardingMerchantVerification, PayoutDestination, MerchantAgreementKeep verification evidence, approvals and effective dates
PaymentsPaymentMethod, PaymentMandate, ConsentEvidence, PaymentPreferenceOnly tokenised methods; merchant-specific permissions and revocation
BillingBill, BillVersion, Payment, PaymentAttemptBill versions immutable; attempt references unique by provider
FundsCollection, SettlementRecord, Payout, PayoutAllocationSeparate collection, settlement and payout; no double allocation
AccountingLedgerAccount, LedgerTransaction, LedgerEntryBalanced double-entry, append-only, integer minor units
ExceptionsRefund, Dispute, Reversal, ReconciliationRecordTrace back to original payment and ledger postings
CommercialMerchantPricing, PricingAgreement, FeeAssessment, MerchantInvoice, InvoiceLineVersioned pricing; fee invoices separate from bill proceeds
OperationsProviderWebhook, Notification, AuditEvent, IdempotencyKey, JobWebhook deduplication, traceability, retries and access control

Key relationships​

Implementation principles​

  1. Use UUID/ULID primary keys and explicit unique constraints on provider IDs and merchant-scoped external IDs.
  2. Store money as integer minor units with ISO currency, never floating-point.
  3. Store event times in UTC; preserve the relevant Australian business timezone and cut-off calendar for scheduling.
  4. Separate internal IDs from external provider and merchant identifiers.
  5. Use soft disable/status changes for operational records; do not delete financial or consent evidence.
  6. Encrypt personal information at rest, minimise retained data and set evidence retention rules after legal review.
  7. Use outbox/inbox patterns for reliable events and webhooks.
  8. Define row-level/tenant authorization for every merchant API and admin query.

To design next​

Formal Prisma schema, unique indexes, state-transition guards, retention policy, migrations, test fixtures and reconciliation queries.