> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fincode.technology/llms.txt
> Use this file to discover all available pages before exploring further.

# Loan Details with Payment History

> Retrieves comprehensive loan application details including payment history and installment schedule.

Fetches detailed information about a loan application including all installments, payment history, outstanding balances, and repayment schedule.

<RequestExample>
  ```bash cURL GET theme={null}
  [https://finlend.fincode.software/api/v1/services/user/loan-details-with-payment-history/{loan-application-id}](https://finlend.fincode.software/api/v1/services/user/loan-details-with-payment-history/{loan-application-id})
  ```
</RequestExample>

## Request Headers

<ParamField header="X-Auth-Token" type="string" required>
  The **JWT Access Token** obtained from the `/login` or `/refresh-token` endpoint.
</ParamField>

<ParamField header="x-idempotency-key" type="string" required>
  Unique idempotency key for the request to prevent duplicate processing.
</ParamField>

<ParamField header="x-fapi-auth-date" type="string" required>
  The date and time at which the request was initiated (ISO 8601 format).
</ParamField>

<ParamField header="x-fapi-customer-ip-address" type="string" required>
  The IP address of the customer making the request.
</ParamField>

<ParamField header="x-fapi-interaction-id" type="string" required>
  Unique identifier for the interaction/session.
</ParamField>

## Path Parameters

<ParamField path="loan-application-id" type="string" required>
  The unique identifier (UUID) of the loan application for which to retrieve details.
</ParamField>

## Response

Returns comprehensive loan details including installment schedule and payment history.

<ResponseField name="status" type="string" default="SUCCESS">
  Overall status of the API request.
</ResponseField>

<ResponseField name="data" type="object">
  Loan application details with payment history.

  <Expandable title="data object">
    <ResponseField name="loanApplicationId" type="string">
      Unique identifier of the loan application.
    </ResponseField>

    <ResponseField name="customerId" type="string">
      Unique identifier of the customer.
    </ResponseField>

    <ResponseField name="customerName" type="string">
      Name of the customer.
    </ResponseField>

    <ResponseField name="customerEmail" type="string">
      Email address of the customer.
    </ResponseField>

    <ResponseField name="loanProductName" type="string">
      Name of the loan product.
    </ResponseField>

    <ResponseField name="loanApplicationStatus" type="string">
      Current status of the loan application (e.g., `REQUESTED`, `APPROVED`, `DISBURSED`).
    </ResponseField>

    <ResponseField name="accountState" type="string">
      Account state (e.g., `ACTIVE`, `CLOSED`, `ACTIVE_IN_ARREARS`).
    </ResponseField>

    <ResponseField name="loanAmount" type="number">
      Original loan amount (principal).
    </ResponseField>

    <ResponseField name="interestRate" type="number">
      Interest rate applicable to the loan.
    </ResponseField>

    <ResponseField name="totalRepaymentAmount" type="number">
      Total repayment amount (principal + total interest + fees).
    </ResponseField>

    <ResponseField name="totalBalance" type="number">
      Total outstanding balance.
    </ResponseField>

    <ResponseField name="principalBalance" type="number">
      Outstanding principal balance.
    </ResponseField>

    <ResponseField name="interestBalance" type="number">
      Outstanding interest balance.
    </ResponseField>

    <ResponseField name="feesBalance" type="number">
      Outstanding fees balance.
    </ResponseField>

    <ResponseField name="penaltyBalance" type="number">
      Outstanding penalty balance.
    </ResponseField>

    <ResponseField name="totalAmountPaid" type="number">
      Total amount paid so far.
    </ResponseField>

    <ResponseField name="principalPaid" type="number">
      Principal amount paid.
    </ResponseField>

    <ResponseField name="interestPaid" type="number">
      Interest amount paid.
    </ResponseField>

    <ResponseField name="feesPaid" type="number">
      Fees amount paid.
    </ResponseField>

    <ResponseField name="penaltyPaid" type="number">
      Penalty amount paid.
    </ResponseField>

    <ResponseField name="applicationDate" type="string">
      Date when the loan application was created.
    </ResponseField>

    <ResponseField name="disbursementDate" type="string">
      Date when the loan was disbursed.
    </ResponseField>

    <ResponseField name="firstInstallmentDate" type="string">
      Date of the first installment.
    </ResponseField>

    <ResponseField name="maturityDate" type="string">
      Loan maturity date.
    </ResponseField>

    <ResponseField name="nextPaymentDueDate" type="string">
      Next payment due date.
    </ResponseField>

    <ResponseField name="totalInstallments" type="number">
      Total number of installments.
    </ResponseField>

    <ResponseField name="installmentsPaid" type="number">
      Number of installments paid.
    </ResponseField>

    <ResponseField name="installmentsRemaining" type="number">
      Number of installments remaining.
    </ResponseField>

    <ResponseField name="loanDuration" type="number">
      Loan duration.
    </ResponseField>

    <ResponseField name="durationCounter" type="string">
      Duration counter unit (e.g., `MONTH`, `WEEK`, `DAY`).
    </ResponseField>

    <ResponseField name="loanRepaymentMethod" type="string">
      Loan repayment method (e.g., `External Bank Transfer`, `Internal Bank Transfer`).
    </ResponseField>

    <ResponseField name="isThirdPartyPayment" type="boolean">
      Whether the loan uses third-party payment collection (e.g., Remita).
    </ResponseField>

    <ResponseField name="repaymentBankName" type="string">
      Bank name for manual repayments.
    </ResponseField>

    <ResponseField name="repaymentAccountNumber" type="string">
      Account number for manual repayments.
    </ResponseField>

    <ResponseField name="repaymentAccountName" type="string">
      Account name for manual repayments.
    </ResponseField>

    <ResponseField name="loanFullyRepaid" type="boolean">
      Whether the loan is fully repaid.
    </ResponseField>

    <ResponseField name="currencyCode" type="string">
      Currency code.
    </ResponseField>

    <ResponseField name="paymentHistory" type="array">
      List of all installments with payment details.

      <Expandable title="paymentHistory array item (InstallmentDto)">
        <ResponseField name="installmentNumber" type="number">
          Installment number (1, 2, 3, etc.).
        </ResponseField>

        <ResponseField name="dueDate" type="string">
          Due date for this installment.
        </ResponseField>

        <ResponseField name="installmentAmount" type="number">
          Total installment amount (principal + interest + fees).
        </ResponseField>

        <ResponseField name="principalAmount" type="number">
          Principal amount for this installment.
        </ResponseField>

        <ResponseField name="interestAmount" type="number">
          Interest amount for this installment.
        </ResponseField>

        <ResponseField name="feesAmount" type="number">
          Fees amount for this installment.
        </ResponseField>

        <ResponseField name="penaltyAmount" type="number">
          Penalty amount (if any).
        </ResponseField>

        <ResponseField name="amountPaid" type="number">
          Amount paid for this installment.
        </ResponseField>

        <ResponseField name="outstandingAmount" type="number">
          Outstanding amount for this installment.
        </ResponseField>

        <ResponseField name="paymentStatus" type="string">
          Payment status (e.g., `PENDING`, `PAID`, `PARTIAL`, `OVERDUE`).
        </ResponseField>

        <ResponseField name="paymentDate" type="string">
          Date when payment was made (if paid).
        </ResponseField>

        <ResponseField name="daysOverdue" type="number">
          Number of days overdue (if applicable).
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</ResponseField>

## Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl --location 'https://finlend.fincode.software/api/v1/services/user/loan-details-with-payment-history/123e4567-e89b-12d3-a456-426614174000' \
  --header 'X-Auth-Token: YOUR_JWT_ACCESS_TOKEN' \
  --header 'x-idempotency-key: unique-key-12345' \
  --header 'x-fapi-auth-date: 2024-01-15T10:30:00Z' \
  --header 'x-fapi-customer-ip-address: 192.168.1.1' \
  --header 'x-fapi-interaction-id: interaction-12345'
  ```

  ```javascript Node.js theme={null}
  const axios = require('axios');

  const BASE_URL = 'https://finlend.fincode.software/api/v1/services/user';

  async function getLoanDetailsWithPaymentHistory(accessToken, loanApplicationId) {
    try {
      const response = await axios.get(
        `${BASE_URL}/loan-details-with-payment-history/${loanApplicationId}`,
        {
          headers: {
            'X-Auth-Token': accessToken,
            'x-idempotency-key': `key-${Date.now()}`,
            'x-fapi-auth-date': new Date().toISOString(),
            'x-fapi-customer-ip-address': '192.168.1.1',
            'x-fapi-interaction-id': `interaction-${Date.now()}`,
          },
        }
      );

      const loanDetails = response.data.data;
      console.log('Loan Details:');
      console.log(`- Application ID: ${loanDetails.loanApplicationId}`);
      console.log(`- Product: ${loanDetails.loanProductName}`);
      console.log(`- Total Installments: ${loanDetails.totalInstallments}`);
      console.log(`- Installments Paid: ${loanDetails.installmentsPaid}`);
      console.log(`- Total Balance: ${loanDetails.totalBalance}`);
      console.log(`- Next Payment Due: ${loanDetails.nextPaymentDueDate}`);
      
      console.log('\nInstallment Schedule:');
      loanDetails.paymentHistory.forEach((installment) => {
        console.log(
          `Installment ${installment.installmentNumber}: ` +
          `${installment.installmentAmount} due ${installment.dueDate} ` +
          `(Status: ${installment.paymentStatus})`
        );
      });

      return loanDetails;
    } catch (error) {
      console.error(
        'Failed to fetch loan details:',
        error.response?.data || error.message
      );
      throw error;
    }
  }

  // Usage Example
  const accessToken = 'YOUR_JWT_ACCESS_TOKEN';
  const loanApplicationId = '123e4567-e89b-12d3-a456-426614174000';
  getLoanDetailsWithPaymentHistory(accessToken, loanApplicationId);
  ```
</CodeGroup>
