### Install Node SDK Source: https://docs.fintoc.com/docs/setup Command to install the Fintoc Node.js SDK. ```bash npm install fintoc ``` -------------------------------- ### Install Python SDK Source: https://docs.fintoc.com/docs/setup Command to install the Fintoc Python SDK. ```bash pip install fintoc ``` -------------------------------- ### Account Response Example Source: https://docs.fintoc.com/docs/setup Example JSON response when listing accounts. ```json [ { "id": "acc_23JlasHas241", "object": "account", "mode": "test", "description": "My root account", "root_account_number": "738969123456789120", "root_account_number_id": "acno_Kasf91034gj1AD", "available_balance": 0, "currency": "MXN", "entity": { "id": "ent_4324qwkalsds", "holder_name": "ACME Inc.", "holder_id": "ND" } } ] ``` -------------------------------- ### Create a Setup Session Source: https://docs.fintoc.com/docs/save-a-paymentmethod-of-a-customer-for-future-payments Example of creating a Checkout Session with the 'setup' flow using cURL. ```bash curl --request POST "https://api.fintoc.com/v2/checkout_sessions" \ --header "Authorization: YOUR_SECRET_API_KEY" \ --header "Content-Type: application/json" \ --data-raw '{ "flow": "setup", "currency": "CLP", "success_url": "https://merchant.com/success", "cancel_url": "https://merchant.com/cancel", "customer_data": { "email": "customer@mail.com" }, "metadata": {} }' ``` -------------------------------- ### List Accounts using cURL Source: https://docs.fintoc.com/docs/setup Example cURL command to fetch the organization's root account. ```shell curl --request GET \ --url https://api.fintoc.com/v2/accounts \ --header 'Authorization: sk_test_9c8d8CeyBTx1VcJzuDgpm4H' \ --header 'accept: application/json' \ --header 'content-type: application/json' \ ``` -------------------------------- ### Install Node.js SDK with npm Source: https://docs.fintoc.com/docs/guides-bank-movements Install the Fintoc Node.js SDK using npm. ```shell # Using npm npm install fintoc ``` -------------------------------- ### Install Node.js SDK with yarn Source: https://docs.fintoc.com/docs/guides-bank-movements Install the Fintoc Node.js SDK using yarn. ```shell # Using yarn yarn add fintoc ``` -------------------------------- ### Widget Configuration Example Source: https://docs.fintoc.com/docs/webview Example of how to configure the widget by passing query parameters to the WebView URL. This example includes parameters for public_key, holder_type, product, country, and widget_token. ```text https://webview.fintoc.com/widget.html ?public_key=pk_live_00000 &holder_type=individual &product=payments &country=cl &widget_token=pi_XXXXXX_sec_YYYYYYYY ``` -------------------------------- ### Composer Installation and Magento Setup Source: https://docs.fintoc.com/docs/magento Commands to install the Fintoc payment module for Magento, enable it, upgrade the setup, and clear the cache. ```bash composer require fintoc/module-payment bin/magento module:enable Fintoc_Payment bin/magento setup:upgrade bin/magento cache:flush ``` -------------------------------- ### Send First Transfer using cURL Source: https://docs.fintoc.com/docs/setup Example cURL command to send your first transfer. ```shell curl --request POST \ --url https://api.fintoc.com/v2/transfers \ --header 'Authorization: YOUR_API_KEY' \ --header 'Fintoc-JWS-Signature: YOUR_JWS_SIGNATURE' \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --data \ '{ "amount": 59013, "currency": "mxn", "account_id": "acc_M8sKf230BgHjD4", "comment": "Pago de credito 10451", "reference_id": "150195", "counterparty": { "account_number": "012969123456789120" }, } ' ``` -------------------------------- ### Checkout Session Response Source: https://docs.fintoc.com/docs/setup-a-payment-method-for-future-charges This is an example of the response received after creating a Checkout Session for setup, including the redirect URL. ```json { "id": "cs_li5531onlFDi235", "object": "checkout_session", "flow": "setup", "status": "created", "currency": "CLP", "customer": { "name": "Felipe Castro", "email": "customer@mail.com", "tax_id": { "type": "cl_rut", "value": "12088191" } }, "success_url": "https://merchant.com/success", "cancel_url": "https://merchant.com/cancel", "redirect_url": "https://pay.fintoc.com/checkout/cs_li5531onlFDi235", "metadata": {} } ``` -------------------------------- ### Checkout Session Response Example Source: https://docs.fintoc.com/docs/quickstart-payments Example JSON response after creating a Checkout Session. ```json { "id": "cs_li5531onlFDi235", "object": "checkout_session", "mode": "test", "status": "created", "amount": 350000, "currency": "CLP", "created_at": "2024-06-04T15:32:46.721Z", "updated_at": "2024-06-04T15:32:46.721Z", "success_url": "https://merchant.com/success", "cancel_url": "https://merchant.com/987654321", "redirect_url": "https://checkout.fintoc.com/checkout_session_01HXY3Z7X5YQ54V8G2E1KJQAVF", "metadata": {}, "customer": {} } ``` -------------------------------- ### Verify CLI setup Source: https://docs.fintoc.com/docs/install-the-fintoc-cli Runs the doctor command to verify the Fintoc CLI setup, checking authentication and connectivity. ```bash fintoc doctor ``` -------------------------------- ### Create Checkout Session (Node.js) Source: https://docs.fintoc.com/docs/quickstart-payments Example using Node.js SDK to create a Checkout Session. ```javascript const { Fintoc } = require('fintoc'); const fintoc = new Fintoc('YOUR_TEST_SECRET_API_KEY'); const checkoutSession = await fintoc.checkoutSessions.create({ amount: 1000, currency: 'mxn', customer_email: 'name@example.com' }); ``` -------------------------------- ### Simulate Receive Transfer using cURL Source: https://docs.fintoc.com/docs/setup Example cURL command to simulate an inbound transfer to fund a test account. ```shell curl --request POST \ --url https://api.fintoc.com/v2/simulate/receive_transfer \ --header 'Authorization: sk_test_9c8d8CeyBT1ajVcJzuDgpm4H' \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --data \ '{ "account_number_id": "acno_Kasf91034gj1AD", "amount": 59013, "currency": "MXN" }' ``` -------------------------------- ### Create Payment Intent Source: https://docs.fintoc.com/docs/setup-a-payment-method-for-future-charges Example cURL request to create a Payment Intent against a saved payment method. ```bash curl --request POST "https://api.fintoc.com/v2/payment_intents" \ --header "Authorization: YOUR_SECRET_API_KEY" \ --header "Content-Type: application/json" \ --data-raw '{ "amount": 150000, "currency": "CLP", "customer": "cus_NffrFeUfNV2Hib", "payment_method": "pm_NffrFeUfNV2Hib", "metadata": { "order_id": "order_98765" } }' ``` -------------------------------- ### Install with npm Source: https://docs.fintoc.com/docs/install-the-fintoc-cli Installs the Fintoc CLI globally using npm and verifies the installation by checking the version. ```bash npm install -g @fintoc/cli fintoc --version ``` -------------------------------- ### Nested Parameters Example Source: https://docs.fintoc.com/docs/webview Example demonstrating how to include nested parameters in the query string for WebView integration. ```text queryString = " public_key=pk_live_XXX &holder_type=individual &product=movements &country=cl &link_token=pi_XXX " ``` -------------------------------- ### Create a Session Source: https://docs.fintoc.com/docs/setup-a-payment-method-for-future-charges Using your Secret Key, create a Checkout Session on your backend with flow set to setup. ```bash curl --request POST "https://api.fintoc.com/v2/checkout_sessions" \ --header "Authorization: YOUR_SECRET_API_KEY" \ --header "Content-Type: application/json" \ --data-raw '{ "flow": "setup", "currency": "CLP", "success_url": "https://merchant.com/success", "cancel_url": "https://merchant.com/cancel", "customer_data": { "tax_id": { "type": "cl_rut", "value": "12088191" }, "name": "Felipe Castro", "email": "customer@email.com" }, "metadata": {} }' ``` -------------------------------- ### Install with Homebrew Source: https://docs.fintoc.com/docs/install-the-fintoc-cli Installs the Fintoc CLI using Homebrew and verifies the installation by checking the version. ```bash brew install fintoc-com/tap/fintoc fintoc --version ``` -------------------------------- ### Payment Method Activated Event Source: https://docs.fintoc.com/docs/setup-a-payment-method-for-future-charges This is an example of the `payment_method.activated` webhook event, detailing the newly saved payment method. ```json { "id": "pm_3BgHP7aSqsqLiEcotFQfyx7Of8u", "object": "payment_method", "card": null, "created_at": "2021-10-15T15:22:11.474Z", "customer": "cus_NffrFeUfNV2Hib", "mode": "live", "metadata": {}, "pac": { "account_holder_id": "257932338", "account_number": "19831940978", "account_type": "checking_account", "institution_id": "cl_banco_falabella", "status": "active", }, "type": "pac" } ``` -------------------------------- ### Checkout Session Finished Event Source: https://docs.fintoc.com/docs/setup-a-payment-method-for-future-charges This is an example of the `checkout_session.finished` webhook event, containing customer and payment method information. ```json { "id": "evt_a4xK32BanKWYn", "object": "event", "type": "checkout_session.finished", "data": { "id": "cs_li5531onlFDi235", "object": "checkout_session", "mode": "live", "flow": "setup", "status": "finished", "currency": "CLP", "customer": { "id": "cus_NffrFeUfNV2Hib", "name": "Felipe Castro", "email": "customer@mail.com", "tax_id": { "type": "cl_rut", "value": "12088191" } }, "payment_method": "pm_NffrFeUfNV2Hib", "setup_intent": "seti_3AUiBT4dia35S27G7mK8RnQg2SK", "metadata": {}, "success_url": "https://merchant.com/success", "cancel_url": "https://merchant.com/cancel" } } ``` -------------------------------- ### Send your first Transfer Source: https://docs.fintoc.com/docs/transfers-quickstart This cURL command sends your first transfer. ```curl curl --request POST \ --url https://api.fintoc.com/v2/transfers \ --header 'Authorization: YOUR_API_KEY' \ --header 'Fintoc-JWS-Signature: YOUR_JWS_SIGNATURE' \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --data \ '{ "amount": 59013, "currency": "mxn", "account_id": "acc_M8sKf230BgHjD4", "comment": "Pago de credito 10451", "reference_id": "150195", "counterparty": { "account_number": "012969123456789120" }, } ' ``` -------------------------------- ### Fund your test Account Source: https://docs.fintoc.com/docs/transfers-quickstart This cURL command simulates an inbound transfer to fund your test account. ```bash curl --request POST \ --url https://api.fintoc.com/v2/simulate/receive_transfer \ --header 'Authorization: sk_test_9c8d8CeyBT1ajVcJzuDgpm4H' \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --data \ '{ "account_number_id": "acno_Kasf91034gj1AD", "amount": 59013, "currency": "MXN" }' ``` -------------------------------- ### List Accounts using Node.js SDK Source: https://docs.fintoc.com/docs/setup Node.js code to list accounts using the Fintoc SDK. ```javascript const { Fintoc } = require('fintoc'); // You can provide a path to your PEM file or pass the PEM key directly as a string. // const privateKey = process.env.JWS_PRIVATE_KEY; const privateKey = './private_key.pem'; const fintoc = new Fintoc('your_api_key', privateKey); const accounts = await fintoc.v2.accounts.list(); for await (const account of accounts) { console.log(account.id, account.description, account.root_account_number); } ``` -------------------------------- ### Example account output (Node.js) Source: https://docs.fintoc.com/docs/guides-bank-movements Example pretty-printed JSON output for an account when using the Node.js SDK. ```javascript // Prettyfied Output { balance: { available: 0, current: 0, limit: 0 }, currency: 'CLP', holder_id: '199586335', holder_name: 'DANIEL ALEJANDRO LEAL BITRAN', id: 'acc_MNejK7B76wbJGbl1', name: 'Cuenta de Ahorro', number: '340127831', object: 'account', official_name: 'Cuenta de Ahorro', refreshed_at: '2021-11-30T17:53:59.438000+00:00', type: 'savings_account' } { balance: { available: 0, current: 0, limit: 200000 }, currency: 'CLP', holder_id: '199586335', holder_name: 'DANIEL ALEJANDRO LEAL BITRAN', id: 'acc_O38ioEA4QejjnGeb', name: 'Cuenta Corriente', number: '3945154', object: 'account', official_name: 'Cuenta Corriente MN', refreshed_at: '2021-11-30T16:54:23.441000+00:00', type: 'checking_account' } ``` -------------------------------- ### Example account output (Python) Source: https://docs.fintoc.com/docs/guides-bank-movements Example pretty-printed JSON output for an account when using the Python SDK. ```python # Prettyfied Output { "balance": { "available": 0, "current": 0, "limit": 0 }, "currency": "CLP", "holder_id": "199586335", "holder_name": "DANIEL ALEJANDRO LEAL BITRAN", "id": "acc_MNejK7B76wbJGbl1", "name": "Cuenta de Ahorro", "number": "340127831", "object": "account", "official_name": "Cuenta de Ahorro", "refreshed_at": "2021-11-30T17:53:59.438000+00:00", "type": "savings_account" } { "balance": { "available": 0, "current": 0, "limit": 200000 }, "currency": "CLP", "holder_id": "199586335", "holder_name": "DANIEL ALEJANDRO LEAL BITRAN", "id": "acc_O38ioEA4QejjnGeb", "name": "Cuenta Corriente", "number": "3945154", "object": "account", "official_name": "Cuenta Corriente MN", "refreshed_at": "2021-11-30T16:54:23.441000+00:00", "type": "checking_account" } ``` -------------------------------- ### Python SDK Installation Source: https://docs.fintoc.com/docs/accept-a-payment Install the Fintoc Python SDK for easier API interaction, automatic pagination handling, webhook verification, and other helpful features. ```bash pip install fintoc ``` -------------------------------- ### cURL Example Source: https://docs.fintoc.com/docs/guides-bank-movements This cURL command demonstrates how to fetch bank movements using a GET request to the Fintoc API. ```shell curl --request GET \ --url 'https://api.fintoc.com/v1/accounts/ACCOUNT_ID/movements?link_token=LINK_TOKEN' \ --header 'Authorization: FINTOC_SECRET_KEY' \ --header 'Accept: application/json' ``` -------------------------------- ### Node.js SDK Installation Source: https://docs.fintoc.com/docs/accept-a-payment Install the Fintoc Node.js SDK for easier API interaction, automatic pagination handling, webhook verification, and other helpful features. ```bash npm install fintoc ``` -------------------------------- ### List Accounts using Python SDK Source: https://docs.fintoc.com/docs/setup Python code to list accounts using the Fintoc SDK. ```python from fintoc import Fintoc # You can provide a path to your PEM file or pass the PEM key directly as a string. # jws_private_key = os.environ.get('JWS_PRIVATE_KEY') jws_private_key = "./private_key.pem" client = Fintoc("your_api_key", jws_private_key=jws_private_key) for account in client.v2.accounts.list(): print(account.id, account.description, account.root_account_number, account.available_balance) ``` -------------------------------- ### Create a Checkout Session (Ruby) Source: https://docs.fintoc.com/docs/accept-a-payment This Ruby example shows how to create a Checkout Session using Net::HTTP. ```ruby require 'net/http' require 'uri' require 'json' checkout_session = { amount: 1000, currency: 'clp', customer_email: 'name@example.com' } uri = URI("https://api.fintoc.com/v1/checkout_sessions") header = { Accept: 'application/json', Authorization: 'YOUR_TEST_SECRET_API_KEY' } http = Net::HTTP.new(uri.host, uri.port) request = Net::HTTP::Post.new(uri.request_uri, header) request.body = checkout_session.to_json response = http.request(request) ``` -------------------------------- ### Node.js Prettyfied Output Source: https://docs.fintoc.com/docs/guides-bank-movements Example of the prettyfied output for bank movements in Node.js. ```javascript # Prettyfied Output { id: 'mov_J32e7dHabkrqQ48P', description: 'Abono por transferencia de Daniel Alejandro Leal Bitrán Rut 19.958.633-5 desde Cuenta Corriente de B.Santander, el 28/11/2021 a las 19:16', amount: 3143097, currency: 'CLP', post_date: '2021-11-29T00:00:00.000Z', transaction_date: '2021-11-28T19:16:00.000Z', type: 'transfer', recipient_account: null, sender_account: { holder_id: '199586335', number: null, institution: null, holder_name: 'Daniel Alejandro Leal Bitran' }, comment: null, reference_id: null, pending: false, object: 'movement' } { . . . } . . . ``` -------------------------------- ### Create a Checkout Session using Ruby Source: https://docs.fintoc.com/docs/accept-a-payment This example demonstrates how to create a Checkout Session using Ruby's Net::HTTP library. ```ruby require 'net/http' require 'uri' require 'json' checkout_session = { amount: 1000, currency: 'clp', customer_email: 'name@example.com' } uri = URI("https://api.fintoc.com/v2/checkout_sessions") header = { Accept: 'application/json', Authorization: 'YOUR_TEST_SECRET_API_KEY' } http = Net::HTTP.new(uri.host, uri.port) request = Net::HTTP::Post.new(uri.request_uri, header) request.body = checkout_session.to_json response = http.request(request) ``` -------------------------------- ### Python Prettyfied Output Source: https://docs.fintoc.com/docs/guides-bank-movements Example of the prettyfied output for bank movements in Python. ```python # Prettyfied Output { "id": "mov_J32e7dHabkrqQ48P", "description": "Abono por transferencia de Daniel Alejandro Leal Bitrán Rut 19.958.633-5 desde Cuenta Corriente de B.Santander, el 28/11/2021 a las 19:16", "amount": 3143097, "currency": "CLP", "post_date": "2021-11-29T00:00:00.000Z", "transaction_date": "2021-11-28T19:16:00.000Z", "type": "transfer", "recipient_account": None, "sender_account": { "holder_id": "199586335", "number": None, "institution": None, "holder_name": "Daniel Alejandro Leal Bitran" }, "comment": None, "reference_id": None, "pending": False, "object": "movement" } { . . . } . . . ``` -------------------------------- ### Make an API request Source: https://docs.fintoc.com/docs/use-the-fintoc-cli The general form is `fintoc [args]`. Run `fintoc --help` to list available resources, or `fintoc --help` for the actions supported on that resource. ```bash $ fintoc payment_intents list $ fintoc charges create --amount 5000 --currency clp --subscription-id sub_test_abc123 $ fintoc charges create --from-json payload.json ``` ```bash $ fintoc payment_intents list --json [ { "id": "pi_test_a1b2c3d4e5f6g7h8", "object": "payment_intent", "amount": 100000, "currency": "clp", "status": "succeeded" } ] ``` -------------------------------- ### Create a Checkout Session using Python Source: https://docs.fintoc.com/docs/accept-a-payment This example shows how to create a Checkout Session using the Fintoc Python client library. ```python from fintoc import Fintoc client = Fintoc('YOUR_TEST_SECRET_API_KEY') checkout_session = client.checkout_sessions.create( amount=1000, currency='clp', customer_email='name@example.com' ) ``` -------------------------------- ### Create Checkout Session (cURL) Source: https://docs.fintoc.com/docs/quickstart-payments Example using cURL to create a Checkout Session for Chile. ```curl curl --request POST "https://api.fintoc.com/v2/checkout_sessions" \ --header "Authorization: YOUR_TEST_SECRET_API_KEY" \ --header "Content-Type: application/json" \ --data-raw '{ "amount": 2476, "currency": "CLP", "customer_email": "name@example.com", "success_url": "https://merchant.com/success", "cancel_url": "https://merchant.com/987654321" }' ``` -------------------------------- ### Node.js Example Source: https://docs.fintoc.com/docs/guides-bank-movements This Node.js code snippet shows how to retrieve bank movements asynchronously using the Fintoc library. ```javascript import { Fintoc } from 'fintoc'; async function main() { const fintocClient = new Fintoc('FINTOC_SECRET_KEY'); const link = await fintocClient.links.get('LINK_TOKEN'); const account = await link.accounts.get('ACCOUNT_ID'); const movements = await account.movements.all(); for await (const movement of movements) { console.log(movement.serialize()); } } main(); ``` -------------------------------- ### Create a Checkout Session using Node.js Source: https://docs.fintoc.com/docs/accept-a-payment This example demonstrates how to create a Checkout Session using the Fintoc Node.js client library. ```javascript const { Fintoc } = require('fintoc'); const fintoc = new Fintoc('YOUR_SECRET_KEY'); const checkoutSession = await fintoc.checkoutSessions.create({ amount: 1000, currency: 'mxn', customer_email: 'name@example.com' }); ``` -------------------------------- ### Create Checkout Session for Installments Payment Source: https://docs.fintoc.com/docs/buy-now-pay-later Example of creating a Checkout Session with the 'installments_payment' method using cURL. ```curl curl --request POST \ --url https://api.fintoc.com/v1/checkout_sessions \ --header 'accept: application/json' \ --header 'content-type: application/json' \ --data \ '{ "amount": 100000, "currency": "CLP", "cancel_url": "https://merchant.com/987654321", "success_url": "https://merchant.com/success", "customer_email": "customer@example.com", "metadata": { "order": "123456" }, "payment_methods": ["installments_payment"] }' ``` -------------------------------- ### Python Example Source: https://docs.fintoc.com/docs/guides-bank-movements This Python code snippet demonstrates how to fetch bank movements for a specific account using the Fintoc client. ```python from fintoc import Fintoc fintoc_client = Fintoc("FINTOC_SECRET_KEY") link = fintoc_client.links.get("LINK_TOKEN") account = link.accounts.get("ACCOUNT_ID") movements = account.movements.all() for movement in movements: print(movement.serialize()) ```