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

# Installments

> Sell a product in installments: the customer pays part now and the rest later.

## Intro

The customer pays the first installment at checkout. That payment opens an **installment plan** and saves their card. The remaining installments are collected later.

> [!NOTE]
>
> The API says **installment**. "Split" means marketplace commission, never paying in parts.

## Context

* Installments are set per product, as an installment template (`installment_plan`).
* The first installment goes through normal checkout, so [Gateway Routing](https://docs.khaime.com/payments/gateway-routing.md) and [Multicurrency](https://docs.khaime.com/payments/multicurrency.md) apply.
* Each installment is its own payment: own transaction, wallet credit, `payment.succeeded`, refundable on its own.
* Amounts are integers in the smallest currency unit and add up exactly to the total.

## Hows

### 1. Set the template

Via [Marketplace Products](https://docs.khaime.com/api-reference/marketplace/products.md):

```bash theme={null}
curl -X PATCH https://api.khaime.com/api/v1/marketplace/products/3046 \
  -H "X-API-Key: pk_sandbox_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "installment_plan": {
      "enabled": true,
      "installments": [
        { "position": 1, "label": "Deposit", "type": "percentage", "amount": 40 },
        { "position": 2, "label": "Second payment", "type": "percentage", "amount": 30 },
        { "position": 3, "label": "Final payment", "type": "percentage", "amount": 30 }
      ]
    }
  }'
```

* At least 2 installments, positions 1, 2, 3 … with no gaps.
* One `type` for all: `percentage` (adds up to 100) or `amount` (minor units).
* `{ "enabled": false }` turns it off.

Or in the dashboard: **Allow split payments** on the product form.

### 2. Preview the schedule

`GET /products/3046/installment-quote`: see [Installment Quote](https://docs.khaime.com/api-reference/installments/quote.md).

### 3. Take the first installment

```bash theme={null}
curl -X POST https://api.khaime.com/api/v1/installment-plans/checkout \
  -H "X-API-Key: pk_sandbox_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "product_id": 3046,
    "customer": { "email": "ada@example.com", "full_name": "Ada Lovelace" },
    "installment": { "enabled": true }
  }'
```

Also works:

* `"installment": { "enabled": true }` on `POST /payments/sessions`, `POST /payments/intents` and `POST /sdk/initialize`.
* `is_split: true, payment_split_position: 1` on [Create Product Payment Intent](https://docs.khaime.com/api-reference/commerce/payment-intent.md#installments).

Complete the returned `payment` in the browser (Stripe.js with `client_secret`, or redirect to `payment_url`). Once paid, the plan is `active`, the card is saved and the next installments are due monthly.

### 4. Collect the rest

| How | Use |
| - | - |
| [Charge an installment](https://docs.khaime.com/api-reference/installments/charge.md) | Charge the saved card. Needs `Idempotency-Key`. |
| [Pay link](https://docs.khaime.com/api-reference/installments/pay-link.md) | Customer pays (after a decline, or for 3-D Secure). |
| [Create Product Payment Intent](https://docs.khaime.com/api-reference/commerce/payment-intent.md#pay-in-installments) | Your own checkout: `payment_split_position` + `installment_plan_id`. |
| Automatic collection | Business turns it on per plan in the dashboard. |
| Dashboard order page | Business clicks **Charge now**. |
| Storefront account | Customer clicks **Pay now** under **Account → Installments**. |

Automatic collection charges on the due date and retries after 1, 3 and 7 days. The third failure sets the plan to `past_due`; the last one marks the installment `failed`. Customers get an email 3 days before each charge and after each failure.

An installment is never charged twice. Paying one that is already paid returns `INSTALLMENT_ALREADY_PAID`.

### 5. Track the plan

* [List](https://docs.khaime.com/api-reference/installments/list.md) and [get](https://docs.khaime.com/api-reference/installments/get.md) plans.
* [Webhooks](https://docs.khaime.com/webhooks/events.md): `installment_plan.created`, `.past_due`, `.completed`, `.cancelled`; `installment.paid`, `.failed`, `.due_soon`.
* Every installment also fires `payment.succeeded` with `payment_type: "installment"` and `installment: { plan_id, position, total_installments }`.

### Cancel and refund

* [Cancel a plan](https://docs.khaime.com/api-reference/installments/cancel.md): unpaid installments are cancelled; paid ones stay.
* Refund one installment with [Refunds](https://docs.khaime.com/payments/refunds.md) and `installment: { plan_id, position }`.

### Scope

Endpoints see only your business's plans (plus active sub-merchants for a marketplace operator), in the key's environment. Anything else returns `404 INSTALLMENT_PLAN_NOT_FOUND`.

### Error codes

| `error_code` | HTTP | Meaning |
| - | - | - |
| `INSTALLMENT_PLAN_NOT_FOUND` | 404 | No such plan for this key |
| `INSTALLMENT_NOT_FOUND` | 404 | No installment at that position |
| `INSTALLMENT_ALREADY_PAID` | 409 | Already paid |
| `INSTALLMENT_PAYMENT_METHOD_MISSING` | 400 | No saved card; use a pay link |
| `INSTALLMENT_NOT_ALLOWED` | 400 | Product not sold in installments, plan closed, or invalid template |
| `INSTALLMENT_IDEMPOTENCY_KEY_REQUIRED` | 400 | Charge without `Idempotency-Key` |
| `IDEMPOTENCY_CONFLICT` | 409 | Key reused for a different request, or still running |
| `PAYMENT_CARD_DECLINED` | 402 | Saved card declined |

## Whys

* Per-product templates give every buyer the same terms, matching the quote.
* The first installment reuses checkout, so routing, currency, fees and 3-D Secure work without extra integration.
* Each installment is a normal payment for accounting and refunds; the plan links them.

## Why nots

* Schedule is monthly from the first payment; intervals aren't configurable.
* A template can't mix `percentage` and `amount`.
* Changing a template doesn't change existing plans.
* Each installment must be above the gateway minimum (e.g. \$0.50 Stripe, ₦50 Paystack).
* Storefront installments: one non-physical product per checkout.
* `POST /payment/intent` and `POST /payments/charge` don't support installments: they have no catalog product. Use [Installment Checkout](https://docs.khaime.com/api-reference/installments/checkout.md).
* Cancelling doesn't refund paid installments.
* Defaulting doesn't revoke access automatically.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.