Payments
Description
The Payment entity represents a payment transaction against a loan. Payments can be initiated automatically via autopay, manually by the user, or as retries of previously failed payments. Each payment tracks its lifecycle from creation through completion or failure.
Storage
| Environment | Table Name | Region |
|---|---|---|
test |
test-loc-service |
us-west-2 |
prod |
prod-loc-service |
us-east-2 |
Fields
| Field | Type | Description |
|---|---|---|
|
String |
User ID who owns the payment |
|
String |
Loan this payment applies to |
|
String |
Unique payment identifier (UUID) |
|
Integer |
Payment amount in cents |
|
String |
Payment status (see Status Values below) |
|
String |
Payment method: |
|
String |
How payment was initiated: |
|
String |
Confirmation ID from payments service |
|
String |
Last 4 digits of payment account |
|
String |
Target installment for this payment |
|
Integer |
Number of payment attempts made |
|
Array |
List of installments this payment was applied to |
|
String |
Reason for last update (for audit logging) |
|
String |
Creation timestamp (RFC3339) |
|
String |
Last update timestamp (RFC3339) |
Status Values
| Status | Description |
|---|---|
|
Payment created, not yet submitted |
|
ACH payment submitted, awaiting settlement |
|
Payment successfully completed |
|
Payment failed, scheduled for retry |
|
Payment skipped (e.g., loan already paid) |
|
Payment permanently failed |
|
Payment was charged back |
|
ACH payment was returned |
Keys and Indexes
GSI1 - Payments by User and Loan Status
Used to list payments for a specific loan filtered by status.
| Key | Pattern |
|---|---|
GSI1PK |
|
GSI1SK |
|
Query Patterns
| Query | Index | Key Condition | Sort Key Condition |
|---|---|---|---|
Get payment by loan and payment ID |
Primary |
|
|
List all payments for a loan |
Primary |
|
|
List payments for loan in status |
GSI1 |
|
|
List all payments in retry status |
GSI2 |
|
|
Get payment by confirmation ID |
GSI3 |
|
|
Status Transitions
┌──────────────────────┐
│ PENDING │
│ (Payment created) │
└──────────┬───────────┘
│
┌──────────▼───────────┐
│ ACHSENT │
│ (Submitted to bank) │
└──────────┬───────────┘
│
┌─────────────────────┼─────────────────────┐
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ COMPLETED │ │ RETRY │ │ RETURNED │
│ (Success) │ │ (Will retry) │ │ (ACH returned) │
└─────────────────┘ └────────┬────────┘ └─────────────────┘
│
┌──────────▼───────────┐
│ FAILED │
│ (Max retries) │
└──────────────────────┘
Payment Applications
When a payment completes successfully, it is applied to installments. The loc_applications field tracks which installments received funds:
{
"loc_applications": [
{
"payment_id": "abc-123",
"installment_id": "inst-456",
"amount": 5000,
"payment_date": "2024-01-15T12:00:00Z"
}
]
}
Related Entities
-
Loans - Parent loan for this payment
-
Installments - Installments this payment applies to
-
Payment Logs - Audit trail for this payment