### Get List of Banks (Node.js) Source: https://docs.zeleri.com/#introduccion Use this snippet to fetch a list of available banks from the Zeleri API. Ensure you have the 'node-fetch-json' library installed. ```javascript const fetch = require('node-fetch-json'); fetch('https://api.zeleri.com/banks', { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Public-Key': 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' } }).then(function(response) { console.log(response); }); ``` -------------------------------- ### Ordering by Creation Date (Ascending) Source: https://docs.zeleri.com/#introduccion This example demonstrates how to order the list of customers by their creation date in ascending order. ```APIDOC ## GET /customers?order_field=created_at&order=asc ### Description Orders the list of customers by the `created_at` field in ascending order. ### Method GET ### Endpoint `https://api.zeleri.com/customers` ### Query Parameters - **order_field** (string) - Required - The field to order by. Use `created_at` for creation date. - **order** (string) - Required - The order of the results. Use `asc` for ascending. ### Request Example ```javascript const fetch = require('node-fetch-json'); fetch('https://api.zeleri.com/customers?order_field=created_at&order=asc', { method: 'GET', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Public-Key': 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' }, }).then(function(response) { console.log(response); }); ``` ``` -------------------------------- ### Filtering by Name Source: https://docs.zeleri.com/#introduccion This example shows how to filter the customers list to find resources that contain a specific name. ```APIDOC ## GET /customers?name={name} ### Description Filters the list of customers to return only those whose name matches the provided value. ### Method GET ### Endpoint `https://api.zeleri.com/customers` ### Query Parameters - **name** (string) - Required - The name to filter by. Supports partial matches. ### Request Example ```javascript const fetch = require('node-fetch-json'); fetch('https://api.zeleri.com/customers?name=sheldon', { method: 'GET', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Public-Key': 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' }, }).then(function(response) { console.log(response); }); ``` ``` -------------------------------- ### API Error Response Example Source: https://docs.zeleri.com/ Example of an error response from the Zeleri API, indicating a missing required parameter. ```json { "error": { "message": "amount parameter required" } } ``` -------------------------------- ### Idempotency Key Header Source: https://docs.zeleri.com/ Example of the 'Idempotency-Key' header for ensuring safe request retries. ```text Idempotency-Key: zk_pudsb_F1yBmB8f5UCI1e1Z-I7rp ``` -------------------------------- ### Public API Key Authentication Header Source: https://docs.zeleri.com/ Example of the required 'Public-Key' header for API authentication. ```text Public-Key: zk_pub_F1yBmB8f5UCI1e1Z-I7rp ``` -------------------------------- ### Zeleri Transaction Response Example Source: https://docs.zeleri.com/ This is an example of a successful transaction response from the Zeleri API. It includes transaction details such as ID, amount, status, and gateway information. ```json { "id": "trx_2Ef05fTvFKihmqH6MH5dk", "amount": 15000, "buy_order": "cus_6pHJAX1582648391", "status": "pending", "description": null, "attempted_at": null, "approved_at": null, "refunded_at": null, "declined_at": null, "response_message": "pending", "idempotency_key": "eiCrzNrKhgqJymiX6Hb", "gateway": { "id": "gtw_EmzNS_i1JpkBviDqlqY4u", "name": "WebPay OneClick", "logo": "https://zeleri.s3-us-west-2.amazonaws.com/gateways/logos/oneclick.png", "icon": "https://zeleri.s3-us-west-2.amazonaws.com/gateways/icon/oneclick.png", "description": "Tarjetas de Crédito" } } ``` -------------------------------- ### Fetch List of Banks (PHP) Source: https://docs.zeleri.com/ This PHP example demonstrates how to fetch a list of banks using the Guzzle HTTP client. Make sure to include the 'guzzle.phar' file. ```php request('GET', 'https://api.zeleri.com/banks', [ 'headers' => [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'Public-Key' => 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' ] ])->getBody(); $response = json_decode($body); var_dump($response); ?> ``` -------------------------------- ### Fetching Resources with Pagination, Filtering, and Ordering Source: https://docs.zeleri.com/#introduccion This example demonstrates how to fetch a list of customers, applying pagination to retrieve the second page with 10 items per page, ordering by name in descending order, and filtering by a specific name. ```APIDOC ## GET /customers ### Description Retrieves a list of customers with options for pagination, filtering, and ordering. ### Method GET ### Endpoint `https://api.zeleri.com/customers` ### Query Parameters - **page** (integer) - Optional - The page number to retrieve. - **limit** (integer) - Optional - The number of items per page. - **order_field** (string) - Optional - The field to order the results by. - **order** (string) - Optional - The order of the results (ASC or DESC). - **[filter_field]** (string) - Optional - Filters results based on the provided field. Supports partial matches. ### Request Example ```javascript const fetch = require('node-fetch-json'); fetch('https://api.zeleri.com/customers?page=1&limit=10&order_field=name&order=DESC&name=sheldon', { method: 'GET', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Public-Key': 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' }, }).then(function(response) { console.log(response); }); ``` ### Response #### Success Response (200) Returns a list of customer objects, including a pagination object. - **pagination** (object) - Contains pagination details: `total`, `perPage`, `page`, `lastPage`. - **[customer_object]** (object) - Represents a customer. #### Response Example ```json { "pagination": { "total": 100, "perPage": 10, "page": 1, "lastPage": 10 }, "data": [ { "id": "cust_123", "name": "John Doe", "email": "john.doe@example.com" } ] } ``` ``` -------------------------------- ### List Customers (PHP) Source: https://docs.zeleri.com/ This PHP example uses Guzzle to fetch a list of customers from the Zeleri API. The response includes pagination details and an array of customer objects. ```php request('GET', 'https://api.zeleri.com/customers', [ 'headers' => [ 'Accept'=> 'application/json', 'Content-Type'=> 'application/json', 'Public-Key'=> 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' ] ])->getBody(); $response = json_decode($body); var_dump($response); ?> ``` -------------------------------- ### Fetching Customers with Pagination, Filtering, and Ordering Source: https://docs.zeleri.com/ This example demonstrates how to fetch customer data with specific pagination, filtering, and ordering parameters. You can adjust the `page`, `limit`, `order_field`, and `order` parameters to customize your results. ```APIDOC ## GET /customers ### Description Retrieves a list of customers with support for pagination, filtering, and ordering. ### Method GET ### Endpoint `/customers` ### Query Parameters - **page** (integer) - Optional - The page number to retrieve. - **limit** (integer) - Optional - The number of entries per page. - **order_field** (string) - Optional - The field to order the results by. - **order** (string) - Optional - The order of the results (`ASC` or `DESC`). - **name** (string) - Optional - Filters customers by name (supports partial matching). ### Request Example (Node.js) ```javascript const fetch = require('node-fetch-json'); fetch('https://api.zeleri.com/customers?page=1&limit=10&order_field=name&order=DESC', { method: 'GET', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Public-Key': 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' }, }).then(function(response) { console.log(response); }); ``` ### Request Example (PHP) ```php request('GET', 'https://api.zeleri.com/customers?page=1&limit=10&order_field=name&order=DESC', [ 'headers' => [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'Public-Key' => 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' ] ])->getBody(); $response = json_decode($body); var_dump($response); ?> ``` ### Response #### Success Response (200) - **pagination** (object) - Contains pagination details: `total`, `perPage`, `page`, `lastPage`. - **data** (array) - An array of customer objects. ### Filtering Example (Node.js) ```javascript const fetch = require('node-fetch-json'); fetch('https://api.zeleri.com/customers?name=sheldon', { method: 'GET', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Public-Key': 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' }, }).then(function(response) { console.log(response); }); ``` ### Filtering Example (PHP) ```php request('GET', 'https://api.zeleri.com/customers?name=sheldon', [ 'headers' => [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'Public-Key' => 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' ] ])->getBody(); $response = json_decode($body); var_dump($response); ?> ``` ### Ordering Example (Node.js) ```javascript const fetch = require('node-fetch-json'); fetch('https://api.zeleri.com/customers?order_field=created_at&order=asc', { method: 'GET', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Public-Key': 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' }, }).then(function(response) { console.log(response); }); ``` ### Ordering Example (PHP) ```php request('GET', 'https://api.zeleri.com/customers?order_field=created_at&order=asc', [ 'headers' => [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'Public-Key' => 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' ] ])->getBody(); $response = json_decode($body); var_dump($response); ?> ``` ``` -------------------------------- ### Get Payment Gateways Source: https://docs.zeleri.com/ Retrieves a list of all enabled payment methods in Zeleri. ```APIDOC ## GET /gateways ### Description Retorna una lista de medios de pagos habilitados en zeleri. ### Method GET ### Endpoint /gateways ### Response #### Success Response (200) - **gateways** (array) - An array where each entry represents a payment method with its respective information. ### Response Example ```json [ { "id": "gtw_EmzNS_i1JspkBviDqlqY4u", "name": "WebPay OneClick", "logo": "https://zeleri.s3-us-west-2.amazonaws.com/gateways/logos/oneclick.png", "icon": "https://zeleri.s3-us-west-2.amazonaws.com/gateways/icon/oneclick.png", "description": "Tarjetas de Crédito" }, { "id": "gtw_SWveaCnb7wSMe-UqwJYmZQ", "name": "Banco de Chile", "logo": "https://zeleri.s3-us-west-2.amazonaws.com/gateways/logos/001.png", "icon": "https://zeleri.s3-us-west-2.amazonaws.com/gateways/icon/001.png", "description": "Cuenta Vista y Corriente" } ] ``` ``` -------------------------------- ### Order Customers by Creation Date Ascending (JavaScript) Source: https://docs.zeleri.com/ This JavaScript snippet demonstrates how to order customers by their creation date in ascending order. Ensure 'node-fetch-json' is installed. ```javascript const fetch = require('node-fetch-json'); fetch('https://api.zeleri.com/customers?order_field=created_at&order=asc', { method: 'GET', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Public-Key': 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' }, }).then(function(response) { console.log(response); }); ``` -------------------------------- ### Get Enabled Payment Gateways (Node.js) Source: https://docs.zeleri.com/ Fetches a list of payment gateways enabled for your integration. Requires a 'Public-Key' in the headers. ```javascript const fetch = require('node-fetch-json'); fetch('https://api.zeleri.com/gateways/enabled', { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Public-Key': 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' } }).then(function(response) { console.log(response); }); ``` -------------------------------- ### Encryption Utility Methods (Node.js) Source: https://docs.zeleri.com/ Example utility methods in Node.js for encrypting and decrypting data using AES-256 CBC. ```javascript const Crypto = require('crypto'); const utils = { encrypt: (prop, payload) => { var cipher = Crypto.createCipheriv('aes-256-cbc', prop.private_key, prop.private_key.slice(0, 16)); var crypted = cipher.update(payload, 'utf-8', 'base64'); crypted += cipher.final('base64'); return crypted; }, decrypt: (prop, payload) => { var decipher = Crypto.createDecipheriv('aes-256-cbc', prop.private_key, prop.private_key.slice(0, 16)); var decrypted = decipher.update(payload, 'base64', 'utf-8'); decrypted += decipher.final('utf-8'); return decrypted; } }; ``` -------------------------------- ### Order Customers by Creation Date Ascending (PHP) Source: https://docs.zeleri.com/ This PHP example shows how to sort customers by creation date in ascending order using the Guzzle HTTP client. Ensure 'guzzle.phar' is available. ```php request('GET', 'https://api.zeleri.com/customers?order_field=created_at&order=asc', [ 'headers' => [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'Public-Key' => 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' ] ])->getBody(); $response = json_decode($body); var_dump($response); ?> ``` -------------------------------- ### Get Payment Gateways List (Node.js) Source: https://docs.zeleri.com/ Retrieves a list of all enabled payment gateways. Requires a 'Public-Key' in the headers. ```javascript const fetch = require('node-fetch-json'); fetch('https://api.zeleri.com/gateways', { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Public-Key': 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' } }).then(function(response) { console.log(response); }); ``` -------------------------------- ### Get Transactions List (Node.js) Source: https://docs.zeleri.com/ Fetches a list of transactions from the Zeleri API. Requires a 'Public-Key' in the headers. ```javascript const fetch = require('node-fetch-json'); fetch('https://api.zeleri.com/transactions', { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Public-Key': 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' } }).then(function(response) { console.log(response); }); ``` -------------------------------- ### Get a Customer (PHP) Source: https://docs.zeleri.com/ This PHP snippet shows how to fetch a customer's details by their ID using Guzzle. Ensure the 'guzzle.phar' is included and provide the correct 'Public-Key' for authorization. ```php request('GET', 'https://api.zeleri.com/customers/cus_GM7HnvbEiueHIE8z2tkJM', [ 'headers' => [ 'Accept'=> 'application/json', 'Content-Type'=> 'application/json', 'Public-Key'=> 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' ] ])->getBody(); $response = json_decode($body); var_dump($response); ?> ``` -------------------------------- ### Filter Customers by Name (PHP) Source: https://docs.zeleri.com/ This PHP example shows how to filter customers by name using the Guzzle HTTP client. The filtering is based on a '%like%' pattern for partial matches. ```php request('GET', 'https://api.zeleri.com/customers?name=sheldon', [ 'headers' => [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'Public-Key' => 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' ] ])->getBody(); $response = json_decode($body); var_dump($response); ?> ``` -------------------------------- ### Update Customer Information (PHP) Source: https://docs.zeleri.com/ This PHP example demonstrates how to update customer data using the Guzzle HTTP client. It sends a PUT request with the updated information and necessary headers. ```php request('PUT', 'https://api.zeleri.com/customers/cus_GM7HnvbEiueHIE8z2tkJM', [ 'json' => [ 'email' => 'sheldoncooper@bazinga.com', 'name' => 'sheldon cooper' ], 'headers' => [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'Public-Key' => 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' ] ])->getBody(); $response = json_decode($body); var_dump($response); ?> ``` -------------------------------- ### Fetch List of Banks (Node.js) Source: https://docs.zeleri.com/ Use this snippet to retrieve a list of available banks from the Zeleri API. Ensure you have the 'node-fetch-json' package installed. ```javascript const fetch = require('node-fetch-json'); fetch('https://api.zeleri.com/banks', { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Public-Key': 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' } }).then(function(response) { console.log(response); }); ``` -------------------------------- ### Get Payment Gateways List Source: https://docs.zeleri.com/#introduccion Retrieves a list of all payment gateways enabled in Zeleri. Requires 'Public-Key' header. ```javascript const fetch = require('node-fetch-json'); fetch('https://api.zeleri.com/gateways', { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Public-Key': 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' } }).then(function(response) { console.log(response); }); ``` ```php request('GET', 'https://api.zeleri.com/gateways', [ 'headers' => [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'Public-Key' => 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' ] ])->getBody(); $response = json_decode($body); var_dump($response); ?> ``` -------------------------------- ### Get Enabled Payment Gateways (PHP) Source: https://docs.zeleri.com/ Fetches a list of payment gateways enabled for your integration using Guzzle. Requires a 'Public-Key' in the headers. ```php require 'guzzle.phar'; $client = new GuzzleHttp\Client(); $body = $client->request('GET', 'https://api.zeleri.com/gateways/enabled', [ 'headers' => [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'Public-Key' => 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' ] ])->getBody(); $response = json_decode($body); var_dump($response); ?> ``` -------------------------------- ### Get Customer Transactions (JavaScript) Source: https://docs.zeleri.com/ Fetches a list of transactions for a specific customer using the Zeleri API. Requires a 'Public-Key' in the headers. ```javascript fetch('https://api.zeleri.com/customers/cus_N9X5ZbIiFfPU7OukkZtBl/transactions', { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Public-Key': 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' } }).then(function(response) { console.log(response); }); ``` -------------------------------- ### Fetch Customers with Pagination, Filtering, and Sorting (JavaScript) Source: https://docs.zeleri.com/#introduccion Use this snippet to fetch customer data with specified pagination, filtering, and sorting parameters. Ensure you have the 'node-fetch-json' library installed. ```javascript const fetch = require('node-fetch-json'); fetch('https://api.zeleri.com/customers?page=1&limit=10&order_field=name&order=DESC', { method: 'GET', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Public-Key': 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' }, }).then(function(response) { console.log(response); }); ``` -------------------------------- ### Get List of Banks (PHP) Source: https://docs.zeleri.com/#introduccion This PHP snippet demonstrates how to retrieve a list of banks using the Guzzle HTTP client. Make sure to include the 'guzzle.phar' file. ```php request('GET', 'https://api.zeleri.com/banks', [ 'headers' => [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'Public-Key' => 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' ] ])->getBody(); $response = json_decode($body); var_dump($response); ?> ``` -------------------------------- ### Get Customer Transactions (JavaScript) Source: https://docs.zeleri.com/#introduccion Fetches a list of transactions for a specific customer using the Zeleri API. Requires a public key for authentication. ```javascript fetch('https://api.zeleri.com/customers/cus_N9X5ZbIiFfPU7OukkZtBl/transactions', { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Public-Key': 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' } }).then(function(response) { console.log(response); }); ``` -------------------------------- ### Get Payment Gateways List (PHP) Source: https://docs.zeleri.com/ Retrieves a list of all enabled payment gateways using Guzzle. Requires a 'Public-Key' in the headers. ```php require 'guzzle.phar'; $client = new GuzzleHttp\\;Client(); $body = $client->request('GET', 'https://api.zeleri.com/gateways', [ 'headers' => [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'Public-Key' => 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' ] ])->getBody(); $response = json_decode($body); var_dump($response); ?> ``` -------------------------------- ### Get Enabled Payment Gateways Source: https://docs.zeleri.com/#introduccion Retrieves a list of payment gateways enabled for your specific integration. Requires 'Public-Key' header. ```javascript const fetch = require('node-fetch-json'); fetch('https://api.zeleri.com/gateways/enabled', { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Public-Key': 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' } }).then(function(response) { console.log(response); }); ``` ```php request('GET', 'https://api.zeleri.com/gateways/enabled', [ 'headers' => [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'Public-Key' => 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' ] ])->getBody(); $response = json_decode($body); var_dump($response); ?> ``` -------------------------------- ### Fetch Customers with Pagination and Sorting (JavaScript) Source: https://docs.zeleri.com/ Use this snippet to fetch a paginated list of customers, sorted by a specified field in descending order. Ensure you have the 'node-fetch-json' library installed. ```javascript const fetch = require('node-fetch-json'); fetch('https://api.zeleri.com/customers?page=1&limit=10&order_field=name&order=DESC', { method: 'GET', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Public-Key': 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' }, }).then(function(response) { console.log(response); }); ``` -------------------------------- ### Delete Customer (PHP) Source: https://docs.zeleri.com/ This PHP example shows how to delete a customer using the Guzzle HTTP client. It sends a DELETE request to the specified customer endpoint. ```php request('DELETE', 'https://api.zeleri.com/customers/cus_GM7HnvbEiueHIE8z2tkJM', [ 'headers' => [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'Public-Key' => 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' ] ])->getBody(); $response = json_decode($body); var_dump($response); ?> ``` -------------------------------- ### Get Customer Transactions Source: https://docs.zeleri.com/ Retrieves a list of transactions for a specific customer. ```APIDOC ## GET /customers/:id/transactions ### Description Retorna una lista de transacciones de un cliente especifico. ### Method GET ### Endpoint /customers/:id/transactions ### Response #### Success Response (200) - **pagination** (object) - Pagination details for the response. - **data** (array) - An array of transaction objects. ### Response Example ```json { "pagination": { "total": 1, "perPage": 20, "page": 1, "lastPage": 1 }, "data": [ { "refunds": [], "id": "trx_2ghjT8uEzTlhJ-aqTuTPB", "amount": 799990, "buy_order": "cus_N9X5Zb1592861047", "status": "approved", "description": "Mac Mini", "attempted_at": null, "approved_at": "2020-06-23 01:24:08 +00:00", "refunded_at": null, "declined_at": null, "canceled_at": null, "response_message": "aprobado", "idempotency_key": null } ] } ``` ``` -------------------------------- ### Create a Customer (PHP) Source: https://docs.zeleri.com/ This PHP snippet demonstrates how to create a customer using the Guzzle HTTP client. It requires the 'guzzle.phar' file and includes necessary headers for authentication and content type. ```php request('POST', 'https://api.zeleri.com/customers', [ 'json' => [ 'email' => 'sheldoncooper@bazinga.com', 'name' => 'sheldon cooper', 'phone' => '+56988888888', 'unique_id' => "4e93a42c-5c96-11ea-bc55-0242ac130003" ], 'headers' => [ 'Accept'=> 'application/json', 'Content-Type'=> 'application/json', 'Public-Key'=> 'zk_pub_F1yBmB8325UCI1e1Z-I7rp', 'Idempotency-Key'=> '4e93a42c-5c96-11ea-bc55-0242ac130003' ] ])->getBody(); $response = json_decode($body); var_dump($response); ?> ``` -------------------------------- ### Get a list of banks Source: https://docs.zeleri.com/#introduccion Retrieves a list of available banks with their details. ```APIDOC ## GET /banks ### Description Retorna una lista de bancos. ### Method GET ### Endpoint /banks ### Response #### Success Response (200) - **id** (string) - Unique identifier for the bank. - **name** (string) - The name of the bank. - **logo** (string) - URL to the bank's logo. - **brand_color_start** (string) - Starting brand color. - **brand_color_end** (string) - Ending brand color. - **logo_color** (string) - URL to the bank's color logo. - **website** (string) - The bank's website URL. - **keywords** (string) - Keywords associated with the bank. - **country_code** (string) - The country code where the bank operates. ### Request Example ```javascript const fetch = require('node-fetch-json'); fetch('https://api.zeleri.com/banks', { headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Public-Key': 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' } }).then(function(response) { console.log(response); }); ``` ### Response Example ```json [ { "id": "bnk_fdjvne3qed1KfSz-iPU-8o", "name": "Banco Santander", "logo": "https://zeleri.s3-us-west-2.amazonaws.com/banks/white_logos/037.png", "brand_color_start": "#D82E1F", "brand_color_end": "#C70000", "logo_color": "https://zeleri.s3-us-west-2.amazonaws.com/banks/color_logos/037.png", "website": "santander.cl", "keywords": "santander.cl", "country_code": "cl" }, { "id": "bnk_UMcmK03QKOj-PM81h9KM8s", "name": "Banco Bci", "logo": "https://zeleri.s3-us-west-2.amazonaws.com/banks/white_logos/016.png", "brand_color_start": "#5A595A", "brand_color_end": "#C6C6C6", "logo_color": "https://zeleri.s3-us-west-2.amazonaws.com/banks/color_logos/016.png", "website": "bci.cl", "keywords": "bci.cl", "country_code": "cl" } ] ``` ``` -------------------------------- ### Get Transactions Source: https://docs.zeleri.com/ Retrieves a list of transactions, ordered by creation date by default. ```APIDOC ## GET /transactions ### Description Obtiene el listado de transacciones ordenadas por fecha de creación por defecto. ### Method GET ### Endpoint /transactions ### Response #### Success Response (200) - **transactions** (array) - An array of transaction objects. ### Response Example ```json [ { "id": "trx_2Ef05fTvFKihmqH6MH5dk", "amount": 15000, "buy_order": "cus_6pHJAX1582648391", "status": "pending", "description": null, "attempted_at": null, "approved_at": null, "refunded_at": null, "declined_at": null, "response_message": "pending", "idempotency_key": "eiCrzNrKhgqJymiX6Hb", "gateway": { "id": "gtw_EmzNS_i1JpkBviDqlqY4u", "name": "WebPay OneClick", "logo": "https://zeleri.s3-us-west-2.amazonaws.com/gateways/logos/oneclick.png", "icon": "https://zeleri.s3-us-west-2.amazonaws.com/gateways/icon/oneclick.png", "description": "Tarjetas de Crédito" } } ] ``` ``` -------------------------------- ### Get Transaction Source: https://docs.zeleri.com/ Retrieves the details of an existing transaction using its unique identifier. ```APIDOC ## GET /transactions/{transaction_id} ### Description Obtiene los detalles de una transacción existente. ### Method GET ### Endpoint /transactions/{transaction_id} ### Parameters #### Path Parameters - **transaction_id** (string) - Required - Identificador único de la transacción. ### Response #### Success Response (200) - **transaction** (object) - Retorna un objeto de transacción si se provee de un identificador válido. De lo contrario, retornará un error. ``` -------------------------------- ### Create a Customer (Node.js) Source: https://docs.zeleri.com/ Use this snippet to create a new customer object. Ensure you include a unique 'Idempotency-Key' for request idempotency. The 'Public-Key' is required for authentication. ```javascript const fetch = require('node-fetch-json'); fetch('https://api.zeleri.com/customers', { method: 'POST', headers: { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Public-Key': 'zk_pub_F1yBmB8325UCI1e1Z-I7rp', 'Idempotency-Key': '4e93a42c-5c96-11ea-bc55-0242ac130003' }, body: { email: "sheldoncooper@bazinga.com", name: "sheldon cooper", phone: "+56988888888", unique_id: "4e93a42c-5c96-11ea-bc55-0242ac130003" } }).then(function(response) { console.log(response); }); ``` -------------------------------- ### Encrypted Payload Example Source: https://docs.zeleri.com/ Structure of the 'Payload' object for encrypted data transmission. ```json { "payload":"ZrVP7N3cYSFgHHWwmAsn5dpm5+KDcB2EQuNW+h9pZ+SRQ/Jw9bdjXoZAKQ8hXMzpjIXEmRzKdtO8+yiqh8Ya2tVur9eGLHbgYy2qxncKZFdIHdsEdJwuR10mdBd4eHBZDV2qpWdRVk5Wcuv08Mos7XZMF8WoykuAO6Zc1K9RE9g=" } ``` -------------------------------- ### Encriptación de Datos Source: https://docs.zeleri.com/#introduccion La API de Zeleri procesa algunos de sus endpoints más sensibles con encriptación de datos usando el algoritmo AES-256 en modo CBC. Se requiere una llave privada y un IV para generar el hash del payload. ```APIDOC # Encriptacion La API de Zeleri procesa algunos de sus endpoint mas sencibles con encriptación de la data enviada, para esta encriptación Zeleri usa el algoritmo AES-256 con el modo CBC que junto a la llave privada y el IV del cliente genera un hash que es enviado en el request como payload. > El payload `Payload` debe verse así: ``` { "payload":"ZrVP7N3cYSFgHHWwmAsn5dpm5+KDcB2EQuNW+h9pZ+SRQ/Jw9bdjXoZAKQ8hXMzpjIXEmRzKdtO8+yiqh8Ya2tVur9eGLHbgYy2qxncKZFdIHdsEdJwuR10mdBd4eHBZDV2qpWdRVk5Wcuv08Mos7XZMF8WoykuAO6Zc1K9RE9g=" } ``` ### Formato de encriptación Zeleri en su SDK proporciona los metodos para encriptar y desencriptar, estos metodos usan la llave privada seteada en su enviroment, en caso de no usar el sdk es necesario crear su propio metodo en encriptación con el algoritmo AES-256 con el modo CBC que junto a la llave privada y el IV sera los primeros 16 caracteres de la llave privada > Metodo en el SDK: ``` 'use strict'; const Crypto = require('crypto'); const utils = (module.exports = { encrypt: (prop,payload) => { var cipher = Crypto.createCipheriv('aes-256-cbc', prop.private_key, prop.private_key.slice(0, 16)) var crypted = cipher.update(payload, 'utf-8', 'base64'); crypted += cipher.final('base64'); return crypted }, decrypt: (prop,payload) => { var decipher = Crypto.createDecipheriv('aes-256-cbc', prop.private_key, prop.private_key.slice(0, 16)) var decrypted = decipher.update(payload, 'base64', 'utf-8'); decrypted += decipher.final('utf-8'); return decrypted } }); ``` ``` -------------------------------- ### Get Payment Method Source: https://docs.zeleri.com/ Retrieves the details of an existing payment method using its unique identifier. ```APIDOC ## GET /payment_methods/{payment_method_id} ### Description Obtiene los detalles de un metodo de pago existente. Se necesita proporcionar sólo el identificador único del metodo de pago. ### Method GET ### Endpoint /payment_methods/{payment_method_id} ### Parameters #### Path Parameters - **payment_method_id** (string) - Required - Identificador único del metodo de pago. ### Response #### Success Response (200) Retorna un objeto de metodo de pago si se provee de un identificador válido. ### Response Example ```json { "id": "pym_wGzj5u2KyLk9JE7d_F3tR", "card_last4": "6623", "card_type": "credit", "card_brand": "Visa", "card_exp_date": null, "one_time": false, "status": "success", "bank": { "id": "bnk_awvfmgo7KqLs5zrv673MD", "name": "Banco Security", "logo": "https://zeleri.s3-us-west-2.amazonaws.com/banks/white_logos/049.png", "brand_color_start": "#1E1B75", "brand_color_end": "#5E007E", "logo_color": "https://zeleri.s3-us-west-2.amazonaws.com/banks/color_logos/049.png", "website": "bancosecurity.cl", "keywords": "bancosecurity.cl", "country_code": "cl" }, "gateway": { "id": "gtw_EmzNS_i1JpkBviDqlqY4u", "name": "WebPay OneClick", "logo": "https://zeleri.s3-us-west-2.amazonaws.com/gateways/logos/oneclick.png", "icon": "https://zeleri.s3-us-west-2.amazonaws.com/gateways/icon/oneclick.png", "description": "Tarjetas de Crédito" }, "customer": { "id": "cus_6pHJAXNR90MPbpokn8LdJ", "name": "sheldon cooper" } } ``` ``` -------------------------------- ### Fetch Customers with Pagination, Filtering, and Sorting (PHP) Source: https://docs.zeleri.com/#introduccion This PHP snippet demonstrates fetching customer data using the Guzzle HTTP client. It includes parameters for pagination, filtering, and sorting. Ensure 'guzzle.phar' is available. ```php request('GET', 'https://api.zeleri.com/customers?page=1&limit=10&order_field=name&order=DESC', [ 'headers' => [ 'Accept' => 'application/json', 'Content-Type' => 'application/json', 'Public-Key' => 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' ] ])->getBody(); $response = json_decode($body); var_dump($response); ?> ``` -------------------------------- ### List Customers with PHP Source: https://docs.zeleri.com/#introduccion This PHP snippet demonstrates how to fetch a list of customers using the Guzzle HTTP client. Ensure 'guzzle.phar' is included. The response includes pagination details and customer data. ```php request('GET', 'https://api.zeleri.com/customers', [ 'headers' => [ 'Accept'=> 'application/json', 'Content-Type'=> 'application/json', 'Public-Key'=> 'zk_pub_F1yBmB8325UCI1e1Z-I7rp' ] ])->getBody(); $response = json_decode($body); var_dump($response); ?> ``` -------------------------------- ### Obtener una lista de clientes Source: https://docs.zeleri.com/ Retrieves a list of customers. Customers are sorted by creation date by default, with the most recent appearing first. ```APIDOC ## GET /customers ### Description Retrieves a list of customers. Customers are sorted by default by creation date, with the most recent appearing first. ### Method GET ### Endpoint `/customers` ### Response #### Success Response (200) An array where each entry represents a customer with their respective information. #### Response Example ```json { "pagination": { "total": 10, "perPage": 20, "page": 1, "lastPage": 1 }, "data":[ { "id": "cus_GM7HnvbEiueHIE8z2tkJM", "unique_id": "sheldoncooper@bazinga.com", "name": "sheldon cooper", "email": "sheldoncooper@bazinga.com", "phone": "+56988888888", "payment_methods": [], "total_transactions": 0 }, { "id": "cus_GM7HnvbEiueHIE8z2tkJM", "unique_id": "sheldoncooper@bazinga.com", "name": "sheldon cooper", "email": "sheldoncooper@bazinga.com", "phone": "+56988888888", "payment_methods": [], "total_transactions": 0 } ] } ``` ```