# Peru

### Required fields

| Field                  | Format                                                                                                              | Description                                         |
| ---------------------- | ------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- |
| `login`                | String                                                                                                              | Cashouts login                                      |
| `pass`                 | String                                                                                                              | Cashouts pass                                       |
| `external_id`          | String (max length: 100)                                                                                            | Transaction's ID on your end                        |
| `document_id`          | See [document validations](#document_type-and-document_id-validations)                                              | Beneficiary's document ID                           |
| `document_type`        | See [document validations](#document_type-and-document_id-validations)                                              | Beneficiary's document type                         |
| `country`              | `PE`                                                                                                                | The country codes are in ISO 3166-1 alpha-2 format. |
| `currency`             | `PEN` / `USD`                                                                                                       | The currencies are in ISO 4217 format.              |
| `amount`               | Number with up to 2 decimals                                                                                        | Cashout amount                                      |
| `bank_account`         | See [validations below](/guides/cashouts/countries-validations/american-countries/peru.md#bank-account-validations) | Beneficiary's bank account                          |
| `account_type`         | See[ account types](/guides/cashouts/countries-validations/american-countries/peru.md#account-types)                | Beneficiary's bank account type                     |
| `phone`                | Number 10-11 digits                                                                                                 | Customer's Phone. Mandatory for Yape\&Plin          |
| `beneficiary_name`     | String (max length: 100)                                                                                            | Beneficiary's name                                  |
| `beneficiary_lastname` | String (max length: 100)                                                                                            | Beneficiary's last name                             |

### `bank_account`  validations

<table><thead><tr><th width="121.73828125">Bank name</th><th width="117.09375" align="center">Bank code</th><th width="155.921875">Description</th><th>Format</th><th>Example</th></tr></thead><tbody><tr><td>All</td><td align="center">-</td><td><strong>CCI</strong> - Código de Cuenta Interbancaria</td><td>Length 20 (with verifying digits - a validation algorithm is ran over these)</td><td>00219300153895206813</td></tr><tr><td>Yape</td><td align="center">901</td><td>Empty string</td><td><code>^$</code></td><td></td></tr><tr><td>Plin</td><td align="center">902</td><td>Empty string</td><td><code>^$</code></td><td></td></tr></tbody></table>

#### CCI validation algorithm

Since the first three digits of the CCI are the bank code, it is not mandatory to send the `bank_code` field. However, we validate those 3 first digits to be a valid `bank_code`.

{% tabs %}
{% tab title="Java" %}
{% code title="Peru CCI validation algorithm in Java" %}

```java
public final class Validations {
   static Integer CCI_LENGTH_ST = 18;
   static Integer CCI_LENGTH_FST = 20;
   static String EMPTY_CHECK_DIGITS = "00";
    
   public static boolean validateBankAccount(String bankAccount) {
      if (!ValidationsUtils.validateOnlyNumbers(bankAccount)) {
         return false;
      } else {
         int accountLength = bankAccount.length();
         String lastDigits = bankAccount.substring(bankAccount.length() - 2);

         if (accountLength == CCI_LENGTH_ST && lastDigits.equals(EMPTY_CHECK_DIGITS)) {
            return true;
         }
         return validateCCI(bankAccount);
      }
   }

   //Validate CCI bank account
   public static boolean validateCCI(String cci) {
      if (validateCCILength(cci)) {
         String cciWithoutCheck = cci.substring(0, cci.length() - 2);
         String checkDigits = cci.substring(cci.length() - 2);
         String calculatedCheckDigits = getCciCheckDigits(cciWithoutCheck);

         return checkDigits.equals(calculatedCheckDigits);
      }
      return false;
   }

   public static boolean validateCCILength(String cci) {
      return cci.length() == CCI_LENGTH_FST;
   }

   public static String getCciCheckDigits(String cci) {
      int firstControlNumber = calculateCheckDigit(cci.substring(0, 6));
      int secondControlNumber = calculateCheckDigit(cci.substring(6, 18));

      return String.valueOf(firstControlNumber) + String.valueOf(secondControlNumber);
   }

   private static int calculateCheckDigit(String cci) {
      int total = 0;
      int factor = 1;

      for (int i = 0; i < cci.length(); i++) {
         String[] cciArray = cci.split("");
         int num = Integer.parseInt(cciArray[i]);

         if (num * factor < 10) {
            total += (num * factor);
         } else {
            int product = (num * factor);
            String product_str = Integer.toString(product);
            int firstDigit = Integer.parseInt(product_str.substring(0, 1));
            int lastDigit = product % 10;
            total += firstDigit + lastDigit;
         }

         factor = factor == 1 ? 2 : 1;
      }
      return (total % 10) > 0 ? 10 - (total % 10) : 0;
   }

}
```

{% endcode %}
{% endtab %}
{% endtabs %}

### `account_type`

The `account_type` is specified with only one character as described below.

| account\_type | Description       |
| :-----------: | ----------------- |
|    **`C`**    | Checkings account |
|    **`S`**    | Savings account   |

### `document_type`  and `document_id` validations

<table><thead><tr><th width="166.68359375">document_type</th><th>document_id format</th></tr></thead><tbody><tr><td><code>CE</code>/<code>CPP</code>   </td><td>Numeric. Length 9</td></tr><tr><td><code>DNI</code></td><td>Numeric. Length 8-9</td></tr><tr><td><code>PASS</code></td><td>Numeric. Length 12</td></tr><tr><td><code>RUC</code></td><td>Length 11</td></tr></tbody></table>

### `phone` validations

<table><thead><tr><th width="128.3515625">Bank name</th><th width="123.3359375" align="center">Bank code</th><th width="212.56640625">Format</th><th align="center">Required</th><th>Example</th></tr></thead><tbody><tr><td>Yape</td><td align="center">901</td><td>Numeric - Country code +51 plus 10 digits<br>+51 XXXXXXXXX</td><td align="center">Yes</td><td>+51901671234</td></tr><tr><td>Plin</td><td align="center">902</td><td>Numeric - Country code +51 plus 9 digits<br>+51 XXXXXXXXX</td><td align="center">Yes</td><td>+51901671234</td></tr><tr><td>Others</td><td align="center">-</td><td>-</td><td align="center">No</td><td>-</td></tr></tbody></table>

### Example request

{% tabs %}
{% tab title="Banks" %}

```json
{
    "login": "xxxxxxx",
    "pass": "xxxxxxx",
    "external_id": "30000000001",
    "country": "PE",
    "currency": "PEN",
    "amount": 100,
    "document_id": "848392783",
    "document_type": "CE",
    "bank_account": "00219300153895206813",
    "account_type": "C",
    "beneficiary_name": "User",
    "beneficiary_lastname": "Test",
    "notification_url": "https://webhook.site/url",
    "type": "json"
}
```

{% endtab %}

{% tab title="Yape" %}

<pre class="language-json"><code class="lang-json">{
    "login": "xxxxxxx",
    "pass": "xxxxxxx",
    "external_id": "30000000001",
    "country": "PE",
    "currency": "PEN",
    "amount": 100,
    "document_id": "848392783",
    "document_type": "CE",
<strong>    "bank_code": "901",
</strong><strong>    "bank_account": "",
</strong>    "account_type": "C",
<strong>    "phone":"51901671234",
</strong>    "beneficiary_name": "User",
    "beneficiary_lastname": "Test",
    "notification_url": "https://webhook.site/url",
    "type": "json"
}
</code></pre>

{% endtab %}

{% tab title="Plin" %}

<pre class="language-json"><code class="lang-json">{
    "login": "xxxxxxx",
    "pass": "xxxxxxx",
    "external_id": "30000000001",
    "country": "PE",
    "currency": "PEN",
    "amount": 100,
    "document_id": "848392783",
    "document_type": "CE",
<strong>    "bank_code": "902",
</strong><strong>    "bank_account": "",
</strong>    "account_type": "C",
<strong>    "phone":"51901671234",
</strong>    "beneficiary_name": "User",
    "beneficiary_lastname": "Test",
    "notification_url": "https://webhook.site/url",
    "type": "json"
}
</code></pre>

{% endtab %}
{% endtabs %}

### Bank codes

{% hint style="success" %}

### Bank code retrieval via API

For the full and most up-to-date list of banks and its codes, please check this endpoint <a href="/spaces/VNE8t2FopKfzgQzTjlBb/pages/kD1eu0r7kuzS2nEDm1N9" class="button primary">Get bank codes</a>
{% endhint %}

| Bank                                         | Code |
| -------------------------------------------- | ---- |
| Banco de Crédito del Peru                    | 002  |
| Interbank                                    | 003  |
| Citibank                                     | 007  |
| Scotiabank                                   | 009  |
| BBVA Continental                             | 011  |
| Banco de la Nación                           | 018  |
| Banco de Comercio                            | 023  |
| Banco Financiero                             | 035  |
| Banco Interamericano de Finanzas (BIF)       | 038  |
| Crediscotia Financiera                       | 043  |
| Mi Banco                                     | 049  |
| Banco GNB Peru S.A                           | 053  |
| Banco Falabella                              | 054  |
| Santander                                    | 056  |
| Caja Metropolitana de Lima                   | 800  |
| Caja Municipal de Ahorro y Credito Piura SAC | 801  |
| Caja Municipal de Ahorro y Crédito Trujillo  | 802  |
| Caja Municipal de Ahorro y Crédito Arequipa  | 803  |
| Caja Municipal de Ahorro y Crédito Sullana   | 805  |
| Caja Municipal de Ahorro y Crédito Cuzco     | 806  |
| Caja Municipal de Ahorro y Crédito Huancayo  | 808  |
| Yape                                         | 901  |
| Plin                                         | 902  |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.pandablue.com/guides/cashouts/countries-validations/american-countries/peru.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
