BNPL is a hybrid of payments and lending. A $100 purchase creates a $100 Merchant Payout (immediate) and a $100 Consumer Loan split into 4 installments of $25. The ledger must link these distinct entities. The complexity is the high velocity; a user might have 20 active micro-loans, each with its own schedule.
The Installment Object Structure
Instead of one loan, the database tracks Installments.
Loan_ID: 101
Installment_1: $25 | Due: T+0 | Status: Paid
Installment_2: $25 | Due: T+14 | Status: Scheduled
Installment_3: $25 | Due: T+28 | Status: Scheduled
Payment Routing: When a user pays $50, the "Allocation Engine" must intelligently apply it to the oldest due installments across multiple active loans.
Late Fee Triggering Logic
Automation is key to unit economics.
The Cron Job: Runs nightly. Checks WHERE due_date < today AND status != 'paid'.
The Action:
Transition Installment to Overdue.
Create new Ledger Entry: Debit: User_Account | Credit: Late_Fee_Revenue.
Trigger email notification.
Freeze user from making new purchases (Risk Control).