# Payku API — 🇨🇱 Chile (EN)

> Official Payku API documentation for Chile, auto-generated from the OpenAPI specification (v2.1.01). Source: https://docs.payku.com/ · Sandbox: https://des.payku.cl/

Base URL: `https://app.payku.cl/` (Default server) · `https://des.payku.cl/` (Sandbox server)

## Introduction

Welcome to the Payku API. You can use our API to access the different
Payku endpoints, where you can generate and manage payments through different
methods and get information from them.

The API is organized around REST. It has predictable URLs and resource-oriented,
and uses HTTP response codes to indicate the result of the call. All API
responses return objects JSON, including errors.

User should look for a 200 result code. If received any result code other
than 200, the request, or the response is invalid, which means that the fields
did not pass the checks of validation from payku. We use features included in
the HTTP protocol, such as authentication, which are supported by the most HTTP
clients.

**Important — How to tell if an operation failed**

Do not rely only on the HTTP status code (for example, 200). In our API, many
error responses also return HTTP 200. This is intentional and part of how the
API is designed.

Always read the JSON response body and check the `status` field:
- If `status` is `"success"`, the operation completed successfully.
- If `status` is `"failed"`, there was an error (for example, invalid data or a
  rejected operation). Also check the error message included in the same response.

## Authentication

Payku uses Token Based Authentication over HTTPS for authentication. To have
access to our API, access your account in the section of Integration you will
find the option of integration and API tokens. The request Unauthenticated or
incorrect will return an Invalid token response.

## API Security

Each request is required to have included in the header:
  - Authorization: Bearer **TOKEN-PÚBLICO**

## Signature

In the case of the subscription, nullification and Mall API, an additional layer of security was added
through of a signature that is sent in the request header, to obtain said signature
is necessary the following:

The Request Path must be concatenated in url format along with all the request
parameters, which must be ordered alphabetically by key, such that key = value.
Therefore, if the client email value is "example@domain.com" the correct format
would be "example%40domain.com" and then concatenated with the character '&'.

Once the character sets are ordered and concatenated, the hash is calculated
using the HMAC function with encryption type sha256, and the private token.

**Note:** If an element of the data has as value an object or array, it is excluded from the data. This function is in the PHP and Javascript example.

### PHP Example
API Endpoint:
```php
$request_path = urlencode('/api/suclient');
```
Sorting the parameters:
```php
$data = [
  'email' => 'support@youwebsite.cl',
  'name' => 'Joe Doe',
  'phone' => '923122312',
  'address' => 'Moneda 101',
  'country' => 'Chile',
  'region' => 'Metropolitana',
  'city' => 'Santiago',
  'postal_code' => '850000',
  'additional_parameters' => [
    'parameter_1' => 'example',
    'parameter_2' => 'example 2',
  ]
];
ksort($data);
```
Transformation of the parameters to url format:
```php
    $contador = 0;
    $concatenar = null;

    if (!empty($data) && !is_null($data)) {
        foreach ($data as $key => $val) {
            if(gettype($val)!='array' && gettype($val)!='object'){
                if ($contador>0) {
                    $concatenar .= '&';
                }
                $concatenar .= $key . '=' . urlencode($val);
                $contador++;
            }
        }
    };
```
Concatenation of the parameters in url format with the API endpoint:
```php
$concat = $request_path.'&'.$concatenar;
```
Sign:
```php
$sign = hash_hmac('sha256', $concat, 'fe551abcef62fcf002dc598922e68f0a');
```

### JavaScript Example
Import CryptoJS dependency:
```javascript
const CryptoJS = require("crypto-js");
```
API Endpoint:
```javascript
const requestPath = encodeURIComponent('/api/suclient');
```
Sorting the parameters:
```javascript
const data = {
  email: "support@youwebsite.cl",
  name: "Joe Doe",
  phone: "923122312",
  address: "Moneda 101",
  country: "Chile",
  region: "Metropolitana",
  city: "Santiago",
  postal_code: "850000"
};
const orderedData = {};
Object.keys(data).sort().forEach(function(key) {
  orderedData[key] = data[key];
  if (typeof orderedData[key] === 'object') {
        delete orderedData[key];
  }
});
```
Transformation of the parameters to url format:
```javascript
const arrayConcat = new URLSearchParams(orderedData).toString();
```
Concatenation of the parameters in url format with the API endpoint:
```javascript
const concat = requestPath + "&" + arrayConcat;
```
Sign:
```javascript
const sign = CryptoJS.HmacSHA256(concat, "fe551abcef62fcf002dc598922e68f0a").toString();
```

The result of the signature obtained for both examples is:

```javascript
"d891663698d31aa8b68babe96ac6497f5a0d874024368102998d5b79a4d12c36"
```

## Errors

Payku uses conventional HTTP responses to indicate the success or failure of a request.
In general, codes in the 2xx range indicate success, codes in the 4xx range indicate
an error that failed due to the information provided (ex: a required parameter was
skipped, a payment failed, etc.), and codes in the 5xx range indicate an error with
Payku servers (these are rare).

## Error codes
<div class="errorContent">
<table>
  <tbody>
    <tr>
      <td style="text-align: right"><strong class="errorTitle">400</strong>
        <p class="psmall">Bad Request</p>
      </td>
      <td class="errorDescription">There is a problem with your request</td>
    </tr>
    <tr>
      <td style="text-align: right"><strong class="errorTitle">401</strong>
        <p class="psmall">Unauthorized</p>
      </td>
      <td class="errorDescription">Your token is incorrect or signature is incorrect</td>
    </tr>
    <tr>
      <td style="text-align: right"><strong class="errorTitle">403</strong>
        <p class="psmall">Forbidden</p>
      </td>
      <td class="errorDescription">You do not have permission to view this page</td>
    </tr>
    <tr>
      <td style="text-align: right"><strong class="errorTitle">404</strong>
        <p class="psmall">Not Found</p>
      </td>
      <td class="errorDescription">The specified resource was not found</td>
    </tr>
    <tr>
      <td style="text-align: right"><strong class="errorTitle">405</strong>
        <p class="psmall">Method Not Allowed</p>
      </td>
      <td class="errorDescription">You tried to enter a resource with an invalid method</td>
    </tr>
    <tr>
      <td style="text-align: right"><strong class="errorTitle">406</strong>
        <p class="psmall">Not Acceptable</p>
      </td>
      <td class="errorDescription">You requested a format other than JSON</td>
    </tr>
    <tr>
      <td style="text-align: right"><strong class="errorTitle">410</strong>
        <p class="psmall">Gone</p>
      </td>
      <td class="errorDescription">The requested resource was removed from our servers</td>
    </tr>
    <tr>
      <td style="text-align: right"><strong class="errorTitle">422</strong>
        <p class="psmall">Unprocessable Entity</p>
      </td>
      <td class="errorDescription">We cannot process your request, please review it.</td>
    </tr>
    <tr>
      <td style="text-align: right"><strong class="errorTitle">429</strong>
        <p class="psmall">Too Many Requests</p>
      </td>
      <td class="errorDescription">You are requesting a lot of resources! Stop!</td>
    </tr>
    <tr>
      <td style="text-align: right"><strong class="errorTitle">500</strong>
        <p class="psmall">Internal Server Error</p>
      </td>
      <td class="errorDescription">We had a problem with our server. Please try again later.</td>
    </tr>
    <tr>
      <td style="text-align: right"><strong class="errorTitle">503</strong>
        <p class="psmall">Service Unavailable</p>
      </td>
      <td class="errorDescription">We are offline for maintenance. Please try again later.</td>
    </tr>
  </tbody>
</table>
</div>

## API access

If you have a payku account, you can access the REST API through the following endpoints:

<div class="content">
  <table class="center smallTable">
    <thead>
      <tr>
        <th style="text-align:center;"><strong>Site</strong></th>
        <th style="text-align:center;"><strong>BASE URL FOR REST ENDPOINT</strong></th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td><strong>Production</strong></td>
        <td align="center"><a href="https://app.payku.cl/api">https://app.payku.cl/api</a></td>
      </tr>
      <tr>
        <td><strong>Sandbox</strong></td>
        <td align="center"><a href="https://des.payku.cl/api">https://des.payku.cl/api</a></td>
      </tr>
    </tbody>
  </table>
</div>

- **Production**: provides direct access to generate actual transactions.
- **Sandbox**: allows you to test your integration without affecting the actual data.

To quickly test our API you can use the Postman collection and environment
from this documentation: <a target="_blank" href="https://docs.payku.com/postman/payku-cl-en.postman_collection.json">Postman collection</a>
and <a target="_blank" href="https://docs.payku.com/postman/payku-environment.postman_environment.json">Postman environment</a>.
They include every endpoint with example bodies and compute the <strong>Sign</strong> signature automatically.

## Test Card

To test transactions use these cards:

<div class="content">
  <table class="center">
    <thead>
      <tr>
        <th style="text-align:center; width:25%"><strong>Card type</strong></th>
        <th style="text-align:center; width:37.5%"><strong>Description</strong></th>
        <th style="text-align:center; width:37.5%"><strong>Result</strong></th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>VISA</td>
        <td align="center">4051 8856 0044 6623 CVV 123 any expiration date</td>
        <td align="center">Generate approved transactions.</td>
      </tr>
      <tr>
        <td>AMEX</td>
        <td align="center">3700 0000 0002 032 CVV 1234 any expiration date</td>
        <td align="center">Generate approved transactions.</td>
      </tr>
      <tr>
        <td>MASTERCARD</td>
        <td align="center">5186 0595 5959 0568 CVV 123 any expiration date</td>
        <td align="center">Generate declined transactions.</td>
      </tr>
      <tr>
        <td>Redcompra</td>
        <td align="center">4051 8842 3993 7763</td>
        <td align="center">Generates approved transactions (for operations that allow Redcompra debit and prepayment)</td>
      </tr>
      <tr>
        <td>Redcompra</td>
        <td align="center">5186 0085 4123 3829</td>
        <td align="center">Generates rejected transactions (for operations that allow Redcompra debit and prepayment)</td>
      </tr>
      <tr>
        <td>Prepago VISA</td>
        <td align="center">4051 8860 0005 6590 CVV 123 any expiration date</td>
        <td align="center">Generate declined transactions.</td>
      </tr>
      <tr>
        <td>Prepago MASTERCARD</td>
        <td align="center">5186 1741 1062 9480 CVV 123 any expiration date</td>
        <td align="center">Generate declined transactions.</td>
      </tr>
    </tbody>
  </table>
</div>

When the authentication form with RUT and password appears, RUT 11.111.111-1 and password 123 must be used.

## Transaction

It allows the creation of transactions and later check their status.
<br>
<div class='container'>
  <img src='https://docs.payku.com/img/diagrams/Diagram-Transaction.png' alt='Avatar' class='image' style='width:100%'>
  <div class='middle'>
    <a target='_blank' href='https://docs.payku.com/img/diagrams/Diagram-Transaction.png' class='text'>View</a>
  </div>
</div>

### Generate a transaction

`POST /api/transaction`

This method allows to create a payment order to **Payku** and receives as a response the **URL** to redirect the payer's browser and the **token** that identifies the transaction.
Once the payer makes the successful payment, **Payku** will notify the result to the page of the business that was sent in the **urlnotify** parameter.

**additional_parameters** = allows sending additional information to be registered in payku associated with the transaction **order_ext** within additional_parameters, it is a reserved word, and it is useful to associate the transaction to a unique merchant identifier

**Request body**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `email` | string | ✓ | Client email. — maximum 100 characters — Example: `joedoe@gmail.com` |
| `order` | string | ✓ | Trade order. — maximum 40 characters — Example: `98745` |
| `subject` | string | ✓ | Description of the order. — maximum 2000 characters — Example: `test subject` |
| `amount` | integer | ✓ | Order amount. — maximum 14 digits — Example: `25000` |
| `currency` | string |  | Currency. — maximum 6 characters — Example: `CLP` |
| `payment` | integer |  | Identifier of the payment method. If the identifier is sent, the payer will be redirected directly to the indicated means of payment. - 99 All - 1 Webpay - 4 Etpay (Transfer) - 6 Pago46 - 9 Mach - 19 Fintoc (Transfer) - 23 Tenpo - 26 Floid (Transfer) - 100 Webpay plus (1 a 3 quotas) - 101 Webpay plus (4 a 6 quotas) - 102 Webpay plus (7 a 12 quotas) — maximum 2 characters — Example: `1` |
| `expired` | string |  | Date on which the transaction expires **This field is not required.** Allowed format (year-month-day hour:minute:second) Example: 2022-10-18 23:59:59 In case of being sent, it must comply with the following rules: - It must be greater than 5 minutes from the current date (Santiago time). - urlreturn is required, it will be attached as parameters GET /?message_error=expired&id=trx60dc327d9e4c094 — Example: `2022-10-19 13:05:10` |
| `urlreturn` | string |  | return url of the merchant where payku will redirect the payer after 3 seconds of obtaining the result of the transaction. — maximum 200 characters — Example: `https://youwebsite.com/urlreturn?orderClient=123` |
| `urlnotify` | string |  | Callback url of the business where payku will notify the payment. - Note: After the client completes the payment process at their bank, payku will automatically respond to the endpoint entered in urlnotify the result of the banking operation. - **Approved Example:** - { - "transaction_id": "9916587765599311", - "payment_key" : "trx32cb779c0a777fc68", - "transaction_key" : "9916581777599311", - "verification_key": "8b3e2202fb086a7de93777ae34d5e18c", - "order": "199", - "status": "success" - } - **Rejected Example:** - { - "transaction_id": "9916587765599311", - "payment_key" : "trx32cb779c0a777fc68", - "transaction_key" : "9916581777599311", - "verification_key": "8b3e2202fb086a7de93777ae34d5e18c", - "order": "199", - "status": "failed" - } — maximum 600 characters — Example: `https://youwebsite.com/urlnotify?orderClient=123` |
| `additional_parameters` | object |  | Additional client parameters. It is mandatory for providers 26 (Floid), 19 (Fintoc), and 4 (Etpay), and optional for the rest of payment methods. — maximum 4000 characters |
| ↳ `parameters1` | string |  | Name of the parameter given by the user payku — Example: `keyValue` |
| ↳ `parameters2` | string |  | Name of the parameter given by the user payku — Example: `keyValue2` |
| ↳ `order_ext` | string |  | Unique identifier provided by the merchant, which allows the transaction to be associated with an external identifier — Example: `fff-777` |
| ↳ `payer_rut` | string |  | RUT to specify a unique payer. It can be used when the **payment** parameter is 26 (Floid), 19 (Fintoc), or 4 (Etpay), and it is a mandatory field for these providers. — Example: `111111111` |
| ↳ `payer_bank` | string |  | Code to preselect the bank. This parameter is optional and will only work when the payment parameter is (Fintoc / Etpay / Floid). You can obtain the values to use in the endpoint api/banks?currency=clp (Optional) — Example: `0001` |

**cURL**

```bash
curl -X POST \
https://BASE-URL/api/transaction \
-H 'Accept: application/json, text/plain, */*' \
-H 'Authorization: Bearer PUBLIC-TOKEN' \
-H 'Content-Type: application/json' \
-H 'Host: BASE-URL' \
-d '{
  "email": "test@domain.com",
  "order": "5696"
  "subject": "Cliente Test",
  "amount": 25000,
  "payment": 1,
  "expired": "2022-10-19 13:05:10",
  "urlreturn": "https://youwebsite.com/urlreturn?orderClient=123",
  "urlnotify": "https://youwebsite.com/urlnotify?orderClient=123",
  "additional_parameters": {
    "parameters1":"keyValue",
    "parameters2":"keyValue2",
    "order_ext":"fff-777"
  }
}'
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('POST', 'https://BASE_URL/api/transaction', [
    'json' => [
      'email' => 'joedoe@gmail.cl',
      'order' => "98745",
      'subject' => 'Client Test',
      'amount' => 25000,
      'payment' => 1,
      'expired' => '2022-10-19 13:05:10',
      'urlreturn' => 'https://youwebsite.com/urlreturn?orderClient=123',
      'urlnotify' => 'https://youwebsite.com/urlnotify?orderClient=123',
        'additional_parameters' => [
          'parameters1'=>'keyValue',
          'parameters2'=>'keyValue2',
          'order_ext'=>'fff-777'
        ]
      ],
    'headers' => [
      'Authorization' => 'Bearer PUBLIC-TOKEN'
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async (data) => {
  const response = await fetch('https://BASE_URL/api/transaction', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
    body: JSON.stringify(data)
  });
  const result = await response.json();
  console.log(result)
}

let data = {
  email: "joedoe@gmail.com",
  order: "98745",
  subject: "test subject",
  amount: 25000,
  payment: 1,
  expired: "2022-10-19 13:05:10",
  urlreturn: "https://youwebsite.com/urlreturn?orderClient=123",
  urlnotify: "https://youwebsite.com/urlnotify?orderClient=123",
  additional_parameters: {
    parameters1:"keyValue",
    parameters2:"keyValue2",
    order_ext:"fff-777"
  }
};

request(data);
```

**Responses**

*200*

```json
{
  "status": "pending",
  "id": "trx32cb779c0a777fc68",
  "url": "https://BASE-URL/payment_url"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Transaction status. The possible statuses you can get are the following: - register - pending - success - rejected - refunded partial - refunded — Example: `pending` |
| `id` | string |  | Transaction identifier created by payku. — Example: `trx32cb779c0a777fc68` |
| `url` | string |  | URL to redirect the user. — Example: `https://BASE-URL/payment_url` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### Get the status of multiple payments

`GET /api/transaction`

you can filter the search for transactions depending on their status. for example. /api/transaction?success=true or to fetch multiple status /api/transaction?pending=true&rejected=true.
  - date_init: indicates the date from which you want to start the transaction search, if this parameter is not sent the search will start with the current date.
  - date_end: indicates the date where you want the transaction search to end, if this parameter is not sent, the search will have the current date as the end date.
  - estatus: you can filter the search for transactions depending on their status. for example: /api/transaction?success=true or to bring multiple statuses /api/transaction?pending=true&rejected=true.

For pagination it is necessary to add the following at the end of the endpoint ?page=1&per_page=100 the first parameter being the page number and the second the number of records per page. In case you want to search for the transactions between the dates 01-09-2021 y 15-09-2021, also that they are only success status transactions, the url to use would be the following:  https://[URL_BASE]/api/transaction?date_init=2021-09-01&date_end=2021-09-15&success=true.

**CURL**

```text
curl -X GET \
https://BASE-URL/api/transaction  \
-H 'Accept: application/json, text/plain, */*' \
-H 'Authorization: Bearer PUBLIC-TOKEN' \
-H 'Content-Type: application/json' \
-H 'Host: BASE-URL' \
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('GET', 'https://BASE_URL/api/transaction', [
    'headers' => [
      'Authorization' => 'Bearer PUBLIC-TOKEN'
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async () => {
  const response = await fetch('https://BASE_URL/api/transaction', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
  });
  const result = await response.json();
  console.log(result)
}

request();
```

**Responses**

*200*

```json
{
  "transaction": [
    {
      "id": "10ac494c1d8da71d98ea",
      "status": "success",
      "created_at": "2019-10-25 14:10:03",
      "email": "alex@onequark.com",
      "amount": "98745",
      "order": "1572023402",
      "subject": "1572023402",
      "payment": {
        "start": "2020-12-16 15:10:33",
        "end": "2020-12-16 15:10:36",
        "media": "Webpay",
        "transaction_id": "107999",
        "transaction_key": null,
        "deposit_date": "2022-10-05",
        "verification_key": "6669cbd982ef54c28f2f15fb9dc5262d",
        "authorization_code": "107742",
        "last_4_digits": "1233",
        "installments": 0,
        "card_type": "",
        "additional_parameters": {
          "identificador": "11.111.111-1",
          "banco": "Banco Estado",
          "numero_cuenta": "00126544977"
        },
        "currency": "CLP"
      },
      "nullify": {
        "status": "complete"
      },
      "gateway_response": {
        "status": "success",
        "message": "successful transaction"
      }
    }
  ]
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `transaction` | array of objects |  |  |
| ↳ `id` | string |  | Identifier of the transaction created by Payku. — Example: `10ac494c1d8da71d98ea` |
| ↳ `status` | string |  | Transaction status The possible statuses you can get are the following: - register - pending - success - rejected — Example: `success` |
| ↳ `created_at` | string |  | Registration date. — Example: `2019-10-25 14:10:03` |
| ↳ `email` | string |  | User email. — Example: `alex@onequark.com` |
| ↳ `amount` | string |  | Amount. — Example: `98745` |
| ↳ `order` | string |  | Order number. — Example: `1572023402` |
| ↳ `subject` | string |  | Description of the purchase order. — Example: `1572023402` |
| ↳ `payment` | object |  |  |
| ↳ ↳ `start` | string |  | Start transaction. — Example: `2020-12-16 15:10:33` |
| ↳ ↳ `end` | string |  | End transaction. — Example: `2020-12-16 15:10:36` |
| ↳ ↳ `media` | string |  | Payment method, used by the user. — Example: `Webpay` |
| ↳ ↳ `transaction_id` | string |  | Identifier of the transaction created by payku. — Example: `107999` |
| ↳ ↳ `transaction_key` | string |  | Transaction identifier created by Payku. |
| ↳ ↳ `deposit_date` | string |  | Date on which the deposit will be made to the client. — Example: `2022-10-05` |
| ↳ ↳ `verification_key` | string |  | Verification code created by Payku. — Example: `6669cbd982ef54c28f2f15fb9dc5262d` |
| ↳ ↳ `authorization_code` | string |  | Authorization code. — Example: `107742` |
| ↳ ↳ `last_4_digits` | string |  | Last 4 digits of the affiliated card. — Example: `1233` |
| ↳ ↳ `installments` | int |  | installments. — Example: `0` |
| ↳ ↳ `card_type` | string |  | Card type. — Example: `` |
| ↳ ↳ `additional_parameters` | object |  | **Example** of additional parameters that Payku can send. |
| ↳ ↳ ↳ `identificador` | string |  | **Example** of transaction identifier: — Example: `11.111.111-1` |
| ↳ ↳ ↳ `banco` | string |  | **Example** of bank where the transaction was made: — Example: `Banco Estado` |
| ↳ ↳ ↳ `numero_cuenta` | string |  | **Example** of account number in which the transaction was made: — Example: `00126544977` |
| ↳ ↳ `currency` | string |  | Currency. — Example: `CLP` |
| ↳ `nullify` | object |  | Object containing abort response information |
| ↳ ↳ `status` | string |  | Cancellation status. The possible statuses you can get are as follows: - pending - awaiting_funds - waiting_bank_details - complete - reverse_deleted - reverse_completed - reverse_deleted — Example: `complete` |
| ↳ `gateway_response` | object |  | Object containing transaction response information |
| ↳ ↳ `status` | string |  | Transaction status The possible statuses you can get are the following: - pending - success - rejected - refunded partial - refunded — Example: `success` |
| ↳ ↳ `message` | string |  | Message describing the status. - successful transaction - Transaction rejected. - Transaction must be retried. - Error transaction. - Rate Error Rejection. - Exceeds maximum monthly quota. - Exceeds daily limit per transaction. - unauthorized item. — Example: `successful transaction` |

*400* — Request error.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Wrong Public Token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

*404* — Identifier does not exist.

```json
{
  "status": "failed",
  "type": "Not Found",
  "id": "is not valid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Not Found` |
| `id` | string |  | Id information — Example: `is not valid` |

### Get status of a payment

`GET /api/transaction/{idTrasaction}`

This method allows you to obtain the information of a payment made in **Payku**

**Path parameters**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | ✓ | id of the transaction to request — maximum 30 characters |

**CURL**

```text
curl -X GET \
https://BASE-URL/api/transaction/ID-IDENTIFICADOR  \
-H 'Accept: application/json, text/plain, */*' \
-H 'Authorization: Bearer PUBLIC-TOKEN' \
-H 'Content-Type: application/json' \
-H 'Host: BASE-URL' \
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('GET', 'https://BASE_URL/api/transaction/10ac494c1d8da71d98ea', [
    'headers' => [
      'Authorization' => 'Bearer PUBLIC-TOKEN'
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async () => {
  const response = await fetch('https://BASE_URL/api/transaction/10ac494c1d8da71d98ea', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
  });
  const result = await response.json();
  console.log(result)
}

request();
```

**Responses**

*200*

```json
{
  "status": "success",
  "id": "10ac494c1d8da71d98ea",
  "created_at": "2019-10-25 14:10:03",
  "order": "1572023402",
  "email": "support@youwebsite.cl",
  "subject": "1572023402",
  "amount": "98745",
  "payment": {
    "start": "2020-12-16 15:10:33",
    "end": "2020-12-16 15:10:36",
    "media": "Webpay",
    "transaction_id": "107999",
    "transaction_key": null,
    "deposit_date": "2022-10-05",
    "verification_key": "6669cbd982ef54c28f2f15fb9dc5262d",
    "authorization_code": "107742",
    "last_4_digits": "1233",
    "installments": 0,
    "card_type": "",
    "additional_parameters": {
      "identificador": "11.111.111-1",
      "banco": "Banco Estado",
      "numero_cuenta": "00126544977",
      "network": {
        "ip_address": "192.0.2.123"
      }
    },
    "currency": "CLP"
  },
  "nullify": {
    "status": "complete"
  },
  "gateway_response": {
    "status": "success",
    "message": "successful transaction"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Transaction status The possible statuses you can get are the following: - register - pending - success - rejected — Example: `success` |
| `id` | string |  | Transaction identifier created by Payku. — Example: `10ac494c1d8da71d98ea` |
| `created_at` | string |  | Registration date. — Example: `2019-10-25 14:10:03` |
| `order` | string |  | Number of order. — Example: `1572023402` |
| `email` | string |  | Client email. — Example: `support@youwebsite.cl` |
| `subject` | string |  | Description of the purchase order. — Example: `1572023402` |
| `amount` | string |  | Amount. — Example: `98745` |
| `payment` | object |  |  |
| ↳ `start` | string |  | Transaction start. — Example: `2020-12-16 15:10:33` |
| ↳ `end` | string |  | Transaction end. — Example: `2020-12-16 15:10:36` |
| ↳ `media` | string |  | Payment method, used by the user. — Example: `Webpay` |
| ↳ `transaction_id` | string |  | Identifier of the transaction created by payku. — Example: `107999` |
| ↳ `transaction_key` | string |  | Transaction identifier created by Payku. |
| ↳ `deposit_date` | string |  | Date on which the deposit will be made to the client. — Example: `2022-10-05` |
| ↳ `verification_key` | string |  | Verification code created by Payku. — Example: `6669cbd982ef54c28f2f15fb9dc5262d` |
| ↳ `authorization_code` | string |  | Authorization code. — Example: `107742` |
| ↳ `last_4_digits` | string |  | Last 4 digits of the affiliated card. — Example: `1233` |
| ↳ `installments` | int |  | installments. — Example: `0` |
| ↳ `card_type` | string |  | Card type. — Example: `` |
| ↳ `additional_parameters` | object |  | **Example** of additional parameters that Payku can send. |
| ↳ ↳ `identificador` | string |  | **Example** of transaction identifier: — Example: `11.111.111-1` |
| ↳ ↳ `banco` | string |  | **Example** of bank where the transaction was made: — Example: `Banco Estado` |
| ↳ ↳ `numero_cuenta` | string |  | **Example** of account number in which the transaction was made: — Example: `00126544977` |
| ↳ ↳ `network` | object |  | User network data: |
| ↳ ↳ ↳ `ip_address` | string |  | **Example** of IP Address of the user: — Example: `192.0.2.123` |
| ↳ `currency` | string |  | Currency. — Example: `CLP` |
| `nullify` | object |  | Objeto que contiene información de la respuesta de la anulación |
| ↳ `status` | string |  | Estatus de anulación. Los posibles estados que puede obtener son los siguientes: - pending - awaiting_funds - waiting_bank_details - complete - reverse_deleted - reverse_completed — Example: `complete` |
| `gateway_response` | object |  | Object containing transaction response information |
| ↳ `status` | string |  | Transaction status The possible statuses you can get are the following: - pending - success - rejected - refunded partial - refunded — Example: `success` |
| ↳ `message` | string |  | Message describing the status. - successful transaction - Transaction rejected. - Transaction must be retried. - Error transaction. - Rate Error Rejection. - Exceeds maximum monthly quota. - Exceeds daily limit per transaction. - unauthorized item. — Example: `successful transaction` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

*404* — Identifier does not exist.

```json
{
  "status": "failed",
  "type": "Not Found",
  "id": "is not valid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Not Found` |
| `id` | string |  | Id information — Example: `is not valid` |

## Escrow Transaction

This functionality will allow escrow accounts authorized by Payku to settle transactions.

### Authorize settlement

`POST /api/escrow`

This method allows authorizing the settlement of one or more transactions using their identifier, so that they can be deposited in the client's wallet or bank account.

**Request body**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `transactions` | array of anys |  | Arrangement containing the identifier of each of the transactions to be authorized for settlement. — maximum 30 characters — Example: `["trx3b4d77b43acd9a720","trx3b4d77b43acd9a385"]` |

**cURL**

```bash
curl -X POST \
https://BASE-URL/api/escrow \
-H 'Accept: application/json, text/plain, */*' \
-H 'Authorization: Bearer PUBLIC-TOKEN' \
-H 'Content-Type: application/json' \
-H 'Host: BASE-URL' \
-d '{
  "transactions": ["trx3b4d77b43acd9a720","trx3b4d77b43acd9a385"]
}'
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('POST', 'https://BASE_URL/api/escrow', [
    'json' => [
      'transactions' => ['trx3b4d77b43acd9a720','trx3b4d77b43acd9a385'],
      ],
    'headers' => [
      'Authorization' => 'Bearer PUBLIC-TOKEN'
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async (data) => {
  const response = await fetch('https://BASE_URL/api/escrow', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
    body: JSON.stringify(data)
  });
  const result = await response.json();
  console.log(result)
}

let data = {
  transactions: ['trx3b4d77b43acd9a720','trx3b4d77b43acd9a385'],
};

request(data);
```

**Responses**

*200*

```json
{
  "transactions": [
    {
      "status": "liquidate",
      "transaction_id": "trx3b4d77b43acd9a720",
      "amount": 15000,
      "availability_date": "2021-07-01",
      "deposit_date": "2021-07-06"
    },
    {
      "status": "pending",
      "transaction_id": "trx3b4d77b43bdd9a540",
      "amount": 20000,
      "availability_date": "2021-07-25",
      "deposit_date": "N/D"
    }
  ]
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `transactions` | array of objects |  | Example: `[{"status":"liquidate","transaction_id":"trx3b4d77b43acd9a720","amount":15000,"availability_date":"2021-07-01","deposit_date":"2021-07-06"},{"status":"pending","transaction_id":"trx3b4d77b43bdd9a540","amount":20000,"availability_date":"2021-07-25","deposit_date":"N/D"}]` |
| ↳ `status` | string |  | Transaction status: - not found - pending - liquidate - pending for deposit - paid |
| ↳ `transaction_id` | string |  | Transaction identifier created by Payku. |
| ↳ `amount` | integer |  | Total amount of traction. |
| ↳ `availability_date` | string |  | Date of availability to authorize the settlement. |
| ↳ `deposit_date` | string |  | Payment date of the settlement. |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

## Nullification

Allows you to request the cancellation of a transaction made through payku.

### Create nullification

`POST /api/nullification`

This method allows you to create a reversal of a transaction.

**Request body**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string |  | Identifier of the transaction which you want to cancel. — maximum 40 characters — Example: `trxpr2a45s1dytg1` |
| `amount` | int |  | Transaction amount. — maximum 14 digits — Example: `25000` |
| `subject` | string |  | description of the cancellation request. — maximum 200 characters — Example: `transaction annulment` |

**cURL**

```bash
curl -X POST \
https://BASE-URL/api/nullification \
-H 'Accept: application/json, text/plain, */*' \
-H 'Authorization: Bearer PUBLIC-TOKEN' \
-H 'Sign: f96ddc14a73a4dd6e009db2514108a3f44832795cd5ac50e6a80fd0b0ae92112' \
-H 'Content-Type: application/json' \
-H 'Host: BASE-URL' \
-d '{
  'id': 'trxpr2a45s1dytg1',
  'amount': 25000,
  'subject': 'nullable request'
}'
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('POST', 'https://BASE_URL/api/nullification', [
    'json' => [
      'id' => 'trxpr2a45s1dytg1',
      'amount' => 25000,
      'subject' => "transaction annulment"
      ],
    'headers' => [
      'Sign' => 'f96ddc14a73a4dd6e009db2514108a3f44832795cd5ac50e6a80fd0b0ae92112',
      'Authorization' => 'Bearer PUBLIC-TOKEN'
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async (data) => {
  const response = await fetch('https://BASE_URL/api/nullification', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Sign': 'f96ddc14a73a4dd6e009db2514108a3f44832795cd5ac50e6a80fd0b0ae92112',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
    body: JSON.stringify(data)
  });
  const result = await response.json();
  console.log(result)
}

let data = {
  'id': 'trxpr2a45s1dytg1',
  'amount': 25000,
  'subject': 'transaction annulment'
};

request(data);
```

**Responses**

*200*

```json
{
  "status": "success",
  "nullify": {
    "id": "trxpr2a45s1dytg1",
    "amount": 25000,
    "currency": "CLP",
    "type": "total",
    "status_nullify": "complete",
    "payment": {
      "gateway": "webpay",
      "payment_type": "VC"
    },
    "created_at": "2017-05-17T19:12:57.189Z",
    "updated_at": "2017-05-17T19:12:57.189Z"
  },
  "gateway_response": {
    "status": "No availability in the wallet",
    "message": "The cancellation will be executed after the amount requested is deducted from your next settlement",
    "nptify": "No availability in the wallet"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Registration status — Example: `success` |
| `nullify` | object |  |  |
| ↳ `id` | string |  | Identifier of the transaction which you want to cancel. — Example: `trxpr2a45s1dytg1` |
| ↳ `amount` | number |  | Transaction amount — Example: `25000` |
| ↳ `currency` | string |  | Currency — Example: `CLP` |
| ↳ `type` | string |  | NotificationTypes of registration: - **total** ( Money available, annulment was executed successfully ) - **partial** ( The total of the funds is not available, it is pending ) — Example: `total` |
| ↳ `status_nullify` | string |  | Annulement status: - **pending** ( Registered pending old--> (register) ) - **awaiting_funds** ( In process (Missing of funds) (partial) ) - **waiting_bank_details** ( Approved (Waiting for customer bank details) Only Debit and other means of payment (waiting_bank_details) ) - **complete** ( Approved (Bank details entered) Only Debit and other means of payment (complete) ) - **complete** ( (Money collected) (complete) ) - **reverse_deleted** ( Request deleted by system (request_deleted) ) - **reverse_completed** ( Annulment made (request_made) ) - **reverse_deleted** ( Disabled (request_deleted) ) — Example: `complete` |
| ↳ `payment` | object |  |  |
| ↳ ↳ `gateway` | string |  | Payment method — Example: `webpay` |
| ↳ ↳ `payment_type` | string |  | Payment type — Example: `VC` |
| ↳ `created_at` | string |  | Cancellation request creation date — Example: `2017-05-17T19:12:57.189Z` |
| ↳ `updated_at` | string |  | Cancellation request update date — Example: `2017-05-17T19:12:57.189Z` |
| `gateway_response` | object |  | Response to the cancellation request |
| ↳ `status` | string |  | Status of registration of the request for annulment — Example: `No availability in the wallet` |
| ↳ `message` | string |  | Application process message — Example: `The cancellation will be executed after the amount requested is deducted from your next settlement` |
| ↳ `nptify` | string |  | Notification on the status of the cancellation request — Example: `No availability in the wallet` |

*400* — Error in the request.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### get nullification

`GET /api/nullification/{identifier}`

This method allows you to obtain nullification requests made to payku by means of an identifier:

To perform the query it is necessary to add the following at the end of the endpoint /{identifier} for example: **api/nullification/trxpr2a45s1dytg1**.

**CURL**

```text
curl -X GET \
https://BASE-URL/api/nullification/{identifier}  \
-H 'Accept: application/json, text/plain, */*' \
-H 'Authorization: Bearer PUBLIC-TOKEN' \
-H 'Content-Type: application/json' \
-H 'Host: BASE-URL' \
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('GET', 'https://BASE_URL/api/nullification/{identifier}', [
    'headers' => [
      'Authorization' => 'Bearer PUBLIC-TOKEN'
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async () => {
  const response = await fetch('https://BASE_URL/api/nullification/{identifier}', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
  });
  const result = await response.json();
  console.log(result)
}

request();
```

**Responses**

*200*

```json
{
  "nullify": {
    "id": "trxpr2a45s1dytg1",
    "amount": 25000,
    "currency": "CLP",
    "type": "total",
    "status_nullify": "complete",
    "payment": {
      "gateway": "webpay",
      "payment_type": "VC"
    },
    "created_at": "2017-05-17T19:12:57.189Z",
    "updated_at": "2017-05-17T19:12:57.189Z"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `nullify` | object |  | Return data from the creation of a cancellation request |
| ↳ `id` | string |  | Identifier of the transfer for which cancellation is to be requested. — Example: `trxpr2a45s1dytg1` |
| ↳ `amount` | number |  | Transaction amount — Example: `25000` |
| ↳ `currency` | string |  | Currency — Example: `CLP` |
| ↳ `type` | string |  | NotificationTypes of registration: - total - partial — Example: `total` |
| ↳ `status_nullify` | string |  | Annulement status: - pending **( Registered pending old--> (register) )** - awaiting_funds **( In process (Missing of funds) (partial) )** - waiting_bank_details **( Approved (Waiting for customer bank details) Only Debit and other means of payment (waiting_bank_details) )** - complete **( Approved (Bank details entered) Only Debit and other means of payment (complete) )** - complete **( (Money collected) (complete) )** - reverse_deleted **( Request deleted by system (request_deleted) )** - reverse_completed **( Annulment made (request_made) )** - reverse_deleted **( Disabled (request_deleted) )** — Example: `complete` |
| ↳ `payment` | object |  |  |
| ↳ ↳ `gateway` | string |  | Payment method — Example: `webpay` |
| ↳ ↳ `payment_type` | string |  | Payment type — Example: `VC` |
| ↳ `created_at` | string |  | Cancellation request creation date — Example: `2017-05-17T19:12:57.189Z` |
| ↳ `updated_at` | string |  | Cancellation request update date — Example: `2017-05-17T19:12:57.189Z` |

*400* — Error in the request.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

*404* — identifier does not exist.

```json
{
  "status": "failed",
  "type": "Not Found",
  "id": "is not valid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Not Found` |
| `id` | string |  | Id information — Example: `is not valid` |

### Generate callback.

`POST callback`

From the payku application, you can generate the notification **url** from the configuration section.

<br>
<div class='container'>
  <img src='https://docs.payku.com/img/diagrams/Show-Url-Notifications.png' alt='Avatar' class='image' style='width:100%'>
  <div class='middle'>
    <a target='_blank' href='https://docs.payku.com/img/diagrams/Show-Url-Notifications.png' class='text'>See example</a>
  </div>
</div>

    Example of callback response:
      {
          "id": "morexxzxxx",
          "id_transaction": "morexxzxxx",
          "ordencompra": "367734544",
          "fecha": "24-08-2023 12:29:35",
          "monto": 7000,
          "status": "complete"
      }

## Marketplace

It allows the registration of clients, to later carry out the distribution according to the assigned percentage.
<br>
<div class='container'>
  <img src='https://docs.payku.com/img/diagrams/Diagram-Marketplace.png' alt='Avatar' class='image' style='width:100%'>
  <div class='middle'>
    <a target='_blank' href='https://docs.payku.com/img/diagrams/Diagrama-Marketplace.png' class='text'>View</a>
  </div>
</div>

### Inserting a client

`POST /api/maclient`

This method allows the insertion of client data.

**Request body**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `email` | string | ✓ | Client email. — maximum 50 characters — Example: `joedoe@gmail.com` |
| `name` | string | ✓ | Client name — maximum 150 characters — Example: `Joe Doe` |
| `phone` | string | ✓ | Client phone. — maximum 12 characters — Example: `923122312` |
| `bank` | object | ✓ | maximum 58 characters |
| ↳ `sbif` | string | ✓ | Bank code to which the bank account belongs. — maximum 5 characters — Example: `0001` |
| ↳ `type` | string | ✓ | Account type. - 1 Checking account - 2 Vista/Cuenta RUT - 3 Saving account — maximum 1 character — Example: `1` |
| ↳ `num` | string | ✓ | Client's account number. — maximum 40 characters — Example: `12312313121` |
| ↳ `rut` | string | ✓ | Single Tax Registry. — 12 characters required — Example: `111111111` |

**CURL**

```text
curl -X POST \
https://BASE_URL/api/maclient \
-H 'Accept: application/json, text/plain, */*' \
-H 'Authorization: Bearer TOKEN_PUBLICO'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE_URL' \
-d {
    "email": "joedoe@gmail.com",
    "name": "Joe Doe",
    "phone": "923122312",
    "bank": {
      "sbif": "1234",
      "type": "1",
      "num": "12312313121",
      "rut": "111111111"
    }
  }'
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('POST', 'https://BASE_URL/api/maclient', [
    'json' => [
      'email' => 'joedoe@gmail.com',
      'name' => 'Joe Doe',
      'phone' => '923122312',
      'bank' => [
        "sbif" => "0001 ",
        "type" => "1",
        "num" => "1231123567",
        "rut" => "111111111",
      ]
    ],
    'headers' => [
      'Authorization' => 'Bearer PUBLIC-TOKEN'
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async (data) => {
  const response = await fetch('https://BASE_URL/api/maclient', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
    body: JSON.stringify(data)
  });
  const result = await response.json();
  console.log(result)
}

let data = {
  email: "joedoe@gmail.com",
  name: "Joe Doe",
  phone: "923122312",
  bank: {
    sbif: "1234",
    type: "1",
    num: "12312313121",
    rut: "111111111"
  }
};

request(data);
```

**Responses**

*200*

```json
{
  "id": "madb93fc00a2cf6f4449",
  "status": "register",
  "name": "Joe Doe",
  "phone": "923122312",
  "email": "joedoe@gmail.com",
  "bank": {
    "sbif": "1234",
    "type": "1",
    "num": "12312313121",
    "rut": "111111111"
  },
  "affiliations": 0,
  "created_at": "2020-09-28 20:42:59",
  "update_at": "null"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string |  | Identifier created by payku. — Example: `madb93fc00a2cf6f4449` |
| `status` | string |  | Client status. — Example: `register` |
| `name` | string |  | Client name. — Example: `Joe Doe` |
| `phone` | string |  | Client phone. — Example: `923122312` |
| `email` | string |  | Client email. — Example: `joedoe@gmail.com` |
| `bank` | object |  |  |
| ↳ `sbif` | string |  | Bank code. — Example: `1234` |
| ↳ `type` | string |  | Account type. - 1 Checking account - 2 Vista/Cuenta RUT - 3 Saving account — Example: `1` |
| ↳ `num` | string |  | Client's account number. — Example: `12312313121` |
| ↳ `rut` | string |  | Single Tax Registry. — Example: `111111111` |
| `affiliations` | integer |  | Number of affiliations. — Example: `0` |
| `created_at` | string |  | Registration date. — Example: `2020-09-28 20:42:59` |
| `update_at` | string |  | Update date. — Example: `null` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### Query client data

`GET /api/maclient/{idClient}`

This method allows obtaining the details of a client.

**Path parameters**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | ✓ | Unique identifier per payku. — maximum 20 characters |

**CURL**

```text
curl -X GET \
https://BASE_URL/api/maclient/id \
-H 'Accept: application/json, text/plain, */*' \
-H 'Authorization: Bearer TOKEN_PUBLICO'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE_URL' \
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('GET', 'https://BASE_URL/api/maclient/madb93fc00a2cf6f4449', [
    'headers' => [
      'Authorization' => 'Bearer PUBLIC-TOKEN'
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async () => {
  const response = await fetch('https://BASE_URL/api/maclient/madb93fc00a2cf6f4449', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
  });
  const result = await response.json();
  console.log(result)
}

request();
```

**Responses**

*200*

```json
{
  "id": "madb93fc00a2cf6f4449",
  "status": "register",
  "name": "Joe Doe",
  "phone": "923122312",
  "email": "joedoe@gmail.com",
  "bank": {
    "sbif": "1234",
    "type": "1",
    "num": "12312313121",
    "rut": "111111111"
  },
  "affiliations": 0,
  "created_at": "2020-09-28 20:42:59",
  "update_at": "null"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string |  | Identifier created by payku. — Example: `madb93fc00a2cf6f4449` |
| `status` | string |  | Client status. — Example: `register` |
| `name` | string |  | Client name. — Example: `Joe Doe` |
| `phone` | string |  | Client phone. — Example: `923122312` |
| `email` | string |  | Client email. — Example: `joedoe@gmail.com` |
| `bank` | object |  |  |
| ↳ `sbif` | string |  | Bank code. — Example: `1234` |
| ↳ `type` | string |  | Account type. - 1 Checking account - 2 Vista/Cuenta RUT - 3 Saving account — Example: `1` |
| ↳ `num` | string |  | Client's account number. — Example: `12312313121` |
| ↳ `rut` | string |  | Single Tax Registry. — Example: `111111111` |
| `affiliations` | integer |  | Number of affiliations. — Example: `0` |
| `created_at` | string |  | Registration date. — Example: `2020-09-28 20:42:59` |
| `update_at` | string |  | Update date. — Example: `null` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### update client

`PUT /api/maclient/{idClient}`

This method allows updating the data of a client.

**Path parameters**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | ✓ | Unique marketplace identifier. — maximum 20 characters |

**Request body**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string |  | Client name — maximum 50 characters — Example: `Joe Doe Doe` |
| `phone` | string |  | Client phone — maximum 50 characters — Example: `923122312` |
| `bank` | object |  | Client bank details — maximum 58 characters |
| ↳ `sbif` | string |  | Code of the bank to which the bank account belongs. — maximum 5 characters — Example: `0001` |
| ↳ `type` | int |  | Account type. - 1 Checking account - 2 Vista/Cuenta RUT - 3 Saving account — maximum 1 character — Example: `3` |
| ↳ `num` | string |  | Client's account number. — maximum 40 characters — Example: `9999999` |
| ↳ `rut` | string |  | Single Tax Registry. — 12 characters required — Example: `111111111` |

**CURL**

```text
curl -X PUT \
https://BASE_URL/api/maclient/id \
-H 'Accept: application/json, text/plain, */*' \
-H 'Sign: SIGN'  \
-H 'Authorization: Bearer TOKEN_PUBLICO'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE_URL' \
-d {
    "name":"Joe Doe",
    "phone":"923122312",
    "bank": {
      "sbif": "0001",
      "type": "3",
      "num": "9999999",
      "rut": "261009617"
      }
    }'
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('PUT', 'https://BASE_URL/api/maclient/madb93fc00a2cf6f4449', [
    'json' => [
      'name' => 'Joe Doe',
      'phone' => '923122312',
      'bank' => [
          'num' => '9999999',
          'rut' => '261009617'
        ]
      ],
    ],
  ],
  'headers' => [
    'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
    'Authorization' => 'Bearer PUBLIC-TOKEN'
  ]
])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async (data) => {
  const response = await fetch('https://BASE_URL/api/maclient/madb93fc00a2cf6f4449', {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
      'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
    body: JSON.stringify(data)
  });
  const result = await response.json();
  console.log(result)
}

let data = {
name:"Joe Doe",
phone:"923122312",
bank: {
  sbif: "0001",
  type: "3",
  num: "9999999",
  rut: "261009617"
  }
};

request(data);
```

**Responses**

*200*

```json
{
  "id": "cl0be4c8e623c167bc8b777",
  "status": "register",
  "name": "Joe Doe",
  "phone": "923122312",
  "email": "923122312",
  "bank": {
    "sbif": "0001",
    "type": "3",
    "num": "9999999",
    "rut": "261009617"
  },
  "affiliations": 2,
  "affiliations_details": [
    [
      {
        "id": "s6df85b41df65b21se685",
        "status": "register",
        "token": "sgh65g1ns6fg5n1sfg2sr6j5nfg65shr6gh5s4r6h5fg6",
        "name": "market1",
        "percentage_affiliation": 1,
        "percentage_client": 99
      },
      {
        "id": "s6df85b41df65b21se685",
        "status": "register",
        "token": "sgh65g1ns6fg5n1sfg2sr6j5nfg65shr6gh5s4r6h5fg6",
        "name": "market2",
        "percentage_affiliation": 1,
        "percentage_client": 99
      }
    ]
  ]
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string |  | Marketplace identifier. — Example: `cl0be4c8e623c167bc8b777` |
| `status` | string |  | Client status. — Example: `register` |
| `name` | string |  | Client name. — Example: `Joe Doe` |
| `phone` | string |  | Client phone. — Example: `923122312` |
| `email` | string |  | Client email. — Example: `923122312` |
| `bank` | object |  | Client bank details. |
| ↳ `sbif` | string |  | Code of the bank to which the bank account belongs. — Example: `0001` |
| ↳ `type` | string |  | Client account type. — Example: `3` |
| ↳ `num` | string |  | Client bank account. — Example: `9999999` |
| ↳ `rut` | string |  | Client rut — Example: `261009617` |
| `affiliations` | number |  | Number of affiliations. — Example: `2` |
| `affiliations_details` | array of objects |  |  |
| ↳ `id` | string |  | Afiliation identifier. |
| ↳ `status` | string |  | Afiliation status: - not found - pending - liquidate - pending for deposit - paid |
| ↳ `token` | string |  | Afiliation Token. |
| ↳ `name` | string |  | Afiliation name. |
| ↳ `percentage_affiliation` | string |  | Afiliation porcentage. |
| ↳ `percentage_client` | string |  | Cliente porcentage. |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### Delete client

`DELETE /api/maclient/{idClient}`

This method allows the removal of a client associated with an id.

**Path parameters**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | ✓ | Unique customer identifier per payku. — maximum 20 characters |

**CURL**

```text
curl -X DELETE \
https://BASE_URL/api/maclient/id \
-H 'Accept: application/json, text/plain, */*' \
-H 'Authorization: Bearer TOKEN_PUBLICO'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE_URL' \
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('DELETE', 'https://BASE_URL/api/maclient/madb93fc00a2cf6f4449', [
      'headers' => [
        'Authorization' => 'Bearer PUBLIC-TOKEN'              ]
      ])->getBody();
    $response = json_decode($body);
```

**JS**

```js
const request = async () => {
  const response = await fetch('https://BASE_URL/api/maclient/madb93fc00a2cf6f4449', {
    method: 'DELETE',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
  });
  const result = await response.json();
  console.log(result)
}

request();
```

**Responses**

*200*

```json
{
  "status": "suspended",
  "id": "madb93fc00a2cf6f4449"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Client status. — Example: `suspended` |
| `id` | string |  | Transaction identifier created by payku. — Example: `madb93fc00a2cf6f4449` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### Manage Memberships

`POST /api/maaffiliation`

This method allows you to register the data for membership.

**Request body**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | ✓ | Membership name. — maximum 80 characters — Example: `name` |
| `percentage` | string | ✓ | Percentage corresponding to the payku user. — maximum 2 characters — Example: `20` |
| `affiliation` | array of anys | ✓ | Array containing customers, each customer is an array containing a customer identifier created by payku and the percentage that it will get. — maximum 25 characters — Example: `[["madb93fc00a2cf6f4449","80"]]` |

**CURL**

```text
curl -X POST \
https://BASE_URL/api/maaffiliation \
-H 'Accept: application/json, text/plain, */*' \
-H 'Authorization: Bearer TOKEN_PUBLICO'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE_URL' \
-d {
    "name": "name",
    "percentage": "20",
    "affiliation": [
      ["ma9fd16221a9645b0036","80"]
    ]
  }'
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('POST', 'https://BASE_URL/api/maaffiliation', [
    'json' => [
      'name' => 'name',
      'percentage' => '20',
      'affiliation' => [
        [ma9fd16221a9645b0036,80]
      ]
    ],
    'headers' => [
      'Authorization' => 'Bearer PUBLIC-TOKEN'
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async (data) => {
  const response = await fetch('https://BASE_URL/api/maaffiliation', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
    body: JSON.stringify(data)
  });
  const result = await response.json();
  console.log(result)
}

let data = {
  name: "name",
  percentage: "20",
  affiliation: [
    ["ma9fd16221a9645b0036","80"]
  ]
};

request(data);
```

**Responses**

*200*

```json
{
  "id": "sucaab7865dceaff49d8b3",
  "status": "register",
  "name": "name",
  "token": "eecd92fdbb8bf615e8215d6fbb30bb6ae6f82c9e1810f85b65bbeb472794c4a4",
  "percentage": "20.00",
  "affiliations": [
    {
      "id": "ma9fd16221a9645b0036",
      "name": "name",
      "percentage": "80.00"
    }
  ]
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string |  | Unique subscription identifier for payku. — Example: `sucaab7865dceaff49d8b3` |
| `status` | string |  | Status. — Example: `register` |
| `name` | string |  | Membership name. — Example: `name` |
| `token` | string |  | Affiliate Token that is entered into the merchant. — Example: `eecd92fdbb8bf615e8215d6fbb30bb6ae6f82c9e1810f85b65bbeb472794c4a4` |
| `percentage` | string |  | Payku user affiliation percentage. — Example: `20.00` |
| `affiliations` | array of objects |  |  |
| ↳ `id` | string |  | Identifier. — Example: `ma9fd16221a9645b0036` |
| ↳ `name` | string |  | Affiliate name. — Example: `name` |
| ↳ `percentage` | string |  | Percentage corresponding to each affiliate. — Example: `80.00` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### Check membership data

`GET /api/maaffiliation/{idClient}`

This method allows you to obtain the details of an membership.

**Path parameters**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | ✓ | Unique membership identifier for payku. — maximum 20 characters |

**CURL**

```text
curl -X GET \
https://BASE_URL/api/maaffiliation/id \
-H 'Accept: application/json, text/plain, */*' \
-H 'Authorization: Bearer TOKEN_PUBLICO'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE_URL' \
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('GET', 'https://BASE_URL/api/maaffiliation/sucaab7865dceaff49d8b3', [
    'headers' => [
      'Authorization' => 'Bearer PUBLIC-TOKEN'
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async () => {
  const response = await fetch('https://BASE_URL/api/maaffiliation/sucaab7865dceaff49d8b3', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
  });
  const result = await response.json();
  console.log(result)
}

request();
```

**Responses**

*200*

```json
{
  "id": "sucaab7865dceaff49d8b3",
  "status": "register",
  "name": "name",
  "token": "eecd92fdbb8bf615e8215d6fbb30bb6ae6f82c9e1810f85b65bbeb472794c4a4",
  "percentage": "20.00",
  "affiliations": [
    {
      "id": "ma9fd16221a9645b0036",
      "name": "name",
      "percentage": "80.00"
    }
  ]
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string |  | Unique subscription identifier for payku. — Example: `sucaab7865dceaff49d8b3` |
| `status` | string |  | Status. — Example: `register` |
| `name` | string |  | Membership name. — Example: `name` |
| `token` | string |  | Affiliate Token that is entered into the merchant. — Example: `eecd92fdbb8bf615e8215d6fbb30bb6ae6f82c9e1810f85b65bbeb472794c4a4` |
| `percentage` | string |  | Payku user affiliation percentage. — Example: `20.00` |
| `affiliations` | array of objects |  |  |
| ↳ `id` | string |  | Identifier. — Example: `ma9fd16221a9645b0036` |
| ↳ `name` | string |  | Affiliate name. — Example: `name` |
| ↳ `percentage` | string |  | Percentage corresponding to each affiliate. — Example: `80.00` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### Remove membership

`DELETE /api/maaffiliation/{idClient}`

This method allows the removal of an membership associated with an id.

**Path parameters**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | ✓ | Unique client identifier per payku. — maximum 20 characters |

**CURL**

```text
curl -X DELETE \
https://BASE_URL/api/maaffiliation/id \
-H 'Accept: application/json, text/plain, */*' \
-H 'Authorization: Bearer TOKEN_PUBLICO'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE_URL' \
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('DELETE', 'https://BASE_URL/api/maaffiliation/madb93fc00a2cf6f4449', [
      'headers' => [
        'Authorization' => 'Bearer PUBLIC-TOKEN'              ]
      ])->getBody();
    $response = json_decode($body);
```

**JS**

```js
const request = async () => {
  const response = await fetch('https://BASE_URL/api/maaffiliation/sucaab7865dceaff49d8b3', {
    method: 'DELETE',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
  });
  const result = await response.json();
  console.log(result)
}

request();
```

**Responses**

*200*

```json
{
  "status": "suspended",
  "id": "eecd92fdbb8bf615e821"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Membership status. — Example: `suspended` |
| `id` | string |  | Transaction identifier created by payku. — Example: `eecd92fdbb8bf615e821` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### Generate a Marketplace transaction

`POST /api/transaction/`

This method allows to create a payment order to **Payku** and receives as a response the **URL** to redirect the payer's browser and the **token** that identifies the transaction. Once the payer makes the successful payment, **Payku** will notify the result to the page of the business that was sent in the **urlnotify** parameter.

**Request body**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `email` | string | ✓ | Client email. — maximum 50 characters — Example: `joedoe@gmail.com` |
| `order` | string | ✓ | Trade order. — maximum 40 characters — Example: `98745` |
| `subject` | string | ✓ | Description of the order. — maximum 2000 characters — Example: `test subject` |
| `amount` | integer | ✓ | Order amount. — maximum 14 digits — Example: `25000` |
| `payment` | integer |  | Identifier of the payment method. If the identifier is sent, the payer will be redirected directly to the indicated means of payment. - 1 Webpay - 4 Etpay (Transfer) - 6 Pago46 - 9 Mach - 19 Fintoc (Transfer) - 23 Tenpo - 26 Floid (Transfer) - 99 All — maximum 2 characters — Example: `1` |
| `urlreturn` | string |  | return url of the trade where payku will redirect the payer. — maximum 200 characters — Example: `https://youwebsite.com/urlreturn?orderClient=123` |
| `urlnotify` | string |  | Callback url of the business where payku will notify the payment. — maximum 600 characters — Example: `https://youwebsite.com/urlnotify?orderClient=123` |
| `marketplace` | string |  | Mandatory attribute to make transactions to Marketplace affiliation, this consists of the token of the marketplace affiliation to which you want to carry out the transaction. — maximum 70 characters — Example: `c1c879f4862d393ea6b326a313022dd98f0baa2869d3e9095c124199c9941030` |

**cURL**

```bash
curl -X POST \
https://BASE-URL/api/transaction \
-H 'Accept: application/json, text/plain, */*' \
-H 'Authorization: Bearer PUBLIC-TOKEN' \
-H 'Content-Type: application/json' \
-H 'Host: BASE-URL' \
-d '{
  "email": "test@domain.com",
  "order": "5696"
  "subject": "Cliente Test",
  "amount": 25000,
  "payment": 1,
  "urlreturn": "https://youwebsite.com/urlreturn?orderClient=123",
  "urlnotify": "https://youwebsite.com/urlnotify?orderClient=123",
  "marketplace": "c1c879f4862d393ea6b326a313022dd98f0baa2869d3e9095c124199c9941030"
}'
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('POST', 'https://BASE_URL/api/transaction', [
    'json' => [
      'email' => 'joedoe@gmail.cl',
      'order' => "98745",
      'subject' => 'Client Test',
      'amount' => 25000,
      'payment' => 1,
      'urlreturn' => 'https://youwebsite.com/urlreturn?orderClient=123',
      'urlnotify' => 'https://youwebsite.com/urlnotify?orderClient=123',
      'marketplace' => 'c1c879f4862d393ea6b326a313022dd98f0baa2869d3e9095c124199c9941030'
      ],
    'headers' => [
      'Authorization' => 'Bearer PUBLIC-TOKEN'
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async (data) => {
  const response = await fetch('https://BASE_URL/api/transaction', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
    body: JSON.stringify(data)
  });
  const result = await response.json();
  console.log(result)
}

let data = {
  email: "joedoe@gmail.com",
  order: "98745",
  subject: "test subject",
  amount: 25000,
  payment: 1,
  urlreturn: "https://youwebsite.com/urlreturn?orderClient=123",
  urlnotify: "https://youwebsite.com/urlnotify?orderClient=123",
  marketplace: c1c879f4862d393ea6b326a313022dd98f0baa2869d3e9095c124199c9941030
};

request(data);
```

**Responses**

*200*

```json
{
  "status": "pending",
  "id": "ma32cb779c0a777fc68",
  "url": "https://BASE-URL/payment_url"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Transaction status The possible statuses you can get are the following: - pending - success - rejected - refunded partial - refunded — Example: `pending` |
| `id` | string |  | Transaction identifier created by payku. — Example: `ma32cb779c0a777fc68` |
| `url` | string |  | URL to redirect the user. — Example: `https://BASE-URL/payment_url` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

## Mall

The product has been specially designed for those integrating companies of different brands with different lines of business which can be grouped while maintaining their diversity in the same virtual space or mall.

Offering the possibility of grouping the payment of purchases made in multiple virtual stores in a single transaction.
<br>
<div class='container'>
  <img src='https://docs.payku.com/img/diagrams/Diagram-Mall.png' alt='Avatar' class='image' style='width:100%'>
  <div class='middle'>
    <a target='_blank' href='https://docs.payku.com/img/diagrams/Diagram-Mall.png' class='text'>View</a>
  </div>
</div>

### Create Mall transaction

`POST /api/mall`

This method allows the insertion of data from a transaction.

**Request body**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `email` | string | ✓ | Customer email. — maximum 50 characters — Example: `joedoe@gmail.com` |
| `payment` | integer | ✓ | Identifier of the payment method. If the identifier is sent, the payer will be redirected directly to the indicated means of payment. - 1 Webpay - 4 Etpay (Transfer) - 6 Pago46 - 9 Mach - 19 Fintoc (Transfer) - 23 Tenpo - 26 Floid (Transfer) - 99 All — maximum 2 characters — Example: `1` |
| `merchant` | array of arrays | ✓ | Array containing the clients, each client is an array containing its public token or marketplace affiliation id, transaction value, description, id of the specific event which if not owned must pass null and individual order number. — maximum 200 characters — Example: `[["81b6179e4feeef2b50af71d660f830de",30000,"item1",null,"4545"],["bcf6c06c523d9394be41bc0174c43d1476f274abb342955aac93cc8014737b3b",25000,"item2",null,"4546"],["81b6179e4fffff2b50af71d66f7830de",15000,"item3",null,"4547"]]` |
| `order` | integer | ✓ | Trade order, this must be unique. — maximum 40 characters — Example: `123` |
| `urlreturn` | string | ✓ | return url of the trade where payku will redirect the payer. — maximum 200 characters — Example: `https://youwebsite.cl/urlreturn` |
| `urlnotify` | string |  | callback url of the business where payku will notify the payment. — maximum 600 characters — Example: `https://youwebsite.cl/urlnotify` |

**CURL**

```text
curl -X POST \
https://BASE_URL/api/mall \
-H 'Accept: application/json, text/plain, */*' \
-H 'Sign: SIGN  \
-H 'Authorization: Bearer TOKEN_PUBLICO  \
-H 'Content-Type: application/json' \
-H 'Host: BASE_URL' \
-d {
    "email": "joedoe@gmail.com",
    "payment": 1,
    "merchant": [
      ["81b6179e4feeef2b50af71d660f830de", "30000", "item1", null, "4545"],
      ["bcf6c06c523d9394be41bc0174c43d1476f274abb342955aac93cc8014737b3b","25000","item2", null, "4546"],
      ["PUBLIC-TOKEN","15000","item3", null, "4547"]
    ],
    "order": 123,
    "urlreturn": "https://youwebsite.cl/urlreturn",
    "urlnotify": "https://youwebsite.cl/urlnotify"
  }'
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('POST', 'https://BASE_URL/api/mall', [
    'json' => [
      'email'         => 'joedoe@gmail.com',
      'payment'       => 1,
      'merchant'      => [
        ['81b6179e4feeef2b50af71d660f830de', '30000', 'item1', null, '4545'],
        ['bcf6c06c523d9394be41bc0174c43d1476f274abb342955aac93cc8014737b3b','25000','item2', null, '4546'],
        ['PUBLIC-TOKEN','15000','item3', null, '4547']
      ],
      'order'         => 123,
      'urlreturn'     => 'https://youwebsite.cl/urlreturn',
      'urlnotify'     => 'https://youwebsite.cl/urlnotify'
      ],
    'headers' => [
      'Sign' => 'f96ddc14a73a4dd6e009db2514108a3f44832795cd5ac50e6a80fd0b0ae92112',
      'Authorization' => 'Bearer PUBLIC-TOKEN'
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async (data) => {
  const response = await fetch('https://BASE_URL/api/mall', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Sign': 'f96ddc14a73a4dd6e009db2514108a3f44832795cd5ac50e6a80fd0b0ae92112',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
    body: JSON.stringify(data)
  });
  const result = await response.json();
  console.log(result)
}
let data = {
  email: "joedoe@gmail.com",
  payment: 1,
  merchant: [
    ["81b6179e4feeef2b50af71d660f830de", "30000", "item1", null, "4545"],
    ["bcf6c06c523d9394be41bc0174c43d1476f274abb342955aac93cc8014737b3b","25000","item2", null, "4546"],
    ["PUBLIC-TOKEN","15000","item3", null, "4547"]
  ],
  order: 123,
  urlreturn: "https://youwebsite.cl/urlreturn",
  urlnotify: "https://youwebsite.cl/urlnotify"
};
request(data);
```

**Responses**

*200*

```json
{
  "status": "success",
  "individual_orders": [
    {
      "merchant": "81b6179e4feeef2b50af71d660f830de",
      "amount": 30000,
      "subject": "item1",
      "event": null,
      "identificador": "9917068816213146",
      "individual_order": "9654"
    },
    {
      "merchant": "81b6179e4feeef2b50af71d66f7830de",
      "amount": 25000,
      "subject": "item2",
      "event": null,
      "identificador": "9917068816213146",
      "individual_order": "9654"
    },
    {
      "merchant": "81b6179e4fffff2b50af71d66f7830de",
      "amount": 15000,
      "subject": "item3",
      "event": null,
      "identificador": "9917068816213146",
      "individual_order": "9654"
    }
  ],
  "url": "https://BASE_URL/gateway/mall/malld200058ab44739ddee2adcd2f5"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Transaction status The possible statuses you can get are the following: - pending - success - rejected - refunded partial - refunded — Example: `success` |
| `individual_orders` | array of objects |  | Arrangement containing beneficiary information. — Example: `[{"merchant":"81b6179e4feeef2b50af71d660f830de","amount":30000,"subject":"item1","event":null,"identificador":"9917068816213146","individual_order":"9654"},{"merchant":"81b6179e4feeef2b50af71d66f7830de","amount":25000,"subject":"item2","event":null,"identificador":"9917068816213146","individual_order":"9654"},{"merchant":"81b6179e4fffff2b50af71d66f7830de","amount":15000,"subject":"item3","event":null,"identificador":"9917068816213146","individual_order":"9654"}]` |
| ↳ `merchant` | string |  | Beneficiary's name. |
| ↳ `amount` | string |  | Amount of the product or service. |
| ↳ `detail` | string |  | Description of the transaction. |
| ↳ `event` | string |  | ID of the event, if it does not have event it must pass null. |
| ↳ `identificador` | string |  | Transaction identifier. — Example: `9917068816213146` |
| ↳ `individual_order` | string |  | Individual transaction identifier. — Example: `4546` |
| `url` | string |  | URL has redirect user. — Example: `https://BASE_URL/gateway/mall/malld200058ab44739ddee2adcd2f5` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Wrong Public Token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### Get Mall transaction

`GET /api/mall/{identificadorTrasaccion}`

This method allows you to obtain the information of a payment made in **Payku**

**Path parameters**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | ✓ | id of the transaction to request — maximum 30 characters |

**CURL**

```text
curl -X GET \
https://BASE-URL/api/mall/ID-IDENTIFICADOR  \
-H 'Accept: application/json, text/plain, */*' \
-H 'Authorization: Bearer PUBLIC-TOKEN' \
-H 'Content-Type: application/json' \
-H 'Host: BASE-URL ' \
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('GET', 'https://BASE_URL/api/mall/malld200058ab44739ddee2adcd2f5', [
    'headers' => [
      'Sign' => 'f96ddc14a73a4dd6e009db2514108a3f44832795cd5ac50e6a80fd0b0ae92112',
      'Authorization' => 'Bearer PUBLIC-TOKEN'
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async () => {
  const response = await fetch('https://BASE_URL/api/mall/malld200058ab44739ddee2adcd2f5', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
      'Sign' => 'f96ddc14a73a4dd6e009db2514108a3f44832795cd5ac50e6a80fd0b0ae92112',
      'Authorization' => 'Bearer PUBLIC-TOKEN'
    },
  });
  const result = await response.json();
  console.log(result)
}
request();
```

**Responses**

*200*

```json
{
  "status": "success",
  "id": "10ac494c1d8da71d98ea",
  "created_at": "2019-10-25 14:10:03",
  "amount": "98745",
  "payment": {
    "media": "Webpay",
    "verification_key": "6669cbd982ef54c28f2f15fb9dc5262d",
    "authorization_code": "107742",
    "last_4_digits": "1233",
    "card_type": "",
    "currency": "CLP"
  },
  "merchant": [
    {
      "name": "John Doe",
      "amount": 30000,
      "subject": "item1"
    },
    {
      "name": "Jane Doe",
      "amount": 25000,
      "subject": "item2"
    },
    {
      "name": "Enteprise",
      "amount": 15000,
      "subject": "item3"
    }
  ]
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Transaction status The possible statuses you can get are the following: - pending - success - rejected - refunded partial - refunded — Example: `success` |
| `id` | string |  | Identifier of the transaction created by Payku. — Example: `10ac494c1d8da71d98ea` |
| `created_at` | string |  | Registration date. — Example: `2019-10-25 14:10:03` |
| `amount` | string |  | Amount. — Example: `98745` |
| `payment` | object |  |  |
| ↳ `media` | string |  | Payment method, used by the user. — Example: `Webpay` |
| ↳ `verification_key` | string |  | Verification code created by Payku. — Example: `6669cbd982ef54c28f2f15fb9dc5262d` |
| ↳ `authorization_code` | string |  | Authorization code. — Example: `107742` |
| ↳ `last_4_digits` | string |  | Last 4 digits of the affiliated card. — Example: `1233` |
| ↳ `card_type` | string |  | Card type. — Example: `` |
| ↳ `currency` | string |  | Currency. — Example: `CLP` |
| `merchant` | array of objects |  | Arrangement containing beneficiary information. — Example: `[{"name":"John Doe","amount":30000,"subject":"item1"},{"name":"Jane Doe","amount":25000,"subject":"item2"},{"name":"Enteprise","amount":15000,"subject":"item3"}]` |
| ↳ `name` | string |  | Name of the beneficiary. |
| ↳ `amount` | string |  | Amount of the product or service. |
| ↳ `subject` | string |  | Description of the product or service. |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Wrong Public Token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

*404* — Identifier does not exist.

```json
{
  "status": "failed",
  "type": "Not Found",
  "id": "is not valid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Not Found` |
| `id` | string |  | Id information — Example: `is not valid` |

## Event

It allows the creation of events and later check their status.

### Create an event

`POST /api/event`

This method allows you to create an event and receive the event details as a response.

**Request body**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `event` | string | ✓ | Event id. — maximum 40 characters — Example: `98374` |
| `name` | string | ✓ | Event name. — maximum 400 characters — Example: `Event` |
| `date_event` | datetime | ✓ | Date on which the event will take place. — Example: `2020-12-20` |
| `date_closing_sales` | datetime | ✓ | Sales closing date, must be less than or equal to date_event. — Example: `2020-12-19 23:59:00` |
| `date_payment` | datetime | ✓ | Payment date of the event, must be greater than the date_event date. — Example: `2020-12-20` |
| `url_event` | string |  | url where the event is published. — maximum 240 characters — Example: `https://example.cl/event1` |
| `url_logo` | string |  | url of the logo that identifies the event. — maximum 240 characters — Example: `https://example.cl/logo_event1.png` |
| `service_sale` | integer |  | Amount of the sales service, belongs to the amount that the owner of the account will receive per transaction. — maximum 7 characters — Example: `10` |
| `affiliation` | array of objects |  | Distribution of beneficiaries. |
| ↳ `email` | string |  | Beneficiary email. — maximum 50 characters — Example: `afiliate1@domain.com` |
| ↳ `percent` | number |  | Percentage which corresponds to the beneficiary. — maximum 6 characters — Example: `100` |

**CURL**

```text
curl -X POST \
  https://BASE_URL/api/event \
  -H 'Accept: application/json, text/plain, */*' \
  -H 'Authorization: Bearer TOKEN_PUBLICO'  \
  -H 'Content-Type: application/json' \
  -H 'Host: BASE_URL' \
  -d {
    "name": "Event",
    "event": "98374",
    "date_event": "2020-12-20",
    "date_payment": "2020-12-22",
    "date_closing_sales": "2020-12-19 23:59:00",
    "url_logo": "https://example.cl/logo_event1.png",
    "url_event": "https://example.cl/event1",
    "service_sale": 10,
    "affiliation": [
      ["afiliate1@gmail.com",  50],
      ["afiliate2@gmail.com",  50]
    ]
  }'
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('POST', 'https://BASE_URL/api/event', [
    'json' => [
        'name' => 'Event',
        'event' => '98374',
        'date_event' => '2020-12-20',
        'date_payment' => '2020-12-22',
        'date_closing_sales' => '2020-12-19 23:59:00',
        'url_logo' => 'https://example.cl/logo_event1.png',
        'url_event' => 'https://example.cl/event1',
        'service_sale' => 10,
        'affiliation' => [
          ['afiliate1@gmail.com',  50],
          ['afiliate2@gmail.com',  50]
        ]
      ],
    'headers' => [
      'Authorization' => 'Bearer PUBLIC-TOKEN'
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async (data) => {
  const response = await fetch('https://BASE_URL/api/event', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
    body: JSON.stringify(data)
  });
  const result = await response.json();
  console.log(result)
}

let data = {
  name: "Event",
  event: "98374",
  date_event: "2020-12-20",
  date_payment: "2020-12-22",
  date_closing_sales: "2020-12-19 23:59:00",
  url_logo: "https://example.cl/logo_event1.png",
  url_event: "https://example.cl/event1",
  service_sale: 10,
  affiliation: [
    ["afiliate1@gmail.com",  50],
    ["afiliate2@gmail.com",  50]
  ]
};

request(data);
```

**Responses**

*200*

```json
{
  "status": "success",
  "id": "98374",
  "event": "Event",
  "date_event": "2020-12-20",
  "date_payment": "2020-12-22",
  "date_closing_sales": "2020-12-19 23:59:00",
  "url_logo": "https://example.cl/logo_event1.png",
  "url_event": "https://example.cl/event1",
  "distribution": {
    "affiliate": "100.00",
    "service_sale": "10.00"
  },
  "affiliation": {
    "id": "b99dfd8193ebfd37d4b9",
    "email": "afiliate1@domain.com",
    "percent": "100.00",
    "status": "pending"
  },
  "paymentData": {
    "count": 0,
    "amount_general": 0,
    "amount_affiliate": 0,
    "fee": 0,
    "balance": 0
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `success` |
| `id` | string |  | Event id. — Example: `98374` |
| `event` | string |  | Event name. — Example: `Event` |
| `date_event` | datetime |  | Date on which the event will take place. — Example: `2020-12-20` |
| `date_payment` | datetime |  | Payment date of the event, must be greater than the date_event date. — Example: `2020-12-22` |
| `date_closing_sales` | datetime |  | Sales closing date, must be less than or equal to date_event. — Example: `2020-12-19 23:59:00` |
| `url_logo` | string |  | url that belongs to the event. — Example: `https://example.cl/logo_event1.png` |
| `url_event` | string |  | url where the event is published. — Example: `https://example.cl/event1` |
| `distribution` | object |  | Distribution of transactions. |
| ↳ `affiliate` | string |  | Amount to distribute to beneficiaries. — Example: `100.00` |
| ↳ `service_sale` | string |  | Amount to distribute in the sales service. — Example: `10.00` |
| `affiliation` | object |  | Affiliate information. |
| ↳ `id` | string |  | Beneficiary identifier. — Example: `b99dfd8193ebfd37d4b9` |
| ↳ `email` | string |  | Beneficiary email. — Example: `afiliate1@domain.com` |
| ↳ `percent` | string |  | Percentage which corresponds to the beneficiary. — Example: `100.00` |
| ↳ `status` | string |  | Beneficiary status. — Example: `pending` |
| `paymentData` | object |  | Distribution of beneficiaries. |
| ↳ `count` | number |  | Sales quantity. — Example: `0` |
| ↳ `amount_general` | number |  | General amount of all transactions. — Example: `0` |
| ↳ `amount_affiliate` | number |  | Amount to distribute to beneficiaries. — Example: `0` |
| ↳ `fee` | number |  | Fee. — Example: `0` |
| ↳ `balance` | number |  | Amount to deposit. — Example: `0` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### Get event details

`GET /api/event/{idEvent}`

This method allows obtaining the details of an event.

**Path parameters**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | ✓ | id of the event to request — maximum 40 characters |

**CURL**

```text
curl -X GET \
  https://BASE_URL/api/event \
  -H 'Accept: application/json, text/plain, */*' \
  -H 'Authorization: Bearer TOKEN_PUBLICO'  \
  -H 'Content-Type: application/json' \
  -H 'Host: BASE_URL' \
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('GET', 'https://BASE_URL/api/event/98374', [
    'headers' => [
      'Authorization' => 'Bearer PUBLIC-TOKEN'
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async (data) => {
  const response = await fetch('https://BASE_URL/api/event/98374', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
  });
  const result = await response.json();
  console.log(result)
}

request(data);
```

**Responses**

*200*

```json
{
  "id": "98374",
  "event": "Event",
  "date_event": "2020-12-20",
  "date_payment": "2020-12-22",
  "date_closing_sales": "2020-12-19 23:59:00",
  "url_logo": "https://example.cl/logo_event1.png",
  "url_event": "https://example.cl/event1",
  "distribution": {
    "affiliate": "100.00",
    "service_sale": "10.00"
  },
  "affiliation": {
    "id": "b99dfd8193ebfd37d4b9",
    "email": "afiliate1@domain.com",
    "percent": "100.00",
    "status": "pending"
  },
  "paymentData": {
    "count": 0,
    "amount_general": 0,
    "amount_affiliate": 0,
    "fee": 0,
    "balance": 0
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string |  | Event identifier. — Example: `98374` |
| `event` | string |  | Event name. — Example: `Event` |
| `date_event` | datetime |  | Date on which the event will take place. — Example: `2020-12-20` |
| `date_payment` | datetime |  | Payment date of the event, must be greater than the date_event date. — Example: `2020-12-22` |
| `date_closing_sales` | datetime |  | Sales closing date, must be less than or equal to date_event. — Example: `2020-12-19 23:59:00` |
| `url_logo` | string |  | url logo that belongs to the event. — Example: `https://example.cl/logo_event1.png` |
| `url_event` | string |  | url that belongs to the event. — Example: `https://example.cl/event1` |
| `distribution` | object |  | Distribution of transactions. |
| ↳ `affiliate` | string |  | Amount to distribute to beneficiaries. — Example: `100.00` |
| ↳ `service_sale` | string |  | Amount to distribute in the sales service. — Example: `10.00` |
| `affiliation` | object |  | Affiliate information. |
| ↳ `id` | string |  | Beneficiary identifier. — Example: `b99dfd8193ebfd37d4b9` |
| ↳ `email` | string |  | Beneficiary email. — Example: `afiliate1@domain.com` |
| ↳ `percent` | string |  | Percentage which corresponds to the beneficiary. — Example: `100.00` |
| ↳ `status` | string |  | Beneficiary status. — Example: `pending` |
| `paymentData` | object |  | Distribution of beneficiaries. |
| ↳ `count` | number |  | Sales quantity. — Example: `0` |
| ↳ `amount_general` | number |  | General amount of all transactions. — Example: `0` |
| ↳ `amount_affiliate` | number |  | Amount to distribute to beneficiaries. — Example: `0` |
| ↳ `fee` | number |  | Fee. — Example: `0` |
| ↳ `balance` | number |  | Amount to deposit. — Example: `0` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

## Subscription

It allows the linking of a plan to Clients, to later make recurring charges automatically, as defined in each plan.
<br>
<div class='container'>
  <img src='https://docs.payku.com/img/diagrams/Diagram-Subscription.png' alt='Avatar' class='image' style='width:100%'>
  <div class='middle'>
    <a target='_blank' href='https://docs.payku.com/img/diagrams/Diagram-Subscription.png' class='text'>View</a>
  </div>
</div>

### Insert data to a Client

`POST /api/suclient`

This method allows the insertion of Client data.

**Request body**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `email` | string | ✓ | Client email. — maximum 50 characters — Example: `joedoe@gmail.com` |
| `name` | string | ✓ | Client name — maximum 80 characters — Example: `Joe Doe` |
| `rut` | string |  | Single Tax Registry of the client, the entry of this data with or without a hyphen will be allowed. — 12 characters required — Example: `11111111` |
| `phone` | string | ✓ | Client phone. — 20 characters required — Example: `923122312` |
| `address` | string |  | Client address. — maximum 200 characters — Example: `Moneda 101` |
| `country` | string |  | Client country. — maximum 40 characters — Example: `Chile` |
| `region` | string |  | Client region. — maximum 120 characters — Example: `Metropolitana` |
| `city` | string |  | Client city. — maximum 40 characters — Example: `Santiago` |
| `postal_code` | string |  | Client Zip Code. — maximum 10 characters — Example: `850000` |
| `additional_parameters` | object |  | Client additional parameters — maximum 4000 characters |
| ↳ `parameter_1` | string |  | Client additional parameter — Example: `example` |
| ↳ `parameter_2` | string |  | Client additional parameter — Example: `example` |

**CURL**

```text
curl -X POST \
https://BASE_URL/api/suclient \
-H 'Accept: application/json, text/plain, */*' \
-H 'Sign: SIGN'  \
-H 'Authorization: Bearer TOKEN_PUBLICO'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE_URL' \
-d {
    "email": "joedoe@gmail.com",
    "name": "Joe Doe",
    "rut": "111111111",
    "phone": "923122312",
    "address": "Moneda 101",
    "country": "Chile",
    "region": "Metropolitana",
    "city": "Santiago",
    "postal_code": "850000,
    "additional_parameters":{
      "parameter_1": "example",
      "parameter_2": "example 2",
    }
  }'
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('POST', 'https://BASE_URL/api/suclient', [
    'json' => [
      'email' => 'joedoe@gmail.cl',
      'name' => 'Joe Doe',
      'rut' => '111111111',
      'phone' => '923122312',
      'address' => 'Moneda 101',
      'country' => 'Chile',
      'region' => 'Metropolitana',
      'city' => 'Santiago',
      'postal_code' => '850000',
      'additional_parameters' => [
          'parameter_1' => 'example',
          'parameter_2' => 'example 2'
        ]
      ],
    'headers' => [
      'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization' => 'Bearer PUBLIC-TOKEN'
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async (data) => {
  const response = await fetch('https://BASE_URL/api/suclient', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
    body: JSON.stringify(data)
  });
  const result = await response.json();
  console.log(result)
}

let data = {
  email: "joedoe@gmail.com",
  name: "Joe Doe",
  rut: "111111111",
  phone: "923122312",
  address: "Moneda 101",
  country: "Chile",
  region: "Metropolitana",
  city: "Santiago",
  postal_code: "850000",
  additional_parameters:{
    parameter_1: "example",
    parameter_2: "example 2",
  }
};

request(data);
```

**Responses**

*200*

```json
{
  "status": "active",
  "id": "cl0be4c8e623c167bc8b29",
  "rut": "11111111",
  "name": "Joe Doe",
  "phone": "923122312",
  "email": "joedoe@gmail.com",
  "address": "Moneda 101",
  "country": "Chile",
  "region": "Metropolitana",
  "city": "Santiago",
  "postal_code": "850000",
  "create_at": "2020-09-29",
  "update_at": null,
  "subcriptions": null,
  "additional_parameters": {
    "parameter_1": "example",
    "parameter_2": "example"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Client status. — Example: `active` |
| `id` | string |  | Identifier of the transaction created by payku. — Example: `cl0be4c8e623c167bc8b29` |
| `rut` | string |  | Single Tax Registry of the client. — Example: `11111111` |
| `name` | string |  | Client name. — Example: `Joe Doe` |
| `phone` | string |  | Client phone. — Example: `923122312` |
| `email` | string |  | Client email. — Example: `joedoe@gmail.com` |
| `address` | string |  | Client address. — Example: `Moneda 101` |
| `country` | string |  | Client country. — Example: `Chile` |
| `region` | string |  | Client region. — Example: `Metropolitana` |
| `city` | string |  | Client city. — Example: `Santiago` |
| `postal_code` | string |  | Client Zip Code. — Example: `850000` |
| `create_at` | string |  | Registration date. — Example: `2020-09-29` |
| `update_at` | string |  | Update date. |
| `subcriptions` | object |  | Client subscriptions. |
| `additional_parameters` | object |  | Client additional parameters |
| ↳ `parameter_1` | string |  | Client additional parameter — Example: `example` |
| ↳ `parameter_2` | string |  | Client additional parameter — Example: `example` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### Query Client data

`GET /api/suclient/{idClient} or {emailClient}`

This method allows obtaining the details of a client or the client's email.

**Path parameters**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | ✓ | Unique transaction identifier per payku. — maximum 20 characters |

**CURL**

```text
curl -X GET \
https://BASE_URL/api/suclient/id \
-H 'Accept: application/json, text/plain, */*' \
-H 'Sign: SIGN'  \
-H 'Authorization: Bearer TOKEN_PUBLICO'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE_URL' \
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('GET', 'https://BASE_URL/api/suclient/cla90927fa9b30e1dfffa0', [
    'headers' => [
      'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization' => 'Bearer PUBLIC-TOKEN'
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async () => {
  const response = await fetch('https://BASE_URL/api/suclient/cla90927fa9b30e1dfffa0', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
      'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
  });
  const result = await response.json();
  console.log(result)
}

request(data);
```

**Responses**

*200*

```json
{
  "status": "active",
  "id": "cl0be4c8e623c167bc8b29",
  "rut": "11111111",
  "name": "Joe Doe",
  "phone": "923122312",
  "email": "joedoe@gmail.com",
  "address": "Moneda 101",
  "city": "Santiago",
  "region": "Metropolitana",
  "country": "Chile",
  "postal_code": "850000",
  "create_at": "2020-09-29",
  "update_at": null,
  "active_cards": [
    {
      "last_4_digits": "XXXXXXXXXXXX6622",
      "identifier": "surec804a8ed60c747cb8839",
      "card_type": "Visa",
      "register": "2022-07-26 08:00:19"
    },
    {
      "last_4_digits": "XXXXXXXXXXXX1234",
      "identifier": "surec804a8ed60c747cb8843",
      "card_type": "MasterCard",
      "register": "2023-01-01 12:00:00"
    }
  ],
  "additional_parameters": {
    "parameter_1": "example",
    "parameter_2": "example"
  },
  "subcriptions": {
    "id": "su867f07772aa5f5175527",
    "created_at": "2020-09-29 19:58:35",
    "status": "active",
    "amount": "15000",
    "plan": [
      {
        "id": "pl9697fb170834ad42dd00",
        "name": "test plan",
        "currency": "CLP"
      }
    ],
    "cards": [
      {
        "last_4_digits": "6622",
        "card_type": "Visa"
      }
    ],
    "transactions": [
      {
        "created_at": "2020-09-30 19:58:35",
        "date_payment": "2020-09-30",
        "amount": "10000",
        "transaction": "204444",
        "authorization_code": "1234",
        "order": "001",
        "description": "description",
        "status": "success"
      }
    ]
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Client status. — Example: `active` |
| `id` | string |  | Identifier of the transaction created by payku. — Example: `cl0be4c8e623c167bc8b29` |
| `rut` | string |  | Single Tax Registry of the client. — Example: `11111111` |
| `name` | string |  | Client name. — Example: `Joe Doe` |
| `phone` | string |  | Client phone. — Example: `923122312` |
| `email` | string |  | Client email. — Example: `joedoe@gmail.com` |
| `address` | string |  | Client address. — Example: `Moneda 101` |
| `city` | string |  | Client city. — Example: `Santiago` |
| `region` | string |  | Client region. — Example: `Metropolitana` |
| `country` | string |  | Client country. — Example: `Chile` |
| `postal_code` | string |  | Client Zip Code. — Example: `850000` |
| `create_at` | string |  | Registration date. — Example: `2020-09-29` |
| `update_at` | string |  | Update date. |
| `active_cards` | array of objects |  | Example: `[{"last_4_digits":"XXXXXXXXXXXX6622","identifier":"surec804a8ed60c747cb8839","card_type":"Visa","register":"2022-07-26 08:00:19"},{"last_4_digits":"XXXXXXXXXXXX1234","identifier":"surec804a8ed60c747cb8843","card_type":"MasterCard","register":"2023-01-01 12:00:00"}]` |
| ↳ `last_4_digits` | string |  | Last 4 digits of the affiliated carda. — Example: `XXXXXXXXXXXX6622` |
| ↳ `identifier` | string |  | id card. — Example: `surec804a8ed60c747cb8839` |
| ↳ `card_type` | string |  | card type. — Example: `Visa` |
| ↳ `register` | string |  | Register date. — Example: `2022-07-26 08:00:19` |
| `additional_parameters` | object |  | Client additional parameters |
| ↳ `parameter_1` | string |  | Client additional parameter — Example: `example` |
| ↳ `parameter_2` | string |  | Client additional parameter — Example: `example` |
| `subcriptions` | object |  |  |
| ↳ `id` | string |  | Subscription identifier created by payku. — Example: `su867f07772aa5f5175527` |
| ↳ `created_at` | string |  | Registration date. — Example: `2020-09-29 19:58:35` |
| ↳ `status` | string |  | Subscription status. The possible statuses you can get are the following: - register - active - finish - delete - cancel - suspended — Example: `active` |
| ↳ `amount` | string |  | Subscription amount. — Example: `15000` |
| ↳ `plan` | array of objects |  |  |
| ↳ ↳ `id` | string |  | Identifier of the plan created by payku. — Example: `pl9697fb170834ad42dd00` |
| ↳ ↳ `name` | string |  | Plan name. — Example: `test plan` |
| ↳ ↳ `currency` | string |  | Currency. — Example: `CLP` |
| ↳ `cards` | array of objects |  |  |
| ↳ ↳ `last_4_digits` | string |  | Last 4 digits of the affiliated card. — Example: `6622` |
| ↳ ↳ `card_type` | string |  | Card type. — Example: `Visa` |
| ↳ `transactions` | array of objects |  |  |
| ↳ ↳ `created_at` | string |  | Transaction creation date. — Example: `2020-09-30 19:58:35` |
| ↳ ↳ `date_payment` | string |  | Date the transaction was made. — Example: `2020-09-30` |
| ↳ ↳ `amount` | string |  | Transaction amount. — Example: `10000` |
| ↳ ↳ `transaction` | string |  | Transaction number. — Example: `204444` |
| ↳ ↳ `authorization_code` | string |  | Authorization code. — Example: `1234` |
| ↳ ↳ `order` | string |  | Number of order. — Example: `001` |
| ↳ ↳ `description` | string |  | Description. — Example: `description` |
| ↳ ↳ `status` | string |  | Transaction status The possible statuses you can get are the following: - pending - success - retry - canceled by customer - canceled by paymaster - canceled by payku - maximum attempt limit - first payment rejected - payment consumes failed — Example: `success` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### Update Client data

`PUT /api/suclient/{idClient} or {emailClient}`

This method allows updating a Client's data.

**Path parameters**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | ✓ | Unique transaction identifier per payku. — maximum 20 characters |

**Request body**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `email` | string |  | Client email. — maximum 50 characters — Example: `joedoe@gmail.com` |
| `name` | string |  | Client name — maximum 80 characters — Example: `Joe Doe Doe` |
| `phone` | string |  | Client phone. — maximum 20 characters — Example: `923122312` |
| `address` | string |  | Client address. — maximum 200 characters — Example: `Moneda 121` |
| `country` | string |  | Client country. — maximum 40 characters — Example: `Chile` |
| `region` | string |  | Client region. — maximum 120 characters — Example: `Metropolitana` |
| `city` | string |  | Client city. — maximum 40 characters — Example: `Santiago` |
| `postal_code` | string |  | Client Zip Code. — maximum 10 characters — Example: `750000` |
| `additional_parameters` | object |  | Client additional parameters — maximum 4000 characters |
| ↳ `parameter_1` | string |  | Client additional parameter — Example: `example` |
| ↳ `parameter_2` | string |  | Client additional parameter — Example: `example` |

**CURL**

```text
curl -X PUT \
https://BASE_URL/api/suclient/id \
-H 'Accept: application/json, text/plain, */*' \
-H 'Sign: SIGN'  \
-H 'Authorization: Bearer TOKEN_PUBLICO'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE_URL' \
-d {
    "email": "joedoe@gmail.com",
    "name": "Joe Doe Doe",
    "phone": "923122312",
    "address": "Moneda 121",
    "country": "Chile",
    "region": "Metropolitana",
    "city": "Santiago",
    "postal_code": "750000",
    "additional_parameters":{
      "parameter_1": "example",
      "parameter_2": "example 2",
    }
  }'
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('PUT', 'https://BASE_URL//api/suclient/cla90927fa9b30e1dfffa0', [
    'json' => [
      'email' => 'joedoe@gmail.com',
      'name' => 'Joe Doe Doe',
      'phone' => '923122312',
      'address' => 'Moneda 121',
      'country' => 'Chile',
      'region'  => 'Metropolitana',
      'city'    => 'Santiago',
      'postal_code' => '750000',
      'additional_parameters' => [
        'parameter_1' => 'example',
        'parameter_2' => 'example 2'
      ]
    ],
  ],
  'headers' => [
    'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
    'Authorization' => 'Bearer PUBLIC-TOKEN'
  ]
])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async (data) => {
  const response = await fetch('https://BASE_URL/api/suclient', {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
      'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
    body: JSON.stringify(data)
  });
  const result = await response.json();
  console.log(result)
}

let data = {
  email: "joedoe@gmail.com",
  name: "Joe Doe Doe",
  phone: "923122312",
  address: "Moneda 121",
  country: "Chile",
  region: "Metropolitana",
  city: "Santiago",
  postal_code: "750000",
  additional_parameters:{
    parameter_1: "example",
    parameter_2: "example 2",
  }
};

request(data);
```

**Responses**

*200*

```json
{
  "status": "active",
  "id": "cl0be4c8e623c167bc8b29",
  "name": "Joe Doe Doe",
  "phone": "923122312",
  "email": "joedoe@gmail.com",
  "address": "Moneda 121",
  "city": "Santiago",
  "region": "Metropolitana",
  "country": "Chile",
  "postal_code": "750000",
  "create_at": "2020-09-29",
  "update_at": "2020-10-2 08:32:52",
  "additional_parameters": {
    "parameter_1": "example",
    "parameter_2": "example"
  },
  "subcriptions": {
    "id": "su867f07772aa5f5175527",
    "created_at": "2020-09-29 19:58:35",
    "status": "active",
    "amount": "15000",
    "plan": [
      {
        "id": "pl9697fb170834ad42dd00",
        "name": "test plan",
        "currency": "CLP"
      }
    ],
    "cards": [
      {
        "last_4_digits": "6622",
        "card_type": "Visa"
      }
    ],
    "transactions": [
      {
        "created_at": "2020-09-30 19:58:35",
        "date_payment": "2020-09-30",
        "amount": "10000",
        "transaction": "204444",
        "authorization_code": "1234",
        "order": "001",
        "description": "description",
        "status": "success"
      }
    ]
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Client status. — Example: `active` |
| `id` | string |  | Transaction identifier created by payku. — Example: `cl0be4c8e623c167bc8b29` |
| `name` | string |  | Client name. — Example: `Joe Doe Doe` |
| `phone` | string |  | Client phone. — Example: `923122312` |
| `email` | string |  | Client email. — Example: `joedoe@gmail.com` |
| `address` | string |  | Client address. — Example: `Moneda 121` |
| `city` | string |  | Client city. — Example: `Santiago` |
| `region` | string |  | Client region. — Example: `Metropolitana` |
| `country` | string |  | Client country. — Example: `Chile` |
| `postal_code` | string |  | Client Zip Code. — Example: `750000` |
| `create_at` | string |  | Registration date. — Example: `2020-09-29` |
| `update_at` | string |  | Update date. — Example: `2020-10-2 08:32:52` |
| `additional_parameters` | object |  | Client additional parameters |
| ↳ `parameter_1` | string |  | Client additional parameter — Example: `example` |
| ↳ `parameter_2` | string |  | Client additional parameter — Example: `example` |
| `subcriptions` | object |  |  |
| ↳ `id` | string |  | Subscription identifier created by payku. — Example: `su867f07772aa5f5175527` |
| ↳ `created_at` | string |  | Registration date. — Example: `2020-09-29 19:58:35` |
| ↳ `status` | string |  | Subscription status. The possible statuses you can get are the following: - register - active - finish - delete - cancel - suspended — Example: `active` |
| ↳ `amount` | string |  | Subscription amount. — Example: `15000` |
| ↳ `plan` | array of objects |  |  |
| ↳ ↳ `id` | string |  | Identifier of the plan created by payku. — Example: `pl9697fb170834ad42dd00` |
| ↳ ↳ `name` | string |  | Plan name. — Example: `test plan` |
| ↳ ↳ `currency` | string |  | currency. — Example: `CLP` |
| ↳ `cards` | array of objects |  |  |
| ↳ ↳ `last_4_digits` | string |  | Last 4 digits of the affiliated card. — Example: `6622` |
| ↳ ↳ `card_type` | string |  | Card type. — Example: `Visa` |
| ↳ `transactions` | array of objects |  |  |
| ↳ ↳ `created_at` | string |  | Transaction creation date. — Example: `2020-09-30 19:58:35` |
| ↳ ↳ `date_payment` | string |  | Date the transaction was made. — Example: `2020-09-30` |
| ↳ ↳ `amount` | string |  | Transaction amount. — Example: `10000` |
| ↳ ↳ `transaction` | string |  | Transaction number. — Example: `204444` |
| ↳ ↳ `authorization_code` | string |  | Authorization code. — Example: `1234` |
| ↳ ↳ `order` | string |  | Number of order. — Example: `001` |
| ↳ ↳ `description` | string |  | Description. — Example: `description` |
| ↳ ↳ `status` | string |  | Transaction status The possible statuses you can get are the following: - pending - success - retry - canceled by customer - canceled by paymaster - canceled by payku - maximum attempt limit - first payment rejected - payment consumes failed — Example: `success` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### Delete Client

`DELETE /api/suclient/{idClient} or {emailClient}`

This method allows the elimination of a client associated with a user id.

**Path parameters**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | ✓ | Unique transaction identifier per payku. — maximum 20 characters |

**CURL**

```text
curl -X DELETE \
https://BASE_URL/api/suclient/id \
-H 'Accept: application/json, text/plain, */*' \
-H 'Sign: SIGN'  \
-H 'Authorization: Bearer TOKEN_PUBLICO'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE_URL' \
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('DELETE', 'https://BASE_URL/api/suclient/cla90927fa9b30e1dfffa0', [
      'headers' => [
        'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
        'Authorization' => 'Bearer PUBLIC-TOKEN'              ]
      ])->getBody();
    $response = json_decode($body);
```

**JS**

```js
const request = async () => {
  const response = await fetch('https://BASE_URL/api/suclient/cla90927fa9b30e1dfffa0', {
    method: 'DELETE',
    headers: {
      'Content-Type': 'application/json',
      'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
  });
  const result = await response.json();
  console.log(result)
}

request(data);
```

**Responses**

*200*

```json
{
  "status": "success",
  "id": "cl0be4c8e623c167bc8b29"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Client status. — Example: `success` |
| `id` | string |  | Transaction identifier created by payku. — Example: `cl0be4c8e623c167bc8b29` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### Get all Clients

`GET /api/suclient/customers`

This method allows to obtain all Clients.

**CURL**

```text
curl -X GET \
https://BASE_URL/api/suclient/customers \
-H 'Accept: application/json, text/plain, */*' \
-H 'Sign: SIGN'  \
-H 'Authorization: Bearer TOKEN_PUBLICO'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE_URL' \
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('GET', 'https://BASE_URL/api/suclient/customers', [
    'headers' => [
      'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization' => 'Bearer PUBLIC-TOKEN'
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async () => {
  const response = await fetch('https://BASE_URL/api/suclient/customers', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
      'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
  });
  const result = await response.json();
  console.log(result)
}

request(data);
```

**Responses**

*200*

```json
[
  {
    "Customers": [
      {
        "status": "active",
        "id": "cl0be4c8e623c167bc8b29",
        "rut": "11111111",
        "name": "Joe Doe",
        "phone": "923122312",
        "email": "joedoe@gmail.com",
        "address": "Moneda 101",
        "city": "Santiago",
        "region": "Metropolitana",
        "country": "Chile",
        "postal_code": "850000",
        "create_at": "2020-09-29",
        "update_at": null,
        "active_cards": [
          {
            "last_4_digits": "XXXXXXXXXXXX6622",
            "identifier": "surec804a8ed60c747cb8839",
            "card_type": "Visa",
            "register": "2022-07-26 08:00:19"
          },
          {
            "last_4_digits": "XXXXXXXXXXXX1234",
            "identifier": "surec804a8ed60c747cb8843",
            "card_type": "MasterCard",
            "register": "2023-01-01 12:00:00"
          }
        ],
        "subcriptions": {
          "id": "su867f07772aa5f5175527",
          "created_at": "2020-09-29 19:58:35",
          "status": "active",
          "amount": "15000",
          "plan": [
            {
              "id": null,
              "name": null,
              "currency": null
            }
          ],
          "cards": [
            {
              "last_4_digits": null,
              "card_type": null
            }
          ],
          "transactions": [
            {
              "created_at": null,
              "date_payment": null,
              "amount": null,
              "transaction": null,
              "authorization_code": null,
              "order": null,
              "description": null,
              "status": null
            }
          ]
        }
      }
    ]
  }
]
```

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### Insert data for subscription

`POST /api/sususcription`

This method allows the user of a Payku account to create a subscription to a fixed-amount subscription plan, a consumer plan subscription and a variable-amount subscription to one of its clients, for this last type of subscription it is necessary to send the amount that will be charged in the subscription, it is important to note that when making this request for the first time there will be a charge of $ 50 that allows verifying that the card is active and valid, in the case of a fixed subscription plan the service charge will be automatic From the month following the subscription date and in the event that the subscription is to a consumer plan, it will be necessary to use the api / sutransaction endpoint to generate the transaction.

**Request body**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `plan` | string | ✓ | Plan id. — maximum 70 characters — Example: `pl9697fb170834ad42dd00` |
| `client` | string | ✓ | Client id. — maximum 20 characters — Example: `cl9b1e1dd988694f30fa30` |
| `amount` *(oneOf · option 1)* | string | ✓ | This field will only be used in the case of variable amount subscription plans, it is important to note that the currency to be used in this type of plan is CLP. — maximum 14 digits |
| `coupon` *(oneOf · option 2)* | string | ✓ | Coupon code — maximum 50 characters |

**CURL**

```text
curl -X POST \
https://BASE_URL/api/sususcription \
-H 'Accept: application/json, text/plain, */*' \
-H 'Sign: SIGN'  \
-H 'Authorization: Bearer TOKEN_PUBLICO'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE_URL' \
-d {
    "plan": "pl9697fb170834ad42dd00",
    "client": "cl9b1e1dd988694f30fa30"
  }'
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('POST', 'https://BASE_URL/api/sususcription, [
    'json' => [
      'plan' => 'pl9697fb170834ad42dd00',
      'client' => 'cl9b1e1dd988694f30fa30',
      ],
      'headers' => [
        'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
        'Authorization' => 'Bearer PUBLIC-TOKEN'
      ]
    ])->getBody();
  $response = json_decode($body);
```

**JS**

```js
const request = async (data) => {
  const response = await fetch('https://BASE_URL/api/sususcription', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
    body: JSON.stringify(data)
  });
  const result = await response.json();
  console.log(result)
}

let data = {
  plan: "pl9697fb170834ad42dd00",
  client: "cl9b1e1dd988694f30fa30",
};

request(data);
```

**Responses**

*200*

```json
{
  "status": "register",
  "id": "sucaab7865dceaff49d8b3",
  "url": "http://app.payku.cl/gateway/registrosuscripcion?tipoplan=2&plan=true&token=219&validacion=e6c50ba0e0"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Status. — Example: `register` |
| `id` | string |  | Unique subscription identifier for payku. — Example: `sucaab7865dceaff49d8b3` |
| `url` | string |  | Url payment and subscription activation. — Example: `http://app.payku.cl/gateway/registrosuscripcion?tipoplan=2&plan=true&token=219&validacion=e6c50ba0e0` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### Get all subscriptions

`GET /api/sususcription`

This method allows obtaining all the subscriptions associated with a user ID, this method allows a pagination with a maximum of 100 records per page, in addition, it has a date filter, if this parameter is not entered, the current date will be taken, for the pagination, it is necessary to add the following at the end of the endpoint? page = 1 & per_page = 100, the first parameter being the number of the page and the second the number of records per page. status: you can filter the search for subscriptions depending on the status you want to search for by adding the status to search equal to true. If none is added, by default all subscriptions will be searched without discrimination by status.

**CURL**

```text
curl -X GET \
https://BASE_URL/api/sususcription \
-H 'Accept: application/json, text/plain, */*' \
-H 'Sign: SIGN'  \
-H 'Authorization: Bearer TOKEN_PUBLICO'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE_URL' \
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('GET', 'https://BASE_URL/api/sususcription', [
    'headers' => [
      'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization' => 'Bearer PUBLIC-TOKEN'
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async () => {
  const response = await fetch('https://BASE_URL/api/sususcription', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
      'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
  });
  const result = await response.json();
  console.log(result)
}

request(data);
```

**Responses**

*200*

```json
[
  {
    "subscriptions": [
      {
        "id": "sucaab7865dceaff49d8b7",
        "status": "active",
        "last_status_current_payment": "pending",
        "start": "2019-07-22 18:34:49",
        "end": "2020-06-12 00:00:00",
        "client": {
          "id": "su7e5e1c0b1bd2e37ec557",
          "name": "name",
          "email": "example@domain.com",
          "rut": "1.111.111-1",
          "phone": "56928265454",
          "parametros": [],
          "additional_parameters": ""
        },
        "plan": {
          "id": "pl9697fb170834ad42dd00",
          "name": "test plan",
          "currency": "CLP"
        },
        "cards": {
          "last_4_digits": "6622",
          "card_type": "Visa"
        },
        "transactions": [
          {
            "created_at": "2020-09-30 19:58:35",
            "amount": "10000",
            "transaction": "204444",
            "authorization_code": "1234",
            "order": "001",
            "description": "description",
            "status": "success"
          }
        ],
        "logs": {
          "status": [
            {
              "change_date": null,
              "initial_status": null,
              "final_status": null
            }
          ]
        }
      }
    ]
  }
]
```

*400* — Error en la solicitud.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### Get subscriptions V3

`GET /api/sususcriptionv3`

This method allows obtaining all the subscriptions associated with a user ID, this method allows a pagination with a maximum of 4000 records per page, in addition, it has the following filters:

date_init: indicates the date from which you want to start the subscription search, if this parameter is not sent the search will start with the current date.
date_end: indicates the date where you want the subscription search to end, if this parameter is not sent, the search will have the current date as the end date.
estatus: you can filter the search for subscriptions depending on the status you want to search for by adding the status to search equal to true, if none is added, by default all subscriptions will be searched without discrimination by status.

For pagination it is necessary to add the following at the end of the endpoint ?page=1&per_page=100 the first parameter being the page number and the second the number of records per page. In case you want to search for the subscriptions between the dates 01-09-2021 and 15-09-2021, also that they are only active status subscriptions, the url to use would be the following: https://[URL_BASE]/api/sususcriptionv3?date_init=2021-09-01&date_end=2021-09-15&active=true.

**CURL**

```text
curl -X GET \
https://BASE_URL/api/sususcriptionv3 \
-H 'Accept: application/json, text/plain, */*' \
-H 'Sign: SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN'  \
-H 'Authorization: Bearer PUBLIC-TOKEN'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE_URL' \
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('GET', 'https://BASE_URL/api/sususcriptionv3', [
    'headers' => [
      'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization' => 'Bearer PUBLIC-TOKEN'
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async () => {
  const response = await fetch('https://BASE_URL/api/sususcriptionv3', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
      'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
  });
  const result = await response.json();
  console.log(result)
}

request(data);
```

**Responses**

*200*

```json
[
  {
    "subscriptions": [
      {
        "id": "sucaab7865dceaff49d8b7",
        "estatus": "active",
        "start": "2019-07-22 18:34:49",
        "end": "2023-06-12 00:00:00",
        "client": {
          "id": "su7e5e1c0b1bd2e37ec557",
          "name": "name",
          "email": "johndoe@example.com",
          "rut": "11.111.111-1",
          "phone": "56928265454",
          "parametros": [],
          "additional_parameters": ""
        },
        "plan": {
          "id": "pl9697fb170834ad42dd00",
          "name": "test plan",
          "currency": "CLP"
        },
        "active_cards": {
          "last_4_digits": "XXXXXXXXXXXX6622",
          "card_type": "Visa"
        },
        "logs": {
          "status": [
            {
              "change_date": null,
              "initial_status": null,
              "final_status": null
            }
          ]
        },
        "paid": [
          {
            "payment_cycle_day": "2021-07-09",
            "payment_day": "2021-07-09",
            "status": "success",
            "amount_paid": 2500,
            "try_number": 1,
            "paid_number": 1,
            "transactions": []
          }
        ]
      }
    ]
  }
]
```

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### Insert data for the transaction

`POST /api/sutransaction`

This method allows the user of a Payku account to generate a unique transaction to one of his clients who are subscribed to a consumption plan.
<br>
<div class='container'>
  <img src='https://docs.payku.com/img/diagrams/Diagram-Subscription.png' alt='Avatar' class='image' style='width:100%'>
  <div class='middle'>
    <a target='_blank' href='https://docs.payku.com/img/diagrams/Diagram-Subscription.png' class='text'>View</a>
  </div>
</div>

**Request body**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `suscription` | string | ✓ | Unique subscription identifier for payku. — maximum 60 characters — Example: `sucaab7865dceaff49d8b3` |
| `amount` | string |  | Amount. — maximum 14 digits — Example: `10000` |
| `order` | string |  | Order. — maximum 40 characters — Example: `001` |
| `description` | string |  | Description. — maximum 1000 characters — Example: `Description` |

**CURL**

```text
curl -X POST \
https://BASE_URL/api/sutransaction \
-H 'Accept: application/json, text/plain, */*' \
-H 'Sign: SIGN'  \
-H 'Authorization: Bearer TOKEN_PUBLICO'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE_URL' \
-d {
    "suscription": "sucaab7865dceaff49d8b3",
    "amount": "10000",
    "order": "001",
    "description": "Description"
  }'
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('POST', 'https://BASE_URL/api/sutransaction, [
    'json' => [
      'suscription' => sucaab7865dceaff49d8b3,
      'order' => '001',
      'amount' => '10000',
      'description' => 'descripcion'
      ],
      'headers' => [
        'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
        'Authorization' => 'Bearer PUBLIC-TOKEN'
      ]
    ])->getBody();
  $response = json_decode($body);
```

**JS**

```js
const request = async (data) => {
  const response = await fetch('https://BASE_URL/api/sutransaction', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
    body: JSON.stringify(data)
  });
  const result = await response.json();
  console.log(result)
}

let data = {
  suscription: "sucaab7865dceaff49d8b3",
  amount: "10000",
  order: "001",
  description: "Description"
};

request(data);
```

**Responses**

*200*

```json
{
  "status": "success",
  "order": "001",
  "amount": "10000",
  "transaction_id": "204444",
  "verification_key": "025dcad37e071daa8bfc2df35189009db65692a4ff766856108be1675e870839"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Transaction status. The possible statuses you can get are the following: - pending - success - rejected - refunded partial - refunded — Example: `success` |
| `order` | string |  | Order. — Example: `001` |
| `amount` | string |  | Amount. — Example: `10000` |
| `transaction_id` | string |  | Transaction number. — Example: `204444` |
| `verification_key` | string |  | Example: `025dcad37e071daa8bfc2df35189009db65692a4ff766856108be1675e870839` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### Check subscription data

`GET /api/sususcription/{idSuscription}`

This method allows you to get the details of a subscription.

**Path parameters**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | ✓ | Unique transaction identifier per payku. — maximum 20 characters |

**CURL**

```text
curl -X GET \
https://BASE_URL/api/sususcription/id \
-H 'Accept: application/json, text/plain, */*' \
-H 'Sign: SIGN'  \
-H 'Authorization: Bearer TOKEN_PUBLICO'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE_URL' \
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('GET', 'https://BASE_URL/api/sususcription/sucaab7865dceaff49d8b', [
    'headers' => [
      'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization' => 'Bearer PUBLIC-TOKEN'
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async () => {
  const response = await fetch('https://BASE_URL/api/sususcription/sucaab7865dceaff49d8b', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
      'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
  });
  const result = await response.json();
  console.log(result)
}

request(data);
```

**Responses**

*200*

```json
{
  "id": "sucaab7865dceaff49d8b7",
  "status": "active",
  "start": "2019-07-22 18:34:49",
  "end": "2020-06-12 00:00:00",
  "client": {
    "id": "su7e5e1c0b1bd2e37ec557",
    "name": "name",
    "email": "example@domain.com",
    "rut": "1.111.111-1",
    "phone": "example@domain.com",
    "parametros": [],
    "additional_parameters": ""
  },
  "plan": {
    "id": "pl9697fb170834ad42dd00",
    "name": "test plan",
    "currency": "CLP"
  },
  "cards": {
    "last_4_digits": "6622",
    "card_type": "Visa"
  },
  "active_cards": [
    {
      "last_4_digits": "XXXXXXXXXXXX6622",
      "identifier": "surec804a8ed60c747cb8839",
      "card_type": "Visa",
      "register": "2022-07-26 08:00:19"
    },
    {
      "last_4_digits": "XXXXXXXXXXXX1234",
      "identifier": "surec804a8ed60c747cb8843",
      "card_type": "MasterCard",
      "register": "2023-01-01 12:00:00"
    }
  ],
  "transactions": [
    {
      "created_at": "2020-09-30 19:58:35",
      "amount": "10000",
      "transaction": "204444",
      "authorization_code": "1234",
      "order": "001",
      "description": "description",
      "status": "success"
    }
  ],
  "logs": {
    "status": [
      {
        "change_date": "2021-02-17 16:11:53",
        "initial_status": "register",
        "final_status": "active"
      }
    ]
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string |  | Subscription identifier created by payku. — Example: `sucaab7865dceaff49d8b7` |
| `status` | string |  | Subscription status. The possible statuses you can get are the following: - register - active - finish - delete - cancel - suspended — Example: `active` |
| `start` | string |  | Subscription start date. — Example: `2019-07-22 18:34:49` |
| `end` | string |  | Subscription termination date. — Example: `2020-06-12 00:00:00` |
| `client` | object |  |  |
| ↳ `id` | string |  | Client identifier created by payku. — Example: `su7e5e1c0b1bd2e37ec557` |
| ↳ `name` | string |  | Client name. — Example: `name` |
| ↳ `email` | string |  | Client email. — Example: `example@domain.com` |
| ↳ `rut` | string |  | Unique Roll Tributary. — Example: `1.111.111-1` |
| ↳ `phone` | string |  | Client phone. — Example: `example@domain.com` |
| ↳ `parametros` | array of anys |  |  |
| ↳ `additional_parameters` | array of anys |  | Additional parameters that Payku can send. — Example: `` |
| `plan` | object |  |  |
| ↳ `id` | string |  | Identifier of the plan created by payku. — Example: `pl9697fb170834ad42dd00` |
| ↳ `name` | string |  | Plan name. — Example: `test plan` |
| ↳ `currency` | string |  | Currency. — Example: `CLP` |
| `cards` | object |  |  |
| ↳ `last_4_digits` | string |  | Last 4 digits of the affiliated card. — Example: `6622` |
| ↳ `card_type` | string |  | Card type. — Example: `Visa` |
| `active_cards` | array of objects |  | Example: `[{"last_4_digits":"XXXXXXXXXXXX6622","identifier":"surec804a8ed60c747cb8839","card_type":"Visa","register":"2022-07-26 08:00:19"},{"last_4_digits":"XXXXXXXXXXXX1234","identifier":"surec804a8ed60c747cb8843","card_type":"MasterCard","register":"2023-01-01 12:00:00"}]` |
| ↳ `last_4_digits` | string |  | Last 4 digits of the affiliated carda. — Example: `XXXXXXXXXXXX6622` |
| ↳ `identifier` | string |  | id card. — Example: `surec804a8ed60c747cb8839` |
| ↳ `card_type` | string |  | card type. — Example: `Visa` |
| ↳ `register` | string |  | Register date. — Example: `2022-07-26 08:00:19` |
| `transactions` | array of objects |  |  |
| ↳ `created_at` | string |  | Transaction creation date. — Example: `2020-09-30 19:58:35` |
| ↳ `amount` | string |  | Transaction amount. — Example: `10000` |
| ↳ `transaction` | string |  | Transaction number. — Example: `204444` |
| ↳ `authorization_code` | string |  | Authorization code. — Example: `1234` |
| ↳ `order` | string |  | Number of order. — Example: `001` |
| ↳ `description` | string |  | Description. — Example: `description` |
| ↳ `status` | string |  | Transaction status The possible statuses you can get are the following: - pending - success - rejected - refunded partial - refunded — Example: `success` |
| `logs` | object |  | Object with information records about subscriptions |
| ↳ `status` | array of objects |  | Array containing the status changes that were made on the subscription |
| ↳ ↳ `change_date` | string |  | Date the change was made — Example: `2021-02-17 16:11:53` |
| ↳ ↳ `initial_status` | string |  | Initial subscription status — Example: `register` |
| ↳ ↳ `final_status` | string |  | Final subscription status — Example: `active` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### Remove subscription

`DELETE /api/sususcription/{idSuscription}`

This method allows the removal of a subscription associated with a subscription id.

**Path parameters**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | ✓ | Unique transaction identifier per payku. — maximum 20 characters |

**CURL**

```text
curl -X DELETE \
https://BASE_URL/api/sususcription/id \
-H 'Accept: application/json, text/plain, */*' \
-H 'Sign: SIGN'  \
-H 'Authorization: Bearer TOKEN_PUBLICO'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE_URL' \
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('DELETE', 'https://BASE_URL/api/sususcription/sucaab7865dceaff49d8b3, [
      'headers' => [
        'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
        'Authorization' => 'Bearer PUBLIC-TOKEN'              ]
      ])->getBody();
    $response = json_decode($body);
```

**JS**

```js
const request = async () => {
  const response = await fetch('https://BASE_URL/api/sususcription/sucaab7865dceaff49d8b', {
    method: 'DELETE',
    headers: {
      'Content-Type': 'application/json',
      'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
  });
  const result = await response.json();
  console.log(result)
}

request(data);
```

**Responses**

*200*

```json
{
  "id": "sucaab7865dceaff49d8b3",
  "status": "success"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string |  | Transaction identifier created by payku. — Example: `sucaab7865dceaff49d8b3` |
| `status` | string |  | Status. — Example: `success` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### Afiliate card to subscription

`POST /api/suinscriptionscards`

This method allows the insertion of the data of a subscription card.

**Important**

In case you need to renew your client's card. this method will allow you to add a new card to the subscription.

**Immediately upon updating the card associated with the subscription, the system will be able to make the corresponding late charges according to the configuration of the subscribed plan!**,
That is, if the subscription is in a suspended status due to maximum collection attempts made, and the customer registers a new card, the system will be able to review pending payments, make the corresponding charge, and automatically activate the subscription.

**Request body**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `suscription` | string | ✓ | Subscription ID. — maximum 60 characters — Example: `sucaab7865dceaff49d8b3` |

**CURL**

```text
curl -X POST \
https://BASE_URL/api/suinscriptionscards \
-H 'Accept: application/json, text/plain, */*' \
-H 'Sign: SIGN'  \
-H 'Authorization: Bearer PUBLIC_TOKEN'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE_URL' \
-d {
    "suscription": "sucaab7865dceaff49d8b3"
  }'
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('POST', 'https://BASE_URL/api/suinscriptionscards', [
    'json' => [
      'suscription' => sucaab7865dceaff49d8b3,
      ],
      'headers' => [
        'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
        'Authorization' => 'Bearer PUBLIC-TOKEN'              ]
      ])->getBody();
    $response = json_decode($body);
```

**JS**

```js
const request = async (data) => {
  const response = await fetch('https://BASE_URL/api/suinscriptionscards', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
    body: JSON.stringify(data)
  });
  const result = await response.json();
  console.log(result)
}

let data = {
  suscription: "sucaab7865dceaff49d8b3"
};

request(data);
```

**Responses**

*200*

```json
{
  "status": "success",
  "id": "sucaab7865dceaff49d8b3",
  "url": "https://BASE_URL/gateway/registrosuscripcion?plan=true&token=246&validacion=d6b32"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Status. — Example: `success` |
| `id` | string |  | Unique subscription identifier for payku. — Example: `sucaab7865dceaff49d8b3` |
| `url` | string |  | URL paid and subscription activation. — Example: `https://BASE_URL/gateway/registrosuscripcion?plan=true&token=246&validacion=d6b32` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### Remove card

`POST /api/suscriptionsdeletecards`

This method allows you to delete a card associated with the subscription.

**Request body**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `suscription` | string | ✓ | ID of the associated card. — maximum 60 characters — Example: `surec804a8ed60c0a8cb8839` |

**CURL**

```text
curl -X POST \
https://BASE_URL/api/suscriptionsdeletecards \
-H 'Accept: application/json, text/plain, */*' \
-H 'Sign: SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN'  \
-H 'Authorization: Bearer PUBLIC_TOKEN'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE_URL' \
-d {
    "card": "surec804a8ed60c0a8cb8839"
  }'
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('POST', 'https://BASE_URL/api/suscriptionsdeletecards', [
    'json' => [
      'card' => surec804a8ed60c0a8cb8839,
      ],
      'headers' => [
        'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
        'Authorization' => 'Bearer PUBLIC_TOKEN'              ]
      ])->getBody();
    $response = json_decode($body);
```

**JS**

```js
const request = async (data) => {
  const response = await fetch('https://BASE_URL/api/suscriptionsdeletecards', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization': 'Bearer PUBLIC_TOKEN'
    },
    body: JSON.stringify(data)
  });
  const result = await response.json();
  console.log(result)
}

let data = {
  card: "surec804a8ed60c0a8cb8839"
};

request(data);
```

**Responses**

*200*

```json
{
  "status": "Delete",
  "card": "surec804a8ed60c0a8cb8839"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Status. — Example: `Delete` |
| `card` | string |  | Identificador único de La tarjeta asociada a la suscripción. — Example: `surec804a8ed60c0a8cb8839` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "card",
  "message_error": "is not valid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `card` |
| `message_error` | string |  | Mensaje de error — Example: `is not valid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### Check plan data

`GET /api/suplan/{idPlan}`

This method allows to obtain the details of a plan.

**Path parameters**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | ✓ | Unique plan identifier per payku. — maximum 20 characters |

**CURL**

```text
curl -X GET \
https://BASE_URL/api/suplan/id \
-H 'Accept: application/json, text/plain, */*' \
-H 'Sign: SIGN'  \
-H 'Authorization: Bearer TOKEN_PUBLICO'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE_URL' \
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('GET', 'https://BASE_URL/api/suplan/pl29f6ad69fbd594148c39', [
    'headers' => [
      'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization' => 'Bearer PUBLIC-TOKEN'
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async () => {
  const response = await fetch('https://BASE_URL/api/suplan/pl29f6ad69fbd594148c39', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
      'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
  });
  const result = await response.json();
  console.log(result)
}

request(data);
```

**Responses**

*200*

```json
{
  "status": "success",
  "plans": {
    "id": "pl4293e97a87195bb9edcd",
    "status": "active",
    "name": "Test plan",
    "code": "001",
    "description": "Test Plan",
    "url_notify_payment": "",
    "url_notify_suscription": "",
    "total_suscription": 0,
    "total_suscription_active": 0
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Status. — Example: `success` |
| `plans` | object |  |  |
| ↳ `id` | string |  | Unique plan identifier per payku. — Example: `pl4293e97a87195bb9edcd` |
| ↳ `status` | string |  | Plan status. — Example: `active` |
| ↳ `name` | string |  | Plan name. — Example: `Test plan` |
| ↳ `code` | string |  | Plan code. — Example: `001` |
| ↳ `description` | string |  | Plan description. — Example: `Test Plan` |
| ↳ `url_notify_payment` | string |  | Example: `` |
| ↳ `url_notify_suscription` | string |  | Example: `` |
| ↳ `total_suscription` | integer |  | Total subscriptions. — Example: `0` |
| ↳ `total_suscription_active` | integer |  | Total active subscriptions. — Example: `0` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### Check data from all plans

`GET /api/suplan/plans`

This method allows to obtain the details of all the plans.

**CURL**

```text
curl -X GET \
https://BASE_URL/api/suplan/plans \
-H 'Accept: application/json, text/plain, */*' \
-H 'Sign: SIGN'  \
-H 'Authorization: Bearer TOKEN_PUBLICO'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE_URL' \
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('GET', 'https://BASE_URL/api/suplan/plans', [
    'headers' => [
      'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization' => 'Bearer PUBLIC-TOKEN'
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async () => {
  const response = await fetch('https://BASE_URL/api/suplan/plans', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
      'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
  });
  const result = await response.json();
  console.log(result)
}

request(data);
```

**Responses**

*200*

```json
{
  "status": "success",
  "plans": [
    {
      "id": "pl4293e97a87195bb9edcd",
      "status": "active",
      "name": "Test plan",
      "code": "001",
      "description": "Test Plan",
      "url_notify_payment": "",
      "url_notify_suscription": "",
      "total_suscription": 0,
      "total_suscription_active": 0
    }
  ]
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Status. — Example: `success` |
| `plans` | array of objects |  |  |
| ↳ `id` | string |  | Unique plan identifier per payku. — Example: `pl4293e97a87195bb9edcd` |
| ↳ `status` | string |  | Plan status. — Example: `active` |
| ↳ `name` | string |  | Plan name. — Example: `Test plan` |
| ↳ `code` | string |  | Plan code. — Example: `001` |
| ↳ `description` | string |  | Plan description. — Example: `Test Plan` |
| ↳ `url_notify_payment` | string |  | Example: `` |
| ↳ `url_notify_suscription` | string |  | Example: `` |
| ↳ `total_suscription` | integer |  | Total subscriptions. — Example: `0` |
| ↳ `total_suscription_active` | integer |  | Total active subscriptions. — Example: `0` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### url Callback subscription notification

`POST /urlnotifysuscription`

After activating the subscription by the user, payku will notify the merchant, the result of the operation (status), making a post request to the subscription notification url previously provided in the creation of the subscription and in turn deliver a series of data for internal validations by the merchant application, the subscription id which corresponds to the unique identifier in payku. This data will allow the merchant to know the status of their subscriptions and back them up in their database.

**Responses**

*200*

```json
{
  "id": "su74866857980c7d2b4306",
  "status": "active"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string |  | Subscription identifier created by Payku. — Example: `su74866857980c7d2b4306` |
| `status` | string |  | Subscription status. The possible statuses you can get are the following: - register - active - finish - delete - cancel - suspended — Example: `active` |

### url Callback payment notification

`POST /urlnotifypayment`

After charging the subscription automatically, payku will notify the merchant, the result of the operation (status), making a post request to the payment notification url previously provided in the creation of the subscription and in turn deliver a data series for internal validations by the merchant application, the transactionn_id which corresponds to the unique identifier in payku and a verification_key, which corresponds to a unique validation hash per transaction. These data will allow the merchant to know the status of their transactions and back them up in their database.

**Responses**

*200*

```json
{
  "transaction_id": 9123123,
  "verification_key": "2ba83615f863e72sdca5dfd0a6df2782",
  "order": 1568041684,
  "status": "success"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `transaction_id` | number |  | Unique transaction identifier by Payku. — Example: `9123123` |
| `verification_key` | string |  | Unique transaction hash. — Example: `2ba83615f863e72sdca5dfd0a6df2782` |
| `order` | string |  | Unique transaction identifier sent by the merchant. — Example: `1568041684` |
| `status` | string |  | Transaction status The possible statuses you can get are the following: - pending - success - rejected - refunded partial - refunded — Example: `success` |

## Consumption Subscription

It is the set of methods that will allow our users to create clients, plans, subscriptions and carry out consumer plan transactions.

The main use of these methods is to make one-time charges to a customer for a service or product, such as hiring a delivery service for a product or the purchase of a particular product.

### Insert data to a Client

`POST /api/suclient/`

This method allows the insertion of Client data.

**Request body**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `email` | string | ✓ | Client email. — maximum 50 characters — Example: `joedoe@gmail.com` |
| `name` | string | ✓ | Client name — maximum 80 characters — Example: `Joe Doe` |
| `rut` | string |  | Single Tax Registry of the client, the entry of this data with or without a hyphen will be allowed. — 12 characters required — Example: `11111111` |
| `phone` | string | ✓ | Client phone. — 20 characters required — Example: `923122312` |
| `address` | string |  | Client address. — maximum 200 characters — Example: `Moneda 101` |
| `country` | string |  | Client country. — maximum 40 characters — Example: `Chile` |
| `region` | string |  | Client region. — maximum 120 characters — Example: `Metropolitana` |
| `city` | string |  | Client city. — maximum 40 characters — Example: `Santiago` |
| `postal_code` | string |  | Client Zip Code. — maximum 10 characters — Example: `850000` |
| `additional_parameters` | object |  | Client additional parameters — maximum 4000 characters |
| ↳ `parameter_1` | string |  | Client additional parameter — Example: `example` |
| ↳ `parameter_2` | string |  | Client additional parameter — Example: `example` |

**CURL**

```text
curl -X POST \
https://BASE_URL/api/suclient \
-H 'Accept: application/json, text/plain, */*' \
-H 'Sign: SIGN'  \
-H 'Authorization: Bearer TOKEN_PUBLICO'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE_URL' \
-d {
    "email": "joedoe@gmail.com",
    "name": "Joe Doe",
    "rut": "111111111",
    "phone": "923122312",
    "address": "Moneda 101",
    "country": "Chile",
    "region": "Metropolitana",
    "city": "Santiago",
    "postal_code": "850000,
    "additional_parameters":{
      "parameter_1": "example 1",
      "parameter_2": "example 2",
    }
  }'
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('POST', 'https://BASE_URL/api/suclient', [
    'json' => [
      'email' => 'joedoe@gmail.cl',
      'name' => 'Joe Doe',
      'rut' => '111111111',
      'phone' => '923122312',
      'address' => 'Moneda 101',
      'country' => 'Chile',
      'region' => 'Metropolitana',
      'city' => 'Santiago',
      'postal_code' => '850000',
      'additional_parameters' => [
          'parameter_1' => 'example',
          'parameter_2' => 'example 2'
        ]
      ],
    'headers' => [
      'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization' => 'Bearer PUBLIC-TOKEN'
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async (data) => {
  const response = await fetch('https://BASE_URL/api/suclient', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
    body: JSON.stringify(data)
  });
  const result = await response.json();
  console.log(result)
}

let data = {
  email: "joedoe@gmail.com",
  name: "Joe Doe",
  rut: "111111111",
  phone: "923122312",
  address: "Moneda 101",
  country: "Chile",
  region: "Metropolitana",
  city: "Santiago",
  postal_code: "850000",
  additional_parameters:{
    parameter_1: "example",
    parameter_2: "example 2",
  }
};

request(data);
```

**Responses**

*200*

```json
{
  "status": "active",
  "id": "cl0be4c8e623c167bc8b29",
  "rut": "11111111",
  "name": "Joe Doe",
  "phone": "923122312",
  "email": "joedoe@gmail.com",
  "address": "Moneda 101",
  "country": "Chile",
  "region": "Metropolitana",
  "city": "Santiago",
  "postal_code": "850000",
  "create_at": "2020-09-29",
  "update_at": null,
  "subcriptions": null,
  "additional_parameters": {
    "parameter_1": "example",
    "parameter_2": "example"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Client status. — Example: `active` |
| `id` | string |  | Identifier of the transaction created by payku. — Example: `cl0be4c8e623c167bc8b29` |
| `rut` | string |  | Single Tax Registry of the client. — Example: `11111111` |
| `name` | string |  | Client name. — Example: `Joe Doe` |
| `phone` | string |  | Client phone. — Example: `923122312` |
| `email` | string |  | Client email. — Example: `joedoe@gmail.com` |
| `address` | string |  | Client address. — Example: `Moneda 101` |
| `country` | string |  | Client country. — Example: `Chile` |
| `region` | string |  | Client region. — Example: `Metropolitana` |
| `city` | string |  | Client city. — Example: `Santiago` |
| `postal_code` | string |  | Client Zip Code. — Example: `850000` |
| `create_at` | string |  | Registration date. — Example: `2020-09-29` |
| `update_at` | string |  | Update date. |
| `subcriptions` | object |  | Client subscriptions. |
| `additional_parameters` | object |  | Client additional parameters |
| ↳ `parameter_1` | string |  | Client additional parameter — Example: `example` |
| ↳ `parameter_2` | string |  | Client additional parameter — Example: `example` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### Insert the data of a plan.

`POST /api/suplan/`

This method allows the insertion of data for the creation of a plan.

**Request body**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | string | ✓ | Plan name. — maximum 20 characters — Example: `Test plan` |
| `description` | string |  | Plan description. — maximum 1000 characters — Example: `Test Plan` |
| `url_notify_suscription` | string |  | URL where the subscription status will be notified. — maximum 240 characters — Example: `https://youwebsite.com/urlnotifysuscription` |
| `url_notify_payment` | string |  | URL where the payment status will be notified. — maximum 240 characters — Example: `https://youwebsite.com/urlnotifypayment` |
| `url_success_payment` | string |  | URL where the user will be redirected if the payment is successful. — maximum 240 characters — Example: `https://youwebsite.com/urlsuccesspayment` |
| `url_failed_payment` | string |  | URL where the user will be redirected if the payment is unsuccessful. — maximum 240 characters — Example: `https://youwebsite.com/urlfailedpayment` |

**CURL**

```text
curl -X POST \
https://BASE_URL/api/suplan \
-H 'Accept: application/json, text/plain, */*' \
-H 'Sign: SIGN'  \
-H 'Authorization: Bearer TOKEN_PUBLICO'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE_URL' \
-d {
    "name": "Test plan",
    "description": "Test Plan"
  }'
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('POST', 'https://BASE_URL/api/suplan', [
    'json' => [
      'name' => 'Test plan',
      'description' => 'Test Plan'
      ],
      'headers' => [
        'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
        'Authorization' => 'Bearer PUBLIC-TOKEN'              ]
      ])->getBody();
    $response = json_decode($body);
```

**JS**

```js
const request = async (data) => {
  const response = await fetch('https://BASE_URL/api/suplan', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
    body: JSON.stringify(data)
  });
  const result = await response.json();
  console.log(result)
}

let data = {
  name: "Test plan",
  description: "Test Plan"
};

request(data);
```

**Responses**

*200*

```json
{
  "status": "success",
  "id": "pl4293e97a87195bb9edcd"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Status. — Example: `success` |
| `id` | string |  | Unique plan identifier per payku. — Example: `pl4293e97a87195bb9edcd` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### Insert data for subscription

`POST /api/sususcription/`

This method allows the user of a Payku account to create a subscription to a fixed-amount subscription plan, a consumer plan subscription and a variable-amount subscription to one of its clients, for this last type of subscription it is necessary to send the amount that will be charged in the subscription, it is important to note that when making this request for the first time there will be a charge of $ 50 that allows verifying that the card is active and valid, in the case of a fixed subscription plan the service charge will be automatic From the month following the subscription date and in the event that the subscription is to a consumer plan, it will be necessary to use the api / sutransaction endpoint to generate the transaction.

**Request body**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `plan` | string | ✓ | Plan id. — maximum 70 characters — Example: `pl9697fb170834ad42dd00` |
| `client` | string | ✓ | Client id. — maximum 20 characters — Example: `cl9b1e1dd988694f30fa30` |

**CURL**

```text
curl -X POST \
https://BASE_URL/api/sususcription \
-H 'Accept: application/json, text/plain, */*' \
-H 'Sign: SIGN'  \
-H 'Authorization: Bearer TOKEN_PUBLICO'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE_URL' \
-d {
    "plan": "pl9697fb170834ad42dd00",
    "client": "cl9b1e1dd988694f30fa30"
  }'
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('POST', 'https://BASE_URL/api/sususcription, [
    'json' => [
      'plan' => 'pl9697fb170834ad42dd00',
      'client' => 'cl9b1e1dd988694f30fa30',
      ],
      'headers' => [
        'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
        'Authorization' => 'Bearer PUBLIC-TOKEN'
      ]
    ])->getBody();
  $response = json_decode($body);
```

**JS**

```js
const request = async (data) => {
  const response = await fetch('https://BASE_URL/api/sususcription', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
    body: JSON.stringify(data)
  });
  const result = await response.json();
  console.log(result)
}

let data = {
  plan: "pl9697fb170834ad42dd00",
  client: "cl9b1e1dd988694f30fa30"
};

request(data);
```

**Responses**

*200*

```json
{
  "status": "register",
  "id": "sucaab7865dceaff49d8b3",
  "url": "http://app.payku.cl/gateway/registrosuscripcion?tipoplan=2&plan=true&token=219&validacion=e6c50ba0e0"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Status. — Example: `register` |
| `id` | string |  | Unique subscription identifier for payku. — Example: `sucaab7865dceaff49d8b3` |
| `url` | string |  | Url payment and subscription activation. — Example: `http://app.payku.cl/gateway/registrosuscripcion?tipoplan=2&plan=true&token=219&validacion=e6c50ba0e0` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### Insert data for the transaction

`POST /api/sutransaction/`

This method allows the user of a Payku account to generate a unique transaction to one of his clients who are subscribed to a consumption plan.

**Request body**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `suscription` | string | ✓ | Unique subscription identifier for payku. — maximum 60 characters — Example: `sucaab7865dceaff49d8b3` |
| `amount` | string |  | Amount. — maximum 14 digits — Example: `10000` |
| `order` | string |  | Order. — maximum 40 characters — Example: `001` |
| `description` | string |  | Description. — maximum 1000 characters — Example: `Description` |
| `marketplace` | string |  | ma0690b6451a7043d5. — 20 characters — Example: `ma0690b6451a7043d5` |
| `card` | string |  | With the identifier you can indicate which of the active cards will be charged (OPTIONAL). — maximum 28 characters — Example: `surea041d8a4413949425fec` |

**CURL**

```text
curl -X POST \
https://BASE_URL/api/sutransaction \
-H 'Accept: application/json, text/plain, */*' \
-H 'Sign: SIGN'  \
-H 'Authorization: Bearer TOKEN_PUBLICO'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE_URL' \
-d {
    "suscription": "sucaab7865dceaff49d8b3",
    "amount": "10000",
    "order": "001",
    "description": "Description",
    "marketplace": "ma0690b6451a7043d5"
  }'
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('POST', 'https://BASE_URL/api/sutransaction, [
    'json' => [
      'suscription' => sucaab7865dceaff49d8b3,
      'order' => '001',
      'monto' => '10000',
      'description' => 'Description',
      'marketplace' => 'ma0690b6451a7043d5'
      ],
      'headers' => [
        'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
        'Authorization' => 'Bearer PUBLIC-TOKEN'
      ]
    ])->getBody();
  $response = json_decode($body);
```

**JS**

```js
const request = async (data) => {
  const response = await fetch('https://BASE_URL/api/sutransaction', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
    body: JSON.stringify(data)
  });
  const result = await response.json();
  console.log(result)
}

let data = {
  suscription: "sucaab7865dceaff49d8b3",
  amount: "10000",
  order: "001",
  description: "Description",
  marketplace: "ma0690b6451a7043d5"
};

request(data);
```

**Responses**

*200*

```json
{
  "status": "success",
  "order": "001",
  "amount": "10000",
  "transaction_id": "204444",
  "verification_key": "025dcad37e071daa8bfc2df35189009db65692a4ff766856108be1675e870839"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Transaction status. The possible statuses you can get are the following: - pending - success - rejected - refunded partial - refunded — Example: `success` |
| `order` | string |  | Order. — Example: `001` |
| `amount` | string |  | Amount. — Example: `10000` |
| `transaction_id` | string |  | Transaction number. — Example: `204444` |
| `verification_key` | string |  | Example: `025dcad37e071daa8bfc2df35189009db65692a4ff766856108be1675e870839` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### Remove card

`POST /api/suscriptionsdeletecards/`

This method allows you to delete a card associated with the subscription.

**Request body**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `suscription` | string | ✓ | ID of the associated card. — maximum 60 characters — Example: `surec804a8ed60c0a8cb8839` |

**CURL**

```text
curl -X POST \
https://BASE_URL/api/suscriptionsdeletecards \
-H 'Accept: application/json, text/plain, */*' \
-H 'Sign: SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN'  \
-H 'Authorization: Bearer PUBLIC_TOKEN'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE_URL' \
-d {
    "card": "surec804a8ed60c0a8cb8839"
  }'
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('POST', 'https://BASE_URL/api/suscriptionsdeletecards', [
    'json' => [
      'card' => surec804a8ed60c0a8cb8839,
      ],
      'headers' => [
        'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
        'Authorization' => 'Bearer PUBLIC_TOKEN'              ]
      ])->getBody();
    $response = json_decode($body);
```

**JS**

```js
const request = async (data) => {
  const response = await fetch('https://BASE_URL/api/suscriptionsdeletecards', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization': 'Bearer PUBLIC_TOKEN'
    },
    body: JSON.stringify(data)
  });
  const result = await response.json();
  console.log(result)
}

let data = {
  card: "surec804a8ed60c0a8cb8839"
};

request(data);
```

**Responses**

*200*

```json
{
  "status": "Delete",
  "card": "surec804a8ed60c0a8cb8839"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Status. — Example: `Delete` |
| `card` | string |  | Identificador único de La tarjeta asociada a la suscripción. — Example: `surec804a8ed60c0a8cb8839` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "card",
  "message_error": "is not valid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `card` |
| `message_error` | string |  | Mensaje de error — Example: `is not valid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

## Wallet

With this Wallet method you can create your wallet in **Payku**.

### Make payments to third parties from my wallet

`POST /api/wallet/payout`

This method allows you to create a payment order to a third party using the funds in your wallet virtual **payku**.

**Note:** For testing purposes (Development environment only), specific amounts will be processed automatically:
<br>
&bull;  Amounts 1000, 2000, 3000: Will be marked as **approved** automatically.
<br>
&bull;  Amounts 1500, 2500, 3500: Will be marked as **rejected** automatically.

**Request body**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `email` | string | ✓ | Client email — maximum 50 characters — Example: `support@youwebsite.cl` |
| `phone` | string |  | Client phone — maximum 20 characters — Example: `923122312` |
| `subject` | string | ✓ | Order Description — maximum 200 characters — Example: `test subject` |
| `currency` | string | ✓ | Currency description (ISO format) — maximum 6 characters — Example: `CLP` |
| `order` | string | ✓ | E-commerce order — maximum 80 characters — Example: `98745` |
| `amount` | integer | ✓ | Order amount — maximum 14 digits — Example: `25000` |
| `accountbank_name` | string | ✓ | Name of the destination account holder — maximum 180 characters — Example: `José Manuel Muñoz Alarcon` |
| `accountbank_rut` | string | ✓ | Rut of the destination account holder — maximum 15 characters — Example: `111111111` |
| `accountbank_sbif` | string | ✓ | Code of the bank to which the bank account belongs. — maximum 4 characters — Example: `0001` |
| `accountbank_type` | string | ✓ | Account type. - 1 Corriente - 2 Vista/Cuenta RUT - 3 Ahorro — maximum 1 character — Example: `1` |
| `accountbank_num` | string | ✓ | Customer account number - **For the bank "banco estado" (sbif 0012) the maximum number of characters is 12 This bank is the most common in Chile, it is good to add the validation of maximum digits of 12. This prevents users from entering their debit card number For the rest of the banks, it can have more than 12 characters since the banks are not standardized in their account number format.** — maximum 200 characters — Example: `12312312312` |
| `url_notify` | string |  | url where the result of the payment will be notified. - Note: After making the payment to third parties, payku will automatically respond to the endpoint entered in urlnotify the result of the operation. - **Approved Example:** - { - "id": "morexzxxxx", - "identifier_payout": "morexzxxxx", - "order" : "367734544", - "status" : "success", - "update_at" : "2023-08-24 12:29:35", - "customer" : { - "name" : "Jhon Doe", - "phone" : "978456879", - "document" : "111111111", - "number" : "978456879" - } - } - **Rejected Example:** - { - "id": "morexzxxxx", - "identifier_payout": "morexzxxxx", - "order" : "367734544", - "status" : "banking_error", - "update_at" : "2023-08-24 12:29:35", - "customer" : { - "name" : "Jhon Doe", - "phone" : "978456879", - "document" : "111111111", - "number" : "978456879" - } - } — maximum 600 characters — Example: `https://youwebsite.com/urlnotify?orderClient=98745` |
| `additional_parameters` | object |  | Client additional parameters — maximum 4000 characters |
| ↳ `parameter_1` | string |  | Parameter name given by user payku — Example: `keyValue` |
| ↳ `parameter_2` | string |  | Parameter name given by user payku — Example: `keyValue2` |
| ↳ `order_ext` | string |  | Name of the external order given by the user payku (Optional) — Example: `fff-777` |

**cURL**

```bash
curl -X POST \
https://BASE-URL/api/wallet/payout \
-H 'Accept: application/json, text/plain, */*' \
-H 'Authorization: Bearer PUBLIC-TOKEN' \
-H 'Sign: SIGN'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE-URL' \
-d '{
  "email": "example@payku.cl",
  "phone": "123456789",
  "subject": "subject",
  "currency": "CLP",
  "order": "98745",
  "amount":  1000,
  "accountbank_name": "example name",
  "accountbank_rut": "111111111",
  "accountbank_sbif": "0001",
  "accountbank_type": "1",
  "accountbank_num": "12312312312",
  "url_notify": "https://youwebsite.com/urlnotify?orderClient=98745",
  "additional_parameters":
    {
    "parameters1": "keyValue",
    "parameters2": "keyValue2",
    "order_ext": "fff-777"
    }
}'
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('POST', 'https://BASE_URL/api/wallet/payout', [
    'json' => [
        'email' => 'example@payku.cl',
        'phone' => '123456789',
        'subject' => 'subject',
        'order' => "133222",
        'currency' => 'CLP',
        'amount' =>  1000,
        'accountbank_name' => 'example name',
        'accountbank_rut' => '111111111',
        'accountbank_sbif' => '0001',
        'accountbank_type' => '1',
        'accountbank_num' => '12312312312',
        'url_notify' => 'https://youwebsite.com/urlnotify?orderClient=98745',
        'additional_parameters' =>
        [
        'parameters1' => 'keyValue',
        'parameters2' => 'keyValue2',
        'order_ext' => 'fff-777'
        ]
      ],
    'headers' => [
      'Authorization' => 'Bearer PUBLIC-TOKEN',
      'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN'
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async (data) => {
  const response = await fetch('https://BASE_URL/api/wallet/payout', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
    body: JSON.stringify(data)
  });
  const result = await response.json();
  console.log(result)
}

let data = {
  "email": "example@payku.cl",
  "phone": "123456789",
  "subject": "subject",
  "currency": "CLP",
  "order": "133222",
  "amount":  1000,
  "accountbank_name": "example name",
  "accountbank_rut": "111111111",
  "accountbank_sbif": "0001",
  "accountbank_type": "1",
  "accountbank_num": "12312312312",
  "url_notify": "https://youwebsite.com/urlnotify?orderClient=98745",
  "additional_parameters":
    {
    "parameters1": "keyValue",
    "parameters2": "keyValue2",
    "order_ext": "fff-777"
    }
};

request(data);
```

**Responses**

*200*

```json
{
  "status": "success",
  "identifier_wallet": "wab5f7232dafff18f9",
  "identifier_payout": "mor33e36b01e8a11b9ee"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Status of the load to the wallet. The possible statuses that can be obtained are the following: - success - failed — Example: `success` |
| `identifier_wallet` | string |  | payku virtual wallet movement identifier. — Example: `wab5f7232dafff18f9` |
| `identifier_payout` | string |  | Third party payment identifier. — Example: `mor33e36b01e8a11b9ee` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### Withdraw money from my wallet

`POST /api/wallet/withdraw`

This method allows you to create a settlement to the merchant's bank account using the funds from your virtual wallet **payku**.

**Request body**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `subject` | string | ✓ | Order Description — maximum 200 characters — Example: `test subject` |
| `currency` | string | ✓ | Currency description (ISO format) — maximum 6 characters — Example: `CLP` |
| `order` | string | ✓ | E-commerce order — maximum 80 characters — Example: `98745` |
| `amount` | integer | ✓ | order amount — maximum 14 digitis — Example: `25000` |

**cURL**

```bash
curl -X POST \
https://BASE-URL/api/wallet/withdraw \
-H 'Accept: application/json, text/plain, */*' \
-H 'Authorization: Bearer PUBLIC-TOKEN' \
-H 'Sign: SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE-URL' \
-d '{
  "subject": "subject",
  "currency": "CLP",
  "order": "98745",
  "amount":  1000
}'
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('POST', 'https://BASE_URL/api/wallet/withdraw', [
    'json' => [
        'subject' => 'subject',
        'order' => "98745",
        'currency' => 'CLP',
        'amount' =>  1000
      ],
    'headers' => [
      'Authorization' => 'Bearer PUBLIC-TOKEN',
      'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN'
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async (data) => {
  const response = await fetch('https://BASE_URL/api/wallet/withdraw', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
    body: JSON.stringify(data)
  });
  const result = await response.json();
  console.log(result)
}

let data = {
  "amount":  1000,
  "currency": "CLP",
  "order": "98745",
  "subject": "subject"
};

request(data);
```

**Responses**

*200*

```json
{
  "status": "Success",
  "identifier_wallet": "wab5f7232dafff18f9"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Status of the load to the wallet. The possible statuses that can be obtained are the following: - success — Example: `Success` |
| `identifier_wallet` | string |  | payku virtual wallet movement identifier. — Example: `wab5f7232dafff18f9` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

### Get balance

`GET /api/wallet`

This method allows you to obtain the balance of your virtual wallet **payku**.

**CURL**

```text
curl -X GET \
https://BASE-URL/api/wallet  \
-H 'Accept: application/json, text/plain, */*' \
-H 'Authorization: Bearer PUBLIC-TOKEN' \
-H 'Sign: SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE-URL' \
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('GET', 'https://BASE_URL/api/wallet', [
    'headers' => [
      'Authorization' => 'Bearer PUBLIC-TOKEN',
      'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN'
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async () => {
  const response = await fetch('https://BASE_URL/api/wallet', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer PUBLIC-TOKEN',
      'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN'
    },
  });
  const result = await response.json();
  console.log(result)
}

request();
```

**Responses**

*200*

```json
{
  "status": "success",
  "current_id": "wa8a6171ab83323c37",
  "amount_available": 1766,
  "currency": "CLP",
  "filter": {
    "page": 1,
    "per_page": 1000,
    "currency": "CLP",
    "id": "wa8a6171ab83323c37"
  },
  "wallet_movements": [
    {
      "id": "wa8a6171ab83323c37",
      "order": "tme5",
      "subject": "tme5 asunto",
      "created_at": "2022-06-09 20:07:02",
      "income_expense": "expense",
      "status": "current",
      "amount": "3680",
      "actual_amount": "1766",
      "origin_liquidation": null,
      "currency": "CLP",
      "payout": {
        "id": "war3999847529816f2",
        "phone": "111111111",
        "email": "test@test.cl",
        "subject": "subject order",
        "amount": "3680",
        "accountbank_rut": "111111111",
        "accountbank_name": "test",
        "accountbank_type": 1,
        "accountbank_num": 123123123,
        "accountbank_sbif": "0001",
        "status": "pending",
        "update_at": "2022-06-09 21:10:46"
      }
    }
  ]
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Example: `success` |
| `current_id` | string |  | Payku virtual wallet identifier "last movements". — Example: `wa8a6171ab83323c37` |
| `amount_available` | integer |  | Amount available in Payku's virtual wallet. — Example: `1766` |
| `currency` | string |  | Currency. — Example: `CLP` |
| `filter` | object |  | Specific data to filter the data. |
| ↳ `page` | integer |  | Actual page. — Example: `1` |
| ↳ `per_page` | integer |  | Number of moves per page. — Example: `1000` |
| ↳ `currency` | string |  | Currency. — Example: `CLP` |
| ↳ `id` | string |  | Wallet account identifier. — Example: `wa8a6171ab83323c37` |
| `wallet_movements` | array of objects |  |  |
| ↳ `id` | string |  | Virtual wallet identifier. — Example: `wa8a6171ab83323c37` |
| ↳ `order` | string |  | Order identifier. — Example: `tme5` |
| ↳ `subject` | string |  | Description of the movement. — Example: `tme5 asunto` |
| ↳ `created_at` | string |  | Movement execution date. — Example: `2022-06-09 20:07:02` |
| ↳ `income_expense` | string |  | Payment to a third party or withdrawal to your account. — Example: `expense` |
| ↳ `status` | string |  | Movement status. — Example: `current` |
| ↳ `amount` | string |  | Movement amount. — Example: `3680` |
| ↳ `actual_amount` | string |  | Current Balance Amount. — Example: `1766` |
| ↳ `origin_liquidation` | string |  | Origin of settlement. |
| ↳ `currency` | string |  | Currency. — Example: `CLP` |
| ↳ `payout` | object |  | Destination account data. |
| ↳ ↳ `id` | string |  | Destination account identifier. — Example: `war3999847529816f2` |
| ↳ ↳ `phone` | string |  | Telephone of the destination account holder. — Example: `111111111` |
| ↳ ↳ `email` | string |  | Destination account holder's email. — Example: `test@test.cl` |
| ↳ ↳ `subject` | string |  | Application Status. — Example: `subject order` |
| ↳ ↳ `amount` | string |  | Amount to be deposited in the destination account. — Example: `3680` |
| ↳ ↳ `accountbank_rut` | string |  | Rut of the destination account holder. — Example: `111111111` |
| ↳ ↳ `accountbank_name` | string |  | Name of the destination account holder. — Example: `test` |
| ↳ ↳ `accountbank_type` | integer |  | Type of account of the destination bank. — Example: `1` |
| ↳ ↳ `accountbank_num` | integer |  | Destination bank account number. — Example: `123123123` |
| ↳ ↳ `accountbank_sbif` | string |  | Code of the bank to which the bank account belongs. — Example: `0001` |
| ↳ ↳ `status` | string |  | Movement status. — Example: `pending` |
| ↳ ↳ `update_at` | string |  | Date the request was made. — Example: `2022-06-09 21:10:46` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

*404* — Identifier does not exist.

```json
{
  "status": "failed",
  "type": "Not Found",
  "id": "is not valid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Not Found` |
| `id` | string |  | Id information — Example: `is not valid` |

### get moves

`GET /api/wallet/list`

This method allows you to obtain the movements of your virtual wallet **payku**, this method allows pagination with a maximum of 4000 records per page, In addition, it has the following filters:

For pagination it is necessary to add the following at the end of the endpoint ?page=1&per_page=100 being the first parameter the number of the page and the second the number of records per page As for example: **api/wallet/list?page=1&per_page=100**.

**CURL**

```text
curl -X GET \
https://BASE-URL/api/wallet/list  \
-H 'Accept: application/json, text/plain, */*' \
-H 'Authorization: Bearer PUBLIC-TOKEN' \
-H 'Sign: SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE-URL' \
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('GET', 'https://BASE_URL/api/wallet/list', [
    'headers' => [
      'Authorization' => 'Bearer PUBLIC-TOKEN',
      'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN'
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async () => {
  const response = await fetch('https://BASE_URL/api/wallet/list', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer PUBLIC-TOKEN',
      'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN'
    },
  });
  const result = await response.json();
  console.log(result)
}

request();
```

**Responses**

*200*

```json
{
  "status": "success",
  "current_id": "wa8a6171ab83323c37",
  "amount_available": 1766,
  "currency": "CLP",
  "filter": {
    "page": 1,
    "per_page": 1000,
    "currency": "CLP",
    "id": "wa8a6171ab83323c37"
  },
  "wallet_movements": [
    {
      "id": "wa8a6171ab83323c37",
      "order": "tme5",
      "subject": "tme5 asunto",
      "created_at": "2022-06-09 20:07:02",
      "income_expense": "expense",
      "status": "current",
      "amount": "3680",
      "actual_amount": "1766",
      "origin_liquidation": null,
      "currency": "CLP",
      "payout": {
        "id": "war3999847529816f2",
        "phone": "111111111",
        "email": "test@test.cl",
        "subject": "subject order",
        "amount": "3680",
        "accountbank_rut": "111111111",
        "accountbank_name": "test",
        "accountbank_type": 1,
        "accountbank_num": 123123123,
        "accountbank_sbif": "0001",
        "status": "pending",
        "update_at": "2022-06-09 21:10:46"
      }
    }
  ]
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Example: `success` |
| `current_id` | string |  | Payku virtual wallet identifier "last movements". — Example: `wa8a6171ab83323c37` |
| `amount_available` | integer |  | Amount available in Payku's virtual wallet. — Example: `1766` |
| `currency` | string |  | Currency. — Example: `CLP` |
| `filter` | object |  | Specific data to filter the data. |
| ↳ `page` | integer |  | Actual page. — Example: `1` |
| ↳ `per_page` | integer |  | Number of moves per page. — Example: `1000` |
| ↳ `currency` | string |  | Currency. — Example: `CLP` |
| ↳ `id` | string |  | Wallet account identifier. — Example: `wa8a6171ab83323c37` |
| `wallet_movements` | array of objects |  |  |
| ↳ `id` | string |  | Virtual wallet identifier. — Example: `wa8a6171ab83323c37` |
| ↳ `order` | string |  | Order identifier. — Example: `tme5` |
| ↳ `subject` | string |  | Description of the movement. — Example: `tme5 asunto` |
| ↳ `created_at` | string |  | Movement execution date. — Example: `2022-06-09 20:07:02` |
| ↳ `income_expense` | string |  | Payment to a third party or withdrawal to your account. — Example: `expense` |
| ↳ `status` | string |  | Movement status. — Example: `current` |
| ↳ `amount` | string |  | Movement amount. — Example: `3680` |
| ↳ `actual_amount` | string |  | Current Balance Amount. — Example: `1766` |
| ↳ `origin_liquidation` | string |  | Origin of settlement. |
| ↳ `currency` | string |  | Currency. — Example: `CLP` |
| ↳ `payout` | object |  | Destination account data. |
| ↳ ↳ `id` | string |  | Destination account identifier. — Example: `war3999847529816f2` |
| ↳ ↳ `phone` | string |  | Telephone of the destination account holder. — Example: `111111111` |
| ↳ ↳ `email` | string |  | Destination account holder's email. — Example: `test@test.cl` |
| ↳ ↳ `subject` | string |  | Application Status. — Example: `subject order` |
| ↳ ↳ `amount` | string |  | Amount to be deposited in the destination account. — Example: `3680` |
| ↳ ↳ `accountbank_rut` | string |  | Rut of the destination account holder. — Example: `111111111` |
| ↳ ↳ `accountbank_name` | string |  | Name of the destination account holder. — Example: `test` |
| ↳ ↳ `accountbank_type` | integer |  | Type of account of the destination bank. — Example: `1` |
| ↳ ↳ `accountbank_num` | integer |  | Destination bank account number. — Example: `123123123` |
| ↳ ↳ `accountbank_sbif` | string |  | Code of the bank to which the bank account belongs. — Example: `0001` |
| ↳ ↳ `status` | string |  | Movement status. — Example: `pending` |
| ↳ ↳ `update_at` | string |  | Date the request was made. — Example: `2022-06-09 21:10:46` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

*404* — Identifier does not exist.

```json
{
  "status": "failed",
  "type": "Not Found",
  "id": "is not valid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Not Found` |
| `id` | string |  | Id information — Example: `is not valid` |

### Get move

`GET /api/wallet/{identificadorWallet}`

This method allows to obtain a movement of your virtual wallet **payku** using an identifier:

To perform the query it is necessary to add the following at the end of the endpoint /{identificadorWallet} for example: **api/wallet/wa24bg36767**.

**CURL**

```text
curl -X GET \
https://BASE-URL/api/wallet/{idWallet}  \
-H 'Accept: application/json, text/plain, */*' \
-H 'Authorization: Bearer PUBLIC-TOKEN' \
-H 'Sign: SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE-URL' \
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('GET', 'https://BASE_URL/api/wallet/{idWallet}', [
    'headers' => [
      'Authorization' => 'Bearer PUBLIC-TOKEN',
      'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN'
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async () => {
  const response = await fetch('https://BASE_URL/api/wallet/{idWallet}', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer PUBLIC-TOKEN',
      'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN'
    },
  });
  const result = await response.json();
  console.log(result)
}

request();
```

**Responses**

*200*

```json
{
  "status": "success",
  "current_id": "wa8a6171ab83323c37",
  "amount_available": 1766,
  "currency": "CLP",
  "filter": {
    "page": 1,
    "per_page": 1000,
    "currency": "CLP",
    "id": "wa8a6171ab83323c37"
  },
  "wallet_movements": [
    {
      "id": "wa8a6171ab83323c37",
      "order": "tme5",
      "subject": "tme5 asunto",
      "created_at": "2022-06-09 20:07:02",
      "income_expense": "expense",
      "status": "current",
      "amount": "3680",
      "actual_amount": "1766",
      "origin_liquidation": null,
      "currency": "CLP",
      "payout": {
        "id": "war3999847529816f2",
        "phone": "111111111",
        "email": "test@test.cl",
        "subject": "subject order",
        "amount": "3680",
        "accountbank_rut": "111111111",
        "accountbank_name": "test",
        "accountbank_type": 1,
        "accountbank_num": 123123123,
        "accountbank_sbif": "0001",
        "status": "pending",
        "update_at": "2022-06-09 21:10:46"
      }
    }
  ]
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Example: `success` |
| `current_id` | string |  | Payku virtual wallet identifier "last movements". — Example: `wa8a6171ab83323c37` |
| `amount_available` | integer |  | Amount available in Payku's virtual wallet. — Example: `1766` |
| `currency` | string |  | Currency. — Example: `CLP` |
| `filter` | object |  | Specific data to filter the data. |
| ↳ `page` | integer |  | Actual page. — Example: `1` |
| ↳ `per_page` | integer |  | Number of moves per page. — Example: `1000` |
| ↳ `currency` | string |  | Currency. — Example: `CLP` |
| ↳ `id` | string |  | Wallet account identifier. — Example: `wa8a6171ab83323c37` |
| `wallet_movements` | array of objects |  |  |
| ↳ `id` | string |  | Virtual wallet identifier. — Example: `wa8a6171ab83323c37` |
| ↳ `order` | string |  | Order identifier. — Example: `tme5` |
| ↳ `subject` | string |  | Description of the movement. — Example: `tme5 asunto` |
| ↳ `created_at` | string |  | Movement execution date. — Example: `2022-06-09 20:07:02` |
| ↳ `income_expense` | string |  | Payment to a third party or withdrawal to your account. — Example: `expense` |
| ↳ `status` | string |  | Movement status. — Example: `current` |
| ↳ `amount` | string |  | Movement amount. — Example: `3680` |
| ↳ `actual_amount` | string |  | Current Balance Amount. — Example: `1766` |
| ↳ `origin_liquidation` | string |  | Origin of settlement. |
| ↳ `currency` | string |  | Currency. — Example: `CLP` |
| ↳ `payout` | object |  | Destination account data. |
| ↳ ↳ `id` | string |  | Destination account identifier. — Example: `war3999847529816f2` |
| ↳ ↳ `phone` | string |  | Telephone of the destination account holder. — Example: `111111111` |
| ↳ ↳ `email` | string |  | Destination account holder's email. — Example: `test@test.cl` |
| ↳ ↳ `subject` | string |  | Application Status. — Example: `subject order` |
| ↳ ↳ `amount` | string |  | Amount to be deposited in the destination account. — Example: `3680` |
| ↳ ↳ `accountbank_rut` | string |  | Rut of the destination account holder. — Example: `111111111` |
| ↳ ↳ `accountbank_name` | string |  | Name of the destination account holder. — Example: `test` |
| ↳ ↳ `accountbank_type` | integer |  | Type of account of the destination bank. — Example: `1` |
| ↳ ↳ `accountbank_num` | integer |  | Destination bank account number. — Example: `123123123` |
| ↳ ↳ `accountbank_sbif` | string |  | Code of the bank to which the bank account belongs. — Example: `0001` |
| ↳ ↳ `status` | string |  | Movement status. — Example: `pending` |
| ↳ ↳ `update_at` | string |  | Date the request was made. — Example: `2022-06-09 21:10:46` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

*404* — Identifier does not exist.

```json
{
  "status": "failed",
  "type": "Not Found",
  "id": "is not valid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Not Found` |
| `id` | string |  | Id information — Example: `is not valid` |

### get payout

`GET /api/payout/{identificadorPayout}`

This method allows you to obtain a movement of payments to third parties from your **payku** virtual wallet using an identifier:

To perform the query it is necessary to add the following at the end of the endpoint /{identificadorPayout} for example: **api/payout/wa24bg36767**.

**CURL**

```text
curl -X GET \
https://BASE-URL/api/payout/{identificadorPayout}  \
-H 'Accept: application/json, text/plain, */*' \
-H 'Authorization: Bearer PUBLIC-TOKEN' \
-H 'Sign: SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE-URL' \
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('GET', 'https://BASE_URL/api/payout/{identificadorPayout}', [
    'headers' => [
      'Authorization' => 'Bearer PUBLIC-TOKEN',
      'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN'
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async () => {
  const response = await fetch('https://BASE_URL/api/payout/{identificadorPayout}', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer PUBLIC-TOKEN',
      'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN'
    },
  });
  const result = await response.json();
  console.log(result)
}

request();
```

**Responses**

*200*

```json
{
  "payout": {
    "id": "war3999847529816f2",
    "phone": "111111111",
    "email": "test@test.cl",
    "subject": "subject order",
    "amount": "3680",
    "accountbank_rut": "111111111",
    "accountbank_name": "test",
    "accountbank_type": 1,
    "accountbank_num": 123123123,
    "accountbank_sbif": "0001",
    "status": "pending",
    "update_at": "2022-06-09 21:10:46",
    "origin_wallet": "wa1933f37cdaf7d1c6"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `payout` | object |  | Destination account identifier. |
| ↳ `id` | string |  | Destination account identifier. — Example: `war3999847529816f2` |
| ↳ `phone` | string |  | Telephone of the destination account holder. — Example: `111111111` |
| ↳ `email` | string |  | Destination account holder's email. — Example: `test@test.cl` |
| ↳ `subject` | string |  | Application Status. — Example: `subject order` |
| ↳ `amount` | string |  | Amount to be deposited in the destination account. — Example: `3680` |
| ↳ `accountbank_rut` | string |  | Rut of the destination account holder. — Example: `111111111` |
| ↳ `accountbank_name` | string |  | Name of the destination account holder. — Example: `test` |
| ↳ `accountbank_type` | integer |  | Type of account of the destination bank. — Example: `1` |
| ↳ `accountbank_num` | integer |  | Destination bank account number. — Example: `123123123` |
| ↳ `accountbank_sbif` | string |  | Code of the bank to which the bank account belongs. — Example: `0001` |
| ↳ `status` | string |  | Movement status. - pending ("payout registered") - processing ("payout in payment process") - success ("payout successfully deposited") - banking_error ("payout rejected by the bank") - fraud_prevention ("payout rejected by compliance") — Example: `pending` |
| ↳ `update_at` | string |  | Date the request was made. — Example: `2022-06-09 21:10:46` |
| ↳ `origin_wallet` | string |  | Id de la wallet origen. — Example: `wa1933f37cdaf7d1c6` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

*404* — Identifier does not exist.

```json
{
  "status": "failed",
  "type": "Not Found",
  "id": "is not valid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Not Found` |
| `id` | string |  | Id information — Example: `is not valid` |

### get payout V3

`GET /api/payoutv3/{identificadorPayout}`

This method allows you to obtain a movement of payments to third parties from your **payku** virtual wallet using an identifier:

To perform the query it is necessary to add the following at the end of the endpoint /{identificadorPayout} for example: **api/payoutv3/mor33e36b01e8a11b9ee**.

**CURL**

```text
curl -X GET \
https://BASE-URL/api/payoutv3/{identificadorPayout}  \
-H 'Accept: application/json, text/plain, */*' \
-H 'Authorization: Bearer PUBLIC-TOKEN' \
-H 'Sign: SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN'  \
-H 'Content-Type: application/json' \
-H 'Host: BASE-URL' \
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('GET', 'https://BASE_URL/api/payoutv3/{identificadorPayout}', [
    'headers' => [
      'Authorization' => 'Bearer PUBLIC-TOKEN',
      'Sign' => 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN'
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async () => {
  const response = await fetch('https://BASE_URL/api/payoutv3/{identificadorPayout}', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer PUBLIC-TOKEN',
      'Sign': 'SHA256-REQUEST-PATH-VALUE-PRIVATE-TOKEN'
    },
  });
  const result = await response.json();
  console.log(result)
}

request();
```

**Responses**

*200*

```json
{
  "payout": {
    "id": "war3999847529816f2",
    "phone": "111111111",
    "email": "test@test.cl",
    "subject": "subject order",
    "amount": "3680",
    "accountbank_rut": "111111111",
    "accountbank_name": "test",
    "accountbank_type": 1,
    "accountbank_num": 123123123,
    "accountbank_sbif": "0001",
    "status": "pending",
    "update_at": "2022-06-09 21:10:46",
    "origin_wallet": "wa1933f37cdaf7d1c6",
    "reason_rejection": " Error CCA 51. Cuenta Beneficiario no Existe, error_creditor_account_not_found"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `payout` | object |  | Destination account identifier. |
| ↳ `id` | string |  | Destination account identifier. — Example: `war3999847529816f2` |
| ↳ `phone` | string |  | Telephone of the destination account holder. — Example: `111111111` |
| ↳ `email` | string |  | Destination account holder's email. — Example: `test@test.cl` |
| ↳ `subject` | string |  | Application Status. — Example: `subject order` |
| ↳ `amount` | string |  | Amount to be deposited in the destination account. — Example: `3680` |
| ↳ `accountbank_rut` | string |  | Rut of the destination account holder. — Example: `111111111` |
| ↳ `accountbank_name` | string |  | Name of the destination account holder. — Example: `test` |
| ↳ `accountbank_type` | integer |  | Type of account of the destination bank. — Example: `1` |
| ↳ `accountbank_num` | integer |  | Destination bank account number. — Example: `123123123` |
| ↳ `accountbank_sbif` | string |  | Code of the bank to which the bank account belongs. — Example: `0001` |
| ↳ `status` | string |  | Movement status. - pending ("payout registered") - processing ("payout in payment process") - success ("payout successfully deposited") - banking_error ("payout rejected by the bank") - fraud_prevention ("payout rejected by compliance") — Example: `pending` |
| ↳ `update_at` | string |  | Date the request was made. — Example: `2022-06-09 21:10:46` |
| ↳ `origin_wallet` | string |  | Id de la wallet origen. — Example: `wa1933f37cdaf7d1c6` |
| ↳ `reason_rejection` | string |  | Reason for rejection. — Example: `Error CCA 51. Cuenta Beneficiario no Existe, error_creditor_account_not_found` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

*404* — Identifier does not exist.

```json
{
  "status": "failed",
  "type": "Not Found",
  "id": "is not valid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Not Found` |
| `id` | string |  | Id information — Example: `is not valid` |

## Conciliation

Allows to obtain reconciliations in **payku**.

### Get conciliations.

`POST /api/conciliation`

Allows you to obtain bank reconciliations of the money generated by your account and deposited by **payku** in the days corresponding to your payment.

**Request body**

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `date_init` | string | ✓ | **Start date range:** - Cannot be greater than the current date. - It cannot be greater than the end date. - The range of the start date and end date must not be greater than 30 days. — Example: `2022-10-20` |
| `date_end` | string | ✓ | **End date range:** - Cannot be greater than the current date. - Cannot be less than the start date. - The range of the start date and end date must not be greater than 30 days. — Example: `2022-10-21` |

**cURL**

```bash
curl -X POST \
https://BASE-URL/api/conciliation \
-H 'Accept: application/json, text/plain, */*' \
-H 'Authorization: Bearer PUBLIC-TOKEN' \
-H 'Content-Type: application/json' \
-H 'Host: BASE-URL' \
-d '{
    "date_init": "2022-10-20",
    "date_end": "2022-10-21"
  }'
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('POST', 'https://BASE_URL/api/conciliation', [
    'json' => [
        'date_init' => '2022-10-20',
        'date_end' => '2022-10-21'
      ],
    'headers' => [
      'Authorization' => 'Bearer PUBLIC-TOKEN',
    ]
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async (data) => {
  const response = await fetch('https://BASE_URL/api/conciliation', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      'Authorization': 'Bearer PUBLIC-TOKEN'
    },
    body: JSON.stringify(data)
  });
  const result = await response.json();
  console.log(result)
}

let data = {
  "date_init": "2022-10-20",
  "date_end": "2022-10-21"
};

request(data);
```

**Responses**

*200*

```json
{
  "conciliation": [
    {
      "id": "107999",
      "created_at": "2019-10-25 14:10:03",
      "amount_available": 98745,
      "amount_deposit": 0,
      "status": "pending",
      "destiny": "wallet",
      "currency": "CLP",
      "wallet": null,
      "transaction": [
        {
          "transaction_id": "rsyt68j4dhg6k8j54ut698dt6hj84",
          "payment_key": "pra934939d607922f9e",
          "order": "6544",
          "start": "2020-12-16 15:10:33",
          "end": "2020-12-16 15:10:36",
          "deposit_date": "2022-10-05",
          "amount": 250000,
          "fee": 15000,
          "amount_deposit": 235000,
          "media": "Webpay"
        }
      ]
    }
  ]
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `conciliation` | array of objects |  |  |
| ↳ `id` | string |  | Conciliation identifier created by Payku. — Example: `107999` |
| ↳ `created_at` | string |  | Registration date. — Example: `2019-10-25 14:10:03` |
| ↳ `amount_available` | int |  | Amount available. — Example: `98745` |
| ↳ `amount_deposit` | int |  | Amount deposited. — Example: `0` |
| ↳ `status` | string |  | Conciliation status. The possible statuses you can get are as follows: - pending - paid_out - deteined - returned — Example: `pending` |
| ↳ `destiny` | string |  | Destination of the liquidation. — Example: `wallet` |
| ↳ `currency` | string |  | Currency. — Example: `CLP` |
| ↳ `wallet` | string |  | Digital wallet **payku**. |
| ↳ `transaction` | array of objects |  |  |
| ↳ ↳ `transaction_id` | string |  | Transaction identifier created by **Payku**. — Example: `rsyt68j4dhg6k8j54ut698dt6hj84` |
| ↳ ↳ `payment_key` | string |  | Identifier of payment created by **Payku**. — Example: `pra934939d607922f9e` |
| ↳ ↳ `order` | string |  | Order identifier. — Example: `6544` |
| ↳ ↳ `start` | string |  | Start of the transaction. — Example: `2020-12-16 15:10:33` |
| ↳ ↳ `end` | string |  | End of transaction. — Example: `2020-12-16 15:10:36` |
| ↳ ↳ `deposit_date` | string |  | Date on which the deposit will be made to the client. — Example: `2022-10-05` |
| ↳ ↳ `amount` | string |  | Monto de la transacción. — Example: `250000` |
| ↳ ↳ `fee` | string |  | Comisión general. — Example: `15000` |
| ↳ ↳ `amount_deposit` | int |  | Customer deposit amount. — Example: `235000` |
| ↳ ↳ `media` | string |  | payment method, used by the user. — Example: `Webpay` |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": "subject:invalid,amount:is empty,email:is empty,order:invalid"
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message. — Example: `subject:invalid,amount:is empty,email:is empty,order:invalid` |

*401* — Incorrect public token.

```json
{
  "type": "Unauthorized",
  "message_error": {
    "error": "waiting token public"
  }
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `type` | string |  | Request status. — Example: `Unauthorized` |
| `message_error` | object |  |  |
| ↳ `error` | string |  | Error message. — Example: `waiting token public` |

## Banks

Allows you to view the list of partner banks.

### Get list of banks by currency type

`GET /api/banks?currency=clp`

This method provides a list of partner banks filtered by currency.
To filter by currency, you have to add the query params currency with the currency value.

**CURL**

```text
curl -X GET \
https://BASE-URL/api/banks  \
-H 'Accept: application/json, text/plain, */*' \
-H 'Content-Type: application/json' \
-H 'Host: BASE-URL' \
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('GET', 'https://BASE_URL/api/banks?currency=clp', [
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async () => {
  const response = await fetch('https://BASE_URL/api/banks?currency=clp', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json'
    },
  });
  const result = await response.json();
  console.log(result)
}
request();
```

**Responses**

*200*

```json
{
  "status": "success",
  "banks": [
    {
      "code": "0001",
      "name": "Banco de Chile",
      "currency": "CLP"
    },
    {
      "code": "0012",
      "name": "Banco Estado",
      "currency": "CLP"
    }
  ]
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Status of the endpoint. The possible statuses that can be obtained are the following: - success — Example: `success` |
| `banks` | array of objects |  | Example: `[{"code":"0001","name":"Banco de Chile","currency":"CLP"},{"code":"0012","name":"Banco Estado","currency":"CLP"}]` |
| ↳ `code` | string |  | Bank code of the bank to which the bank account belongs. — Example: `Banco de Chile` |
| ↳ `name` | string |  | Name of bank. — Example: `Banco de Chile` |
| ↳ `currency` | string |  | Currency |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": ""
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message — Example: `` |

## Methods of payment

Allows you to view the list of payment methods used by payku.

### Get list of payment methods on payku

`GET /api/paymentmethods`

This method allows you to obtain a list of payment methods on payku.

**CURL**

```text
curl -X GET \
https://BASE-URL/api/paymentmethods  \
-H 'Accept: application/json, text/plain, */*' \
-H 'Content-Type: application/json' \
-H 'Host: BASE-URL' \
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('GET', 'https://BASE_URL/api/paymentmethods', [
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async () => {
  const response = await fetch('https://BASE_URL/api/paymentmethods', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json'
    },
  });
  const result = await response.json();
  console.log(result)
}

request();
```

**Responses**

*200*

```json
{
  "status": "success",
  "payment_methods": [
    {
      "currency": "CLP",
      "payment": 1,
      "name": "Webpay",
      "description": "Visa, Mastercard, Magna, American, Diners y Redcompra."
    }
  ]
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Status of the endpoint. The possible statuses that can be obtained are the following: - success — Example: `success` |
| `payment_methods` | array of objects |  | Example: `[{"currency":"CLP","payment":1,"name":"Webpay","description":"Visa, Mastercard, Magna, American, Diners y Redcompra."}]` |
| ↳ `description` | string |  | Brief description of payment method. — Example: `Use your bank, simplify your transfers.` |
| ↳ `payment` | number |  | Code belonging to the payment method. — Example: `17` |
| ↳ `name` | string |  | Name of payment method. — Example: `Vepuy` |
| ↳ `currency` | string |  | Currency |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": ""
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message — Example: `` |

### Get list of payment methods by currency type

`GET /api/paymentmethods?currency=clp`

This method allows you to get a list of payment methods in payku.
To filter by currency, you have to add the query params currency with the currency value.

**CURL**

```text
curl -X GET \
https://BASE-URL/api/paymentmethods?currency=clp  \
-H 'Accept: application/json, text/plain, */*' \
-H 'Content-Type: application/json' \
-H 'Host: BASE-URL' \
```

**PHP**

```php
$client = new \GuzzleHttp\Client();
  $body = $client->request('GET', 'https://BASE_URL/api/paymentmethods?currency=clp', [
  ])->getBody();
$response = json_decode($body);
```

**JS**

```js
const request = async () => {
  const response = await fetch('https://BASE_URL/api/paymentmethods?currency=clp', {
    method: 'GET',
    headers: {
      'Content-Type': 'application/json'
    },
  });
  const result = await response.json();
  console.log(result)
}
request();
```

**Responses**

*200*

```json
{
  "status": "success",
  "payment_methods": [
    {
      "currency": "CLP",
      "payment": 1,
      "name": "Webpay",
      "description": "Visa, Mastercard, Magna, American, Diners y Redcompra."
    },
    {
      "currency": "CLP",
      "payment": 9,
      "name": "MACH",
      "description": "Paga en comercios online internacionales y nacionales"
    }
  ]
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Status of the endpoint. The possible statuses that can be obtained are the following: - success — Example: `success` |
| `payment_methods` | array of objects |  | Example: `[{"currency":"CLP","payment":1,"name":"Webpay","description":"Visa, Mastercard, Magna, American, Diners y Redcompra."},{"currency":"CLP","payment":9,"name":"MACH","description":"Paga en comercios online internacionales y nacionales"}]` |
| ↳ `code` | string |  | Code of the bank to which the bank account belongs. — Example: `Banco de Chile` |
| ↳ `name` | string |  | Name of bank. — Example: `Banco de Chile` |
| ↳ `currency` | string |  | Currency |

*400* — Request failed.

```json
{
  "status": "failed",
  "type": "Unprocessable Entity",
  "message_error": ""
}
```

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `status` | string |  | Request status. — Example: `failed` |
| `type` | string |  | Type of error. — Example: `Unprocessable Entity` |
| `message_error` | string |  | Error message — Example: `` |
