Audit Logs
Description
The LOC Service maintains two types of audit logs to track changes to payments and installments. These logs are created by DynamoDB Stream handlers when records are modified, providing a complete history of all changes.
Payment Logs
Payment logs track the lifecycle of each payment including status changes, amounts, and which installments the payment was applied to.
Fields
| Field | Type | Description |
|---|---|---|
|
String |
User ID who owns the payment |
|
String |
Loan this payment belongs to |
|
String |
Payment being logged |
|
Integer |
Payment amount in cents at time of log |
|
String |
Confirmation ID from payments service |
|
String |
Payment status at time of log |
|
String |
Process type: |
|
Integer |
Number of payment attempts at time of log |
|
Array |
Installments this payment was applied to |
|
String |
Description of the change (from |
|
String |
Log creation timestamp (RFC3339) |
Installment Logs
Installment logs track changes to installments including payment applications and status changes.
Fields
| Field | Type | Description |
|---|---|---|
|
String |
User ID who owns the installment |
|
String |
Loan this installment belongs to |
|
String |
Installment being logged |
|
String |
Process type: |
|
Array |
Payments applied to this installment at time of log |
|
String |
Description of the change (from |
|
String |
Log creation timestamp (RFC3339) |
How Logs Are Created
Logs are created through DynamoDB Streams:
Payment/Installment Update
│
▼
┌─────────────────────────┐
│ DynamoDB Stream │
│ (captures old/new) │
└───────────┬─────────────┘
│
▼
┌─────────────────────────┐
│ Log Handler │
│ (Lambda function) │
└───────────┬─────────────┘
│
▼
┌─────────────────────────┐
│ PaymentLog or │
│ InstallmentLog │
│ (saved to DynamoDB) │
└─────────────────────────┘
UpdateReason Field
Both Payment and Installment entities have a transient UpdateReason field that is consumed by the log handler:
-
This field should describe what change was made and why
-
For payments, include amount change information when relevant
-
The field is marked
omitemptyand not persisted long-term on the main record
Example usage in code:
payment.UpdateReason = "Payment completed successfully, applied $50.00 to installment"
Example Log Entry
{
"PK": "PAYMENTLOG#user-123",
"SK": "LOAN#loan-456#PAYMENTLOG#pay-789#2024-01-15T12:00:00Z",
"user_id": "user-123",
"loan_id": "loan-456",
"payment_id": "pay-789",
"amount": 5000,
"confirmation_id": "conf-abc",
"status": "COMPLETED",
"process": "AUTO",
"payment_attempts": 1,
"applied_installments": [
{
"payment_id": "pay-789",
"installment_id": "inst-001",
"amount": 5000,
"payment_date": "2024-01-15T12:00:00Z"
}
],
"message": "Autopay payment completed successfully",
"created_at": "2024-01-15T12:00:00Z"
}
Related Entities
-
Payments - Payment records being logged
-
Installments - Installment records being logged