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

# Installments

Attract more customers by allowing them to split purchases into monthly payments. Learn how to easily implement and manage installment plans to boost conversion and average order value.

Localpayment enables merchants to offer installment plans, allowing customers to split their purchases into multiple monthly payments. This guide outlines the process for creating installment plans through Localpayment's API, detailing required parameters, handling responses, and managing the complete installment lifecycle.

## Before You Begin

Ensure you have:

> [card] [API Credentials](https://docs.localpayment.com/docs/api-keys-and-environments.md)
>
> Valid API credentials and access token for authentication.

> [card] [Account Setup](https://docs.localpayment.com/docs/make-your-first-test-payment.md)
>
> Proper account setup for your target country and business verification.

> [card] [IP Whitelisting](https://docs.localpayment.com/docs/dashboard-whitelist-your-ips.md)
>
> Whitelist your server IP addresses for API access.

> [card] [Webhook Endpoint](https://docs.localpayment.com/docs/webhooks.md)
>
> Set up a webhook URL to receive payment notifications.

***

## Step 1: Create Installment Plan Quote

Before processing an installment payment, you need to generate an installment plan quote to present payment options to the customer.

To quote an installment plan, you'll need to send a `POST` request to the [Generate Installment Plan Quote](https://docs.localpayment.com/reference/installments.md) endpoint.

### Key Request Parameters

| Object | Description | Required |
| - | - | - |
| `paymentMethod.code` | Payment method code. Only `CreditCard` methods are supported. | ✅ |
| `amount` | Total transaction amount | ✅ |
| `currency` | Transaction currency code | ✅ |
| `country` | Country where payment will be processed | ✅ |

> [!NOTE]
>
> Installments are available in local currency only. In Peru, you can offer installments on PEN payments but not on USD payments.

### Example Request

Below is an example using `curl`:

```bash curl theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
curl --request POST \
     --url https://api.stage.localpayment.com/api/installments-plans \
     --header 'Authorization: Bearer <your_access_token>' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "paymentMethod": {
    "code": "1600"
  },
  "country": "MEX",
  "currency": "MXN",
  "amount": 1000,
  "accountNumber": "{{accountNumber}}"
}
'
```

See all [available parameters](https://docs.localpayment.com/reference/payins.md) in the request.

***

## Step 2: Handle the Quote Response

### Successful Response

A successful installment quote includes detailed payment plan information:

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
  "installmentsToken": "bc1a1923-fadc-427b-b014-e43eb4462e81",
  "creationDate": "2025-01-29T23:53:52.7150456+00:00",
  "expirationDate": "2025-01-30T00:03:52.71509+00:00",
  "currency": "MXN",
  "amount": 1000,
  "installments": [
        {
            "installments": 3,
            "installmentAmount": 448.98,
            "totalPaymentAmount": 1346.95,
            "financingFee": 346.95
        },
        {
            "installments": 6,
            "installmentAmount": 275.68, 
            "totalPaymentAmount": 1654.12, 
            "financingFee": 654.12
        }
    ]
}
```

### Key Response Fields

| Parameter | Description | Use Case |
| - | - | - |
| `installmentsToken` | Unique token identifying the installment quote | Required for processing the selected installment plan. |
| `creationDate` | Timestamp when the quote was generated. | Track quote validity and timing. |
| `expirationDate` | Timestamp when the quote expires. | Ensure customer selects plan before expiration. |
| `currency` | Currency of the transaction. | Display correct currency symbol to customer. |
| `installments` | Array of available installment options. | Present multiple payment plans to customer. |
| `installments.installments` | Number of monthly payments. | Show payment term duration. |
| `installments.installmentAmount` | Monthly payment amount. | Display monthly cost to customer. |
| `installments.totalPaymentAmount` | Total amount including fees. | Show full cost of financing. |
| `installments.financingFee` | Total financing cost. | Display fees and interest separately. |

### Error Response

When installment quote generation fails::

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
  "status": {
    "code": "300",
    "detail": "Instalment Payment Plan is only for types of Credit Card methods"
  }
}
```

### Best Practices for Installment Presentation

* Display all costs clearly (financing fees, total amount)
* Show monthly payment amounts prominently
* Include comparison between different installment options
* Explain automatic payment process for future installments
* Include customer support information
* Handle token expiration gracefully (**10-minute window**)

***

## Step 3: Process Installment Payment

Once the customer selects an installment plan, process the payment using the installments token.

### Example Request

```bash curl theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
curl --request POST \
  --url https://api.stage.localpayment.com/api/payin/ \
  --header 'Accept: application/json' \
  --header 'Authorization: Bearer <your_access_token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "paymentMethod": {
        "type": "CreditCard",
        "code": "1600",
        "flow": "DIRECT"
    },
    "externalId": "dffbd2a6-6e65-469b-8bbe-dac269882220",
    "country": "MEX",
    "currency": "MXN",
    "amount": 1000,
    "accountNumber": "{{accountNumber}}",
    "conceptCode": "0001",
    "merchant": {
        "type": "COMPANY",
        "name": "Company",
        "document": {
            "type": "RFC",
            "id": "XXX840510XX1"
        },
        "email": "mail@company.com"
    },
    "payer": {
        "type": "INDIVIDUAL",
        "name": "John",
        "lastname": "Doe",
        "document": {
            "type": "RFC",
            "id": "YYY180222YY6"
        },
        "email": "john.doe@example.com"
    },
    "card": {
        "number": "4000000000000002",
        "cvv": "123",
        "expirationMonth": "12",
        "expirationYear": "2029",
        "installments": 3,
        "installmentsToken": "bc1a1923-fadc-427b-b014-e43eb4462e81"
    }
}'
```

***

## Step 4: Track Installment Status

Monitor installment plan progress through these methods:

> [card] [Webhooks (Recommended)](https://docs.localpayment.com/docs/webhooks.md)
>
> Receive real-time notifications for each installment payment and plan status changes.

> [card] [Status API Endpoint](https://docs.localpayment.com/reference/get-transaction-status.md)
>
> Query transaction status programmatically. Useful for polling or recovering lost webhook notifications.

> [card] [Business Portal View](https://docs.localpayment.com/docs/dashboard-overview.md)
>
> Visual interface for monitoring installment plans and payment performance.

### Common Status Codes

The Localpayment API provides various status codes for installment plans and payments.

| Code | Status | Description |
| :- | :- | :- |
| `103` | `APPROVED` | The payin was confirmed but not credited yet. |
| `200` | `Completed` | The payin was completed. |
| `811` | `Rejected` | Requested amount is higher or lower than allowed max/min values. |

> [!NOTE]
>
> **APPROVED is not the final status.** It means the card payment was confirmed, but the funds are not credited to your balance yet. You can see the payment, but you can't withdraw the funds until the status changes to Completed. This usually takes 1 to 2 days, depending on the provider.

> [!NOTE]
>
> **Complete Reference**
>
> View all status codes in our [Transaction Status Documentation](https://docs.localpayment.com/reference/transaction-status-error-codes).

***

## Step 5: Manage Installment Lifecycle

### Installment Payment Flow

```mermaid theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#31467c', 'primaryTextColor': '#ffffff', 'primaryBorderColor': '#0c1a29', 'actorBkg': '#31467c', 'actorBorder': '#0c1a29', 'actorTextColor': '#ffffff', 'actorLineColor': '#0c1a29', 'signalColor': '#0c1a29', 'signalTextColor': '#0c1a29', 'labelBoxBkgColor': '#31467c', 'labelBoxBorderColor': '#0c1a29', 'labelTextColor': '#ffffff', 'loopTextColor': '#0c1a29', 'noteBkgColor': '#ffffff', 'noteBorderColor': '#31467c', 'noteTextColor': '#0c1a29'}}}%%
sequenceDiagram
    participant C as Customer
    participant M as Merchant
    participant LP as Localpayment
    participant B as Bank
    
    C->>M: Initiate payment with installment option
    M->>LP: Request installment quote
    LP->>M: Return installmentsToken and options
    M->>C: Present installment plans
    C->>M: Select preferred plan
    M->>LP: Process payment with installmentsToken
    LP->>B: Authorize first installment
    B->>LP: Authorization confirmed
    LP->>M: Payment confirmation
    M->>C: Display payment result (approved/declined)
    Note over C: Customer receives transaction status and payment plan details
    Note over LP: Monthly installments processed automatically
    LP->>M: Webhook for each installment
```

***

## Testing Your Integration

### Test Scenarios

Verify your integration handles these scenarios:

1. **Successful Installment**: Complete installment payment flow
2. **Multiple Plan Options**: Present different installment terms (2, 3, 6 months)
3. **Token Expiration**: Handle expired installmentsToken (10-minute window)
4. **Status Updates**: Webhook handling and status polling.

***

## Next Steps

After implementing installments, consider these additional capabilities::

> [card] [Refund the transaction](https://docs.localpayment.com/docs/refund-card-payment)
>
> If necessary, you can refund the payment to the customer. Refer to the documentation for details.

> [card] [Review transaction details](https://docs.localpayment.com/reference/get-transaction-status.md)
>
> You can retrieve transaction information using the Localpayment API for detailed insights.


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