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

# Installment Pay Link

> Let the customer pay an installment themselves.

# Installment Pay Link

## Intro

Creates a payment for one installment that the plan's customer completes in the browser — for when the saved card was declined, needs 3-D Secure, or the customer wants to pay early.

## Context

The response is the same `payment` object as [Installment Checkout](/api-reference/installments/checkout), for the installment's amount. When it's paid, the installment is marked `paid` on the plan (`installment.paid`), exactly as if it had been charged.

## Hows

`POST /installment-plans/{plan_id}/installments/{position}/pay-link`

### Request body (optional)

| Field             | Type   | Description                                                                                |
| ----------------- | ------ | ------------------------------------------------------------------------------------------ |
| `payment_gateway` | string | `stripe`, `paystack` or `flutterwave`. Defaults to the gateway for the product's currency. |

### Response

```json theme={null}
{
  "status": true,
  "message": "Installment payment created",
  "data": {
    "installment_plan_id": 812,
    "installment_position": 2,
    "payment": {
      "gateway": "paystack",
      "client_secret": null,
      "access_code": "0peioxfhpn",
      "payment_url": "https://checkout.paystack.com/0peioxfhpn",
      "reference": "khm_...",
      "amount": 300000,
      "currency": "NGN"
    }
  }
}
```

Present it like checkout: Stripe.js with `client_secret`, or redirect to `payment_url`.

### Errors

| Status | `error_code`                 | Cause                                         |
| ------ | ---------------------------- | --------------------------------------------- |
| 400    | `INSTALLMENT_NOT_ALLOWED`    | The plan is completed, cancelled or defaulted |
| 404    | `INSTALLMENT_PLAN_NOT_FOUND` | No such plan for your key                     |
| 404    | `INSTALLMENT_NOT_FOUND`      | No installment at that position               |
| 409    | `INSTALLMENT_ALREADY_PAID`   | Already paid                                  |

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.khaime.com/api/v1/installment-plans/812/installments/2/pay-link \
    -H "X-API-Key: pk_sandbox_your_key"
  ```
</RequestExample>

## Whys

Off-session charges fail when a bank insists on authenticating the customer. A pay link puts the customer back in the flow so the bank can challenge them, without starting a new plan.

## Why nots

* It isn't a hosted Khaime page for Stripe — you present the Stripe payment with Stripe.js, as at checkout.
* Creating a pay link doesn't email the customer; send it through your own channel.
