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

# ETPAY (Chile)

Localpayment enables merchants to process secure bank transfer payments through ETPAY, Chile's leading payment gateway that facilitates direct bank transfers and authentication with major Chilean financial institutions. This guide outlines the process for initiating ETPAY-based payments through Localpayment's API, detailing required parameters, handling responses, and interpreting status codes for seamless integration with Chile's banking infrastructure.

## Before You Begin

Ensure you have:

* Valid [API credentials](https://docs.localpayment.com/docs/api-keys-and-environments.md) (access token).
* Consult the [banking transaction limits and rules](https://docs.localpayment.com/docs/chile.md#payins-banking-transaction-limits-and-rules).

> [!WARNING]
>
> **Only individual (Home Banking Personas) payments are supported**
>
> This payment method only accepts payments from personal bank accounts. If `payer.type` is sent as `COMPANY`, the transaction will be rejected.

***

## Step 1. Create ETPAY Payment

To initiate an ETPAY payment in Chile, send a `POST` request to the [Create Payin](https://docs.localpayment.com/reference/payins.md) endpoint with ETPAY-specific parameters.

### Key Request Parameters

The request requires several key objects specific to Chile ETPAY payments:

| Object | Description | Required |
| - | - | - |
| `paymentMethod.type` | Must be `BankTransfer`. | ✅ |
| `paymentMethod.code` | Use `2528` for Chile ETPAY. | ✅ |
| `sender` | Sender information for compliance. | ✅ |
| `merchant` | Merchant/business details. | ✅ |
| `paymentMethod` | Payment method configuration. | ✅ |
| `amount` | Transaction amount. | ✅ |
| `currency` | Transaction currency code. | ✅ |
| `country` | Must be `CHL`. | ✅ |

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

### 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/payin/ \
     --header 'accept: application/json' \
     --header 'Authorization: Bearer <your_access_token>' \
     --header 'content-type: application/json' \
     --data '
{
  "paymentMethod": {
    "type": "BankTransfer",
    "code": "2528",
    "flow": "REDIRECT"
  },
  "currency": "CLP",
  "merchant": {
    "type": "INDIVIDUAL",
    "document": {
      "type": "RUT",
      "id": "{{id}}"
    },
    "name": "John",
    "lastname": "Doe",
    "email": "merchant@mail.com"
  },
  "payer": {
    "type": "INDIVIDUAL",
    "document": {
      "type": "RUT",
      "id": "{{id}}"
    },
    "phone": {
      "areaCode": "57",
      "countryCode": "57",
      "number": "12345678"
    },
    "address": {
      "country": "CHL",
      "number": "",
      "state": "RM",
      "city": "RM",
      "street": "Street",
      "comment": ""
    },
    "bank": {
      "account": {
        "type": "c",
        "number": "{{bankAccountNumber}}"
      },
      "name": "Banco Estado",
      "code": "012"
    },
    "name": "John",
    "lastname": "Doe",
    "email": "john.doe@example.com"
  },
  "externalId": "c8b360f1-895e-483d-b734-e3ea17eb2b63",
  "country": "CHL",
  "amount": 100,
  "accountNumber": "{{AccountNumber}}",
  "conceptCode": "0038",
  "comment": "Payer"
}
'
```

***

## Step 2. Handle the Response

### Successful Response

A successful ETPAY payment creation includes the redirect URL and transaction details:

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
  "transactionType": "PayIn",
  "externalId": "7e6c8cd9-55ea-4f94-8f05-f0e13fb24e78",
  "internalId": "6b9dfc0b-1fa0-44b4-a4ff-fd46007ae9a2",
  "paymentMethod": {
    "type": "BankTransfer",
    "code": "2528",
    "flow": "REDIRECT"
  },
  "country": "CHL",
  "currency": "CLP",
  "amount": 100,
  "accountNumber": "{{AccountNumber}}",
  "confirmed": {
    "currency": "CLP",
    "amount": 1,
    "fxQuote": 0
  },
  "payment": {
    "currency": "CLP",
    "fxQuote": 0,
    "financingFee": 0,
    "amount": 1
  },
  "localTaxes": [],
  "withHoldings": [],
  "fees": {
    "description": "Fee",
    "currency": "CLP",
    "fxSource": 1,
    "fxQuote": 1,
    "amount": 0,
    "account": "{{Account}}"
  },
  "status": {
    "code": "100",
    "description": "INPROGRESS",
    "detail": "The payin is pending the confirmation"
  },
  "merchant": {
    "type": "INDIVIDUAL",
    "name": "John",
    "lastname": "Doe",
    "document": {
      "type": "{{Type}}",
      "id": "{{documentId}}"
    },
    "email": "merchant@mail.com"
  },
  "payer": {
    "bank": {
      "name": "Banco Estado",
      "code": "012",
      "account": {
        "type": "c",
        "number": "{{Number}}"
      }
    },
    "type": "INDIVIDUAL",
    "name": "John",
    "lastname": "Doe",
    "document": {
      "type": "RUT",
      "id": "{{documentId}}"
    },
    "email": "john.doe@example.com",
    "phone": {
      "countryCode": "57",
      "areaCode": "57",
      "number": "3196741234"
    },
    "address": {
      "street": "Calle 123",
      "number": "0012",
      "city": "RM",
      "state": "RM",
      "country": "CHL",
      "comment": ""
    }
  },
  "intermediaries": [],
  "wireInstructions": {
    "referenceCode": "FDEG-HVCF-JUWX"
  },
  "date": {
    "creationDate": "2024-12-01T15:44:55.058+00:00",
    "processedDate": "2024-12-01T15:45:01.4368519",
    "expirationDate": "2024-12-08T15:44:55.4677488"
  },
  "redirectUrl": "https://web-checkout.stage.localpayment.com/redirect/aHR0cHM6Ly9wbXQtc2FuZGJveC5ldHBheS5jb20vc2Vzc2lvbi9mT09OZkdvcEVuM1F4RUs4aUZKcWVEdGpadDU5T3ExcjhOamNUM213aFNFbjN0S2sxSzNLcXVtUjk5dTFKTFVS",
  "errors": []
}
```

### Key Response Fields

| Parameter | Description | Use Case |
| - | - | - |
| `redirectUrl` | URL to redirect customer to ETPAY payment flow. | Direct customer to bank authentication and payment processing. |
| `wireInstructions.referenceCode` | Unique payment reference code. | Display to customer for payment tracking. |
| `externalId` | Your original reference number. | Internal reconciliation and order matching. |
| `status.code` | Current transaction state (`100` = `INPROGRESS`) | Determine next steps in payment flow. |
| `date.creationDate` | When transaction was created. | Analytics and performance tracking. |

#### Error Response

When ETPAY payment creation fails for Chile, you'll receive specific error information:

```json theme={"theme":{"light":"github-light-high-contrast","dark":"github-dark-high-contrast"}}
{
  "externalId": "ce0aaa1a-4532-43b9-930a-26e780aba99b",
  "status": {
    "code": "812",
    "description": "REJECTED"
  },
  "errors": [
    {
      "code": "812",
      "detail": "External Id already used - duplication"
    }
  ]
}
```

***

## Step 3. Handle ETPAY Payment Flow

1. **Payment Initiation**: Redirect customer to ETPAY payment url.
2. **Bank Selection**: Customer selects their Chilean bank from supported institutions.
3. **Bank Authentication**: Customer logs into their online banking environment.
4. **Payment Authorization**: Customer confirms payment within their banking interface.
5. **Real-time Confirmation**: Localpayment receives payment notification.
6. **Status Update**: Your system receives webhook with payment confirmation.

***

## Step 4. Track Transaction Status

Monitor ETPAY payment progress through these methods:

> [card] [Webhooks (Recommended)](https://docs.localpayment.com/docs/webhooks.md)
>
> Receive real-time notifications when transaction status changes. Most efficient for production environments.

> [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 transactions. Great for manual oversight and detailed transaction analysis.

### Common Status Codes

The Localpayment API provides various status codes to indicate the progress and outcome of the payment in the response.

| 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]
>
> **Complete Reference**
>
> View all status codes in our [Transaction Status Documentation](https://docs.localpayment.com/reference/transaction-status-error-codes).

***

## Testing Your Integration

### Sandbox Environment

Use the staging environment for testing:

```
https://api.stage.localpayment.com/api/payin/
```

### Test Scenarios for Chile

Verify your integration handles these scenarios:

1. **Successful Payment**: Complete ETPAY payment flow with bank simulation.
2. **Bank Authentication**: Test different bank authentication flows.
3. **Payment Expiration**: Handle payment link expiration gracefully.
4. **Authentication Failure**: Test failed bank login scenarios.
5. **Bank Rejection**: Simulate bank-side payment rejection.
6. **Status Updates**: Webhook handling and status polling.

***

## Next Steps

After implementing ETPAY payments, consider these additional capabilities:

> [card] [Refund the transaction](https://docs.localpayment.com/docs/refund-apm-payment.md)
>
> 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.