Checking access…

Skip to main content
Version: v2

Payment Domain Model

πŸ”’ InternalInternal information β€” not visible in the public (merchant) site.

Overview​

This document defines the core domain entities, their relationships, value objects, and invariants that govern the v2 payment system. Every engineer modifying payment logic must understand these boundaries.


Entity-Relationship Diagram​


Aggregate Root: Payment​

The Payment entity is the aggregate root. All state transitions and business rule enforcement flow through it.

Invariants​

#InvariantEnforcement Point
1SUM(allocation.amount) == payment.amountRequest validation (controller)
2payment.allocations.length ∈ 2Request validation (controller)
3Split-tender only allows CARD + CARDService layer
4merchantTransactionId is unique per merchantRepository layer (unique index)
5Retry count ≀ 4 (5 total attempts) per merchantTransactionIdService layer (idempotency check)
6authorizeCard: true requires partialAuthorization: trueRequest validation
7partialAuthorization: true requires authorizeCard: trueRequest validation
8Only CARD allocations support authorizeCardService layer
9BANK_ACCOUNT requires valid consentService layer
10Capture amount ≀ authorized amount per allocationService layer

Value Objects & Enums​

PaymentStatus (Payment-level)​

StatusTerminal?Description
INITIATEDNoPayment created, processing not yet started
PENDINGNoPayment request queued for processing
PENDING_FOR_CUSTOMER_CREATIONNoWaiting for customer record resolution
PENDING_FOR_PAYMENT_METHOD_CREATIONNoWaiting for payment method validation
PROCESSINGNoActively being processed with vendor
PROCESSING_DEDUP_CHECKNoPay-and-save dedup check in progress
AUTHORIZEDNoPre-auth hold placed, awaiting capture
ACCEPTEDNoACH accepted by processor, awaiting settlement
COMPLETEDYesPayment fully processed and settled
FAILEDYesPayment permanently failed
CANCELLEDYesPayment cancelled by merchant or system

AllocationStatus​

StatusTerminal?Description
PENDINGNoAllocation queued
AUTH_REQUIREDNo3DS challenge required
CONFIRMATION_INITIALIZEDNoConfirmation in progress post-3DS
AUTHORIZEDNoFunds held
CAPTURE_INITIALIZEDNoCapture in progress
ACCEPTEDNoACH accepted
CANCEL_INITIALIZEDNoCancellation in progress
CANCELEDYesSuccessfully cancelled
ROLLED_BACKYesSystem-initiated reversal (split-tender failure)
COMPLETEDYesSuccessfully settled
FAILEDYesProcessing failed

PaymentMethodType​

CARD | BANK_ACCOUNT

PaymentCancellationReason​

ValueDescription
DUPLICATEDuplicate payment detected
FRAUDULENTSuspected fraud
REQUESTED_BY_CUSTOMERCustomer initiated cancellation
ABANDONEDCustomer did not complete (e.g., 3DS timeout)
CCG_AUTOMATED_CANCELSystem-initiated (split-tender rollback, partial capture remainder)

CurrencyCode​

USD  (only supported value)

Customer Identification Priority​

When multiple identifiers are provided, the system resolves the customer in this order: