> ## 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.

# Payoff Loan

> Allows customers to pay off their entire loan balance in a single transaction.

Customers can use this endpoint to settle their loan completely by paying the remaining outstanding balance in one transaction.

<RequestExample>
  ```bash cURL POST theme={null}
  [https://finlend.fincode.software/api/v1/services/user/payoff-loan](https://finlend.fincode.software/api/v1/services/user/payoff-loan)
  ```
</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>

<ParamField header="Content-Type" type="string" required default="application/json">
  Must be `application/json`.
</ParamField>

## Request Body

<ParamField body="loanApplicationId" type="string" required>
  The unique identifier (UUID) of the loan application to pay off.
</ParamField>

<ParamField body="paymentMethod" type="string" required>
  Method of payment. Options: `WALLET`, `BANK_TRANSFER`, `CARD`, etc.
</ParamField>

<ParamField body="transactionPin" type="string">
  Transaction PIN for authorization (if required).
</ParamField>

<ParamField body="payoffAmount" type="number">
  Optional payoff amount. If not provided, the system will calculate the full outstanding balance.
</ParamField>

## Response

Returns confirmation of the loan payoff with final settlement details.

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

<ResponseField name="data" type="object">
  Payoff confirmation details.

  <Expandable title="data object">
    <ResponseField name="repaymentId" type="string">
      Unique identifier for the payoff transaction.
    </ResponseField>

    <ResponseField name="loanApplicationId" type="string">
      Identifier of the loan application.
    </ResponseField>

    <ResponseField name="payoffAmount" type="number">
      The amount that was paid to settle the loan.
    </ResponseField>

    <ResponseField name="remainingBalance" type="number" default="0">
      Remaining balance after payoff (should be 0).
    </ResponseField>

    <ResponseField name="loanStatus" type="string" default="PAID_OFF">
      Updated status of the loan (should be `PAID_OFF` or `COMPLETED`).
    </ResponseField>

    <ResponseField name="transactionReference" type="string">
      Reference number for the payoff transaction.
    </ResponseField>

    <ResponseField name="payoffDate" type="string">
      Date and time when the loan was paid off.
    </ResponseField>
  </Expandable>
</ResponseField>

## Code Examples

<CodeGroup>
  ```bash cURL theme={null}
  curl --location --request POST 'https://finlend.fincode.software/api/v1/services/user/payoff-loan' \
  --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' \
  --header 'Content-Type: application/json' \
  --data '{
      "loanApplicationId": "123e4567-e89b-12d3-a456-426614174000",
      "paymentMethod": "WALLET",
      "transactionPin": "1234"
  }'
  ```

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

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

  async function payoffLoan(accessToken, payoffData) {
    try {
      const response = await axios.post(
        `${BASE_URL}/payoff-loan`,
        {
          loanApplicationId: payoffData.loanApplicationId,
          paymentMethod: payoffData.paymentMethod,
          transactionPin: payoffData.transactionPin,
          payoffAmount: payoffData.payoffAmount,
        },
        {
          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()}`,
            'Content-Type': 'application/json',
          },
        }
      );
      return response.data.data;
    } catch (error) {
      console.error(
        'Failed to payoff loan:',
        error.response?.data || error.message
      );
      throw error;
    }
  }

  // Usage Example
  const accessToken = 'YOUR_JWT_ACCESS_TOKEN';
  payoffLoan(accessToken, {
    loanApplicationId: '123e4567-e89b-12d3-a456-426614174000',
    paymentMethod: 'WALLET',
    transactionPin: '1234',
  });
  ```
</CodeGroup>
