Endpoint
Authentication
Requires authentication withBearer token. All staff roles (Admin, Supervisor, Credit Officer) can create repayments.
Request Body
ID of the loan this repayment is for. The loan must be in APPROVED, ACTIVE, or DEFAULTED status.
Payment amount received. Must be a positive number.
Payment method used. Options:
CASH- Cash paymentTRANSFER- Bank transferPOS- Point of sale terminalMOBILE- Mobile money (e.g., M-Pesa)USSD- USSD paymentOTHER- Other payment methods
Date and time when payment was made (ISO 8601 format). If not provided, defaults to current timestamp.
Optional payment reference number or transaction ID (e.g., bank reference, receipt number)
Optional notes about the payment (e.g., “Payment received at branch office”, “Partial payment - borrower will pay balance next week”)
Optional: Target a specific repayment schedule item for payment allocation. If provided, this schedule item will be prioritized when allocating the payment. Useful for making payments on specific overdue installments.
Automatic Payment Processing
When you create a repayment, the system automatically:- Validates the Loan: Checks that the loan exists and is in a valid status (APPROVED, ACTIVE, or DEFAULTED)
- Creates the Repayment Record: Records the payment with all details
- Allocates Payment to Schedule Items:
- If
scheduleItemIdis provided, prioritizes that schedule item - Otherwise, allocates to pending schedule items in order of due date (oldest first)
- Handles partial payments by marking items as
PARTIAL - Applies excess payments to subsequent schedule items
- If
- Recalculates Schedule: Updates all schedule items with new paid amounts and statuses
- Updates Loan Status: Automatically transitions loan status:
APPROVED→ACTIVE(first payment received)ACTIVE→COMPLETED(loan fully paid)DEFAULTED→ACTIVE(payment received on overdue loan)
Response
Indicates if the repayment was recorded successfully
Response message (e.g., “Repayment recorded successfully”)
The created repayment object
Unique identifier for the repayment record
ID of the loan this repayment is for
Payment amount received
Currency code for the payment
Date and time when payment was made (ISO 8601)
Payment method used (CASH, TRANSFER, POS, MOBILE, USSD, OTHER)
Payment reference number or transaction ID
Notes about the payment
ID of the user who recorded this repayment (from authentication token)
Loan details with borrower information
Loan ID
Unique loan number
Original loan amount
Current loan status (APPROVED, ACTIVE, COMPLETED, DEFAULTED)
Timestamp when repayment record was created
Timestamp when repayment record was last updated
Example Request
Example Response
Partial Payment Example
If a borrower pays less than the full installment amount:- Apply ₦2,000 to the oldest pending schedule item
- Mark that schedule item as
PARTIAL - Track the remaining balance (₦3,000 if the installment was ₦5,000)
- The next payment will complete this item before moving to the next
Excess Payment Example
If a borrower pays more than one installment:- Apply ₦5,000 to installment 1 (mark as
PAID) - Apply ₦5,000 to installment 2 (mark as
PAID) - Apply ₦5,000 to installment 3 (mark as
PAID) - Create allocation records showing the distribution
Targeting Specific Schedule Items
To pay a specific overdue installment (e.g., installment 3):Error Responses
Bad request - validation errors
Unauthorized - missing or invalid authentication token
Not found - loan does not exist
Unprocessable entity - loan in invalid status
Audit Trail
All repayment creation actions are automatically logged to the audit trail with:- Action:
REPAYMENT_CREATED - Entity:
Repayment - Actor: Authenticated user who created the repayment
- Timestamp: When the repayment was recorded
- Metadata: Repayment details including amount, method, and loan information
