### Customer Creation Request Examples Source: https://docs.onepay.la/client/customers/create Examples of how to create a customer using the API. Ensure you include an idempotency key for safe retries. ```bash curl https://api.onepay.la/v1/customers \ -X POST \ -H "Authorization: Bearer sk_test_xxx" \ -H "Content-Type: application/json" \ -H "x-idempotency: customer-001" \ -d '{ "user_type": "natural", "first_name": "Juan", "last_name": "Pérez", "email": "juan@example.com", "phone": "+573001234567", "document_type": "CC", "document_number": "1234567890", "enable_notifications": true }' ``` ```javascript const response = await fetch('https://api.onepay.la/v1/customers', { method: 'POST', headers: { 'Authorization': 'Bearer sk_test_xxx', 'Content-Type': 'application/json', 'x-idempotency': 'customer-001' }, body: JSON.stringify({ user_type: 'natural', first_name: 'Juan', last_name: 'Pérez', email: 'juan@example.com', phone: '+573001234567', document_type: 'CC', document_number: '1234567890', enable_notifications: true }) }); const customer = await response.json(); console.log(customer); ``` ```python import requests response = requests.post( 'https://api.onepay.la/v1/customers', headers={ 'Authorization': 'Bearer sk_test_xxx', 'Content-Type': 'application/json', 'x-idempotency': 'customer-001' }, json={ 'user_type': 'natural', 'first_name': 'Juan', 'last_name': 'Pérez', 'email': 'juan@example.com', 'phone': '+573001234567', 'document_type': 'CC', 'document_number': '1234567890', 'enable_notifications': True } ) customer = response.json() print(customer) ``` ```php "https://api.onepay.la/v1/customers", CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_HTTPHEADER => [ "Authorization: Bearer sk_test_xxx", "Content-Type: application/json", "x-idempotency: customer-001" ], CURLOPT_POSTFIELDS => json_encode([ "user_type" => "natural", "first_name" => "Juan", "last_name" => "Pérez", "email" => "juan@example.com", "phone" => "+573001234567", "document_type" => "CC", "document_number" => "1234567890", "enable_notifications" => true ]) ]); $response = curl_exec($curl); curl_close($curl); $customer = json_decode($response, true); print_r($customer); ?> ``` -------------------------------- ### Customer Creation Response Examples Source: https://docs.onepay.la/client/customers/create Examples of successful and error responses when creating a customer. A successful response includes the customer's unique identifier and details. ```json { "id":"9da58912-101d-46f8-86c9-20a52119c0bf", "first_name":"John", "last_name":"Doe", "email":"john.doe@example.com", "phone":"+573100001020", "document_type":"CC", "document_number":"1060500333", "nationality":"CO", "birthdate":"1990-01-01", "created_at":"2024-12-04T20:09:08.000000Z" } ``` ```json { "message":"El campo nombre es obligatorio. (y 6 errores más)", "code":10001, "code_name":"validation_error", "errors":{ "first_name":[ "El campo nombre es obligatorio." ], "last_name":[ "El campo apellido es obligatorio." ], "phone":[ "El campo teléfono es obligatorio." ], "email":[ "El campo correo electrónico es obligatorio." ], "user_type":[ "El campo user type es obligatorio." ], "document_type":[ "El campo document type es obligatorio." ], "document_number":[ "El campo document number es obligatorio." ], "nationality":[ "El código de país debe seguir el formato ISO 3166-1 alpha-2" ], "birthdate":[ "La fecha debe tener el formato YYYY-MM-DD" ] } } ``` ```json { "message": "No se puede generar la operación, genera un token de idempotencia y envíelo en los headers como x-idempotency", "code": 10003, "code_name": "idempotency_error" } ``` -------------------------------- ### Plan Creation Response Source: https://docs.onepay.la/client/subscriptions This is an example of a successful response when creating a plan. It includes the unique ID of the created plan. ```json { "id": "9e5a2b3c-4d5e-6f7a-8b9c-0d1e2f3a4b5c", "name": "Plan Premium Mensual", "amount": 50000, "currency": "COP", "cycle_frequency": 1, "cycle_type": "monthly" } ``` -------------------------------- ### List of Available Banks for Debit Source: https://docs.onepay.la/client/accounts/list-banks This snippet shows an example response for available banks that can be used for authorized debits. It includes details such as bank ID, name, supported types, and availability for PSE. ```json [{"id": "9957817d-239b-4032-8dca-bc508a76579c", "name": "NEQUI", "supported_types": ["savings", "electronic_deposit"], "mask": "999 999 9999", "transaction_avg": 0, "available": true, "pse": true, "connection_type": "CONFIRMATION", "logo": "https://firebasestorage.googleapis.com/v0/b/onepayai.appspot.com/o/images%2Fnequi.jpg?alt=media&token=20984290-ce05-4815-916f-c5362522750f", "instructions": "

Sigue los siguientes pasos para realizar tu pago.

  1. Abre Nequi y toca la campanita en la esquina derecha.
  2. Busca la notificación pendiente de Pagos y conexiones y toca Aceptar.
  3. Confirma el pago a Pagos y conexiones seleccionando Confirmar.
"}, {"id": "9957817c-f17e-472b-b531-e3d1490bf757", "name": "BANCOLOMBIA", "supported_types": ["savings", "checking"], "mask": "999-999999-99", "transaction_avg": null, "available": true, "pse": true, "connection_type": "DATA", "logo": "https://firebasestorage.googleapis.com/v0/b/onepayai.appspot.com/o/images%2Fbancolombia.jpg?alt=media&token=b0fa2f5e-6dfc-4cc1-a5f7-1c49877fd1fa", "instructions": "

Por tu seguridad, tu cuenta de Bancolombia está siendo validada. Este proceso puede tardar algunas horas.

"}] ``` -------------------------------- ### Get Payment Intent Response Source: https://docs.onepay.la/client/payment-intent/get This is an example of a successful response when retrieving a payment intent. ```APIDOC ## GET /client/payment-intent/{id} ### Description Retrieves the details of a specific payment intent. ### Method GET ### Endpoint /client/payment-intent/{id} ### Response #### Success Response (200) - **id** (string) - The unique identifier of the payment intent. - **description** (string) - A description of the payment intent. - **amount** (integer) - The total amount of the payment intent in the smallest currency unit. - **amount_label** (string) - The formatted amount for display. - **currency** (string) - The currency of the payment intent (e.g., 'COP'). - **status** (string) - The current status of the payment intent (e.g., 'paid'). - **payment_method_type** (string) - The type of payment method used (e.g., 'CreditCard'). - **payment_method_id** (string) - The identifier for the payment method. - **source** (object) - Information about the source of the payment. - **type** (string) - The type of the source (e.g., 'Payment'). - **id** (string) - The identifier of the source. - **created_at** (string) - The timestamp when the payment intent was created. - **paid_at** (string) - The timestamp when the payment intent was paid. - **remarks** (string) - Any remarks associated with the payment intent. - **is_test** (boolean) - Indicates if this is a test transaction. - **network_id** (string) - The identifier for the payment network. - **external_id** (string) - An external identifier for the transaction. - **method** (object) - Details about the payment method. - **id** (string) - The identifier of the payment method. - **brand** (string) - The brand of the card (e.g., 'visa'). - **label** (string) - A user-friendly label for the payment method. - **last_four** (string) - The last four digits of the card number. - **expiration_date** (string) - The expiration date of the card (MM/YYYY). - **customer_id** (string) - The identifier of the customer associated with the payment method. - **created_at** (string) - The timestamp when the payment method was created. - **country** (string) - The country associated with the payment method. - **customer** (object) - Details about the customer. - **id** (string) - The identifier of the customer. - **first_name** (string) - The first name of the customer. - **last_name** (string) - The last name of the customer. - **email** (string) - The email address of the customer. - **phone** (string) - The phone number of the customer. - **document_type** (string) - The type of identification document (e.g., 'CC'). - **document_number** (string) - The identification document number. - **created_at** (string) - The timestamp when the customer was created. - **is_test** (boolean) - Indicates if this is a test customer. #### Response Example { "id": "9bf2bc44-28d4-4693-9896-7fc1fe1f5b65", "description": "Pago factura 001-2024", "amount": 63040, "amount_label": "$63.040", "currency": "COP", "status": "paid", "payment_method_type": "CreditCard", "payment_method_id": "3f8b7a21-1d4a-4d2e-8f1a-17e2f1e6b9ab", "source": { "type": "Payment", "id": "12e34567-89ab-4cde-f012-3456789abcde" }, "created_at": "2024-10-20T12:00:00.000000Z", "paid_at": "2024-10-20T12:10:10.000000Z", "remarks": null, "is_test": true, "network_id": "prov-123", "external_id": "EXT-12345", "method": { "id": "3f8b7a21-1d4a-4d2e-8f1a-17e2f1e6b9ab", "brand": "visa", "label": "Personal", "last_four": "4242", "expiration_date": "12/2028", "customer_id": "1c2d3e4f-5678-90ab-cdef-111213141516", "created_at": "2024-09-15T10:20:30.000000Z", "country": "CO" }, "customer": { "id": "4e5f6a7b-8c9d-0e1f-2345-6789abcdef01", "first_name": "Juan", "last_name": "Pérez", "email": "juan.perez@example.com", "phone": "+573001112233", "document_type": "CC", "document_number": "1234567890", "created_at": "2024-09-10T09:00:00.000000Z", "is_test": true } } ``` -------------------------------- ### Exponer Servidor Local con Ngrok Source: https://docs.onepay.la/guides/implementar-webhooks Utiliza Ngrok para exponer tu servidor de desarrollo local a internet. Esto es necesario para que OnePay pueda enviar las solicitudes de webhook a tu máquina durante el desarrollo. ```bash ngrok http 3000 ``` -------------------------------- ### Get Customer Issued Cards (JSON Response) Source: https://docs.onepay.la/client/customers/issuing-cards Example of a successful JSON response when retrieving cards issued to a customer. Includes card details and pagination information. ```json { "data": [ { "id": "9e41fe85-a21b-4145-b127-b9ddd593be5b", "status": "created", "last_4": null, "nickname": null, "type": "physical", "customer_id": "9e41fe85-a058-4afc-9940-09764468aa5c", "wallet_id": "019523d3-419c-7097-a343-b39a8eb7a50c" } ], "current_page": 1, "from": 1, "last_page": 1, "per_page": 15, "to": 1, "total": 1 } ``` -------------------------------- ### Example Webhook Payload Source: https://docs.onepay.la/client/webhooks/accounts An example of the JSON payload received for an account event. ```APIDOC ## Example Webhook Payload ### Description This is an example of the JSON payload structure for an account-related webhook event. ### Payload Example ```json { "account":{ "bank_id":"9b90ba74-4a99-4beb-827d-2df3236c2549", "subtype":"SAVINGS", "authorization":false, "id":"9b90ba74-5743-4eb3-a6a8-a1503919c98f", "status":"PENDING", "title":"Swift Group **** 7890", "created_at":"2024-03-14T23:30:57.000000Z", "method_type":"account", "bank":{ "id":"9b90ba74-4a99-4beb-827d-2df3236c2549", "name":"Swift Group", "supported_types":[ "SAVINGS" ], "mask":null, "transaction_avg":null, "available":0, "connection_type":"CONFIRMATION", "logo":null, "instructions":null } }, "event":{ "type":"account.pending", "timestamp":1689262934, "environment":"live|test" } } ``` ``` -------------------------------- ### List Payment Methods (JavaScript) Source: https://docs.onepay.la/client/customer-session/list-payment-methods This JavaScript example demonstrates how to fetch the customer's payment methods using the Fetch API. It logs the different payment method types (cards, wallets, PSE) to the console. Remember to use your company's Bearer token and the customer's session token. ```javascript const response = await fetch('https://api.onepay.la/v1/customers/session/payment-methods', { headers: { 'Authorization': 'Bearer sk_test_xxx', 'X-Customer-Token': '12|a1b2c3d4e5f6...' } }); const { data } = await response.json(); console.log(data.cards); // Tarjetas console.log(data.wallets); // Nequi/Daviplata console.log(data.pse); // Cuentas PSE ``` -------------------------------- ### Create a Subscription Source: https://docs.onepay.la/client/subscriptions Use this endpoint to create a subscription for a customer. You need to provide the customer ID, plan ID, and an authorized payment method ID. ```bash curl https://api.onepay.la/v1/subscriptions \ -X POST \ -H "Authorization: Bearer sk_test_xxx" \ -H "Content-Type: application/json" \ -H "x-idempotency: subscription-001" \ -d '{ "customer_id": "9dd4158b-0e45-42bc-b56f-a4c1f856814d", "plan_id": "9e5a2b3c-4d5e-6f7a-8b9c-0d1e2f3a4b5c", "card_id": "9e01eeae-2868-4564-9d04-84d1d1d027d2" }' ``` -------------------------------- ### Company Creation Response Examples Source: https://docs.onepay.la/client/companies/create These examples show successful company creation (201), validation errors (422), and idempotency errors (409). ```json { "id": "9da58912-101d-46f8-86c9-20a52119c0bf", "name": "Acme Inc", "legal_name": "Acme Inc S.A.S", "phone": "+573001234567", "document_type": "NIT", "document_number": "123456789-1", "status": "pending", "industry": "0742", "currency": "COP" } ``` ```json { "message": "El campo nombre es obligatorio. (y 5 errores más)", "code": 10001, "code_name": "validation_error", "errors": { "name": ["El campo nombre es obligatorio."], "document_type": ["El tipo de documento no es válido para el tipo de compañía seleccionado."], "fiscal_responsibilities": ["El campo fiscal responsibilities es obligatorio."] } } ``` ```json { "message": "No se puede generar la operación, genera un token de idempotencia y envíelo en los headers como x-idempotency", "code": 10003, "code_name": "idempotency_error" } ``` -------------------------------- ### Consultar cargo con Python Source: https://docs.onepay.la/client/customer-session/show-charge This Python example uses the requests library to query charge information. It requires the charge ID and the appropriate authorization headers. ```python import requests response = requests.get( 'https://api.onepay.la/v1/customers/session/charges/9e02966f-2ddf-4ee7-a391-5b5b7653e232', headers={ 'Authorization': 'Bearer sk_test_xxx', 'X-Customer-Token': '12|a1b2c3d4e5f6...' } ) charge = response.json() ``` -------------------------------- ### Create a Customer Source: https://docs.onepay.la/client/customers/index Use this endpoint to create a new customer. Ensure you include the necessary user type and identification details. The idempotency key helps prevent duplicate requests. ```bash curl https://api.onepay.la/v1/customers \ -X POST \ -H "Authorization: Bearer sk_test_xxx" \ -H "Content-Type: application/json" \ -H "x-idempotency: cli-001" \ -d '{ "user_type": "natural", "first_name": "María", "last_name": "López", "email": "maria@ejemplo.com", "phone": "+573201112233", "document_type": "CC", "document_number": "1060500333" }' ``` -------------------------------- ### Create Account Request Source: https://docs.onepay.la/client/accounts/create Use this endpoint to create a new bank account for a customer. Ensure the `authorization` parameter is set to `true` to enable wallet enrollment and future charges. The `x-idempotency` header is crucial for preventing duplicate requests. ```bash curl https://api.onepay.la/v1/accounts \ -X POST \ -H "Authorization: Bearer sk_test_xxx" \ -H "Content-Type: application/json" \ -H "x-idempotency: account-001" \ -d '{ "subtype": "SAVINGS", "authorization": true, "re-enrollment": false, "account_number": "1234567890", "customer_id": "9dd4158b-0e45-42bc-b56f-a4c1f856814d", "bank_id": "9957817c-f17e-472b-b531-e3d1490bf757" }' ``` ```javascript const response = await fetch('https://api.onepay.la/v1/accounts', { method: 'POST', headers: { 'Authorization': 'Bearer sk_test_xxx', 'Content-Type': 'application/json', 'x-idempotency': 'account-001' }, body: JSON.stringify({ subtype: 'SAVINGS', authorization: true, 're-enrollment': false, account_number: '1234567890', customer_id: '9dd4158b-0e45-42bc-b56f-a4c1f856814d', bank_id: '9957817c-f17e-472b-b531-e3d1490bf757' }) }); const account = await response.json(); ``` ```python import requests response = requests.post( 'https://api.onepay.la/v1/accounts', headers={ 'Authorization': 'Bearer sk_test_xxx', 'Content-Type': 'application/json', 'x-idempotency': 'account-001' }, json={ 'subtype': 'SAVINGS', 'authorization': True, 're-enrollment': False, 'account_number': '1234567890', 'customer_id': '9dd4158b-0e45-42bc-b56f-a4c1f856814d', 'bank_id': '9957817c-f17e-472b-b531-e3d1490bf757' } ) account = response.json() ``` ```php "https://api.onepay.la/v1/accounts", CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_HTTPHEADER => [ ``` -------------------------------- ### Get Cashout Details Source: https://docs.onepay.la/client/cashouts/detail This endpoint allows you to retrieve the full details of a previously created cashout. You need to provide the unique ID of the cashout to get its status, amount, and other relevant information. ```APIDOC ## GET /v1/cashouts/{cashout_id} ### Description Retrieves the details of a specific cashout transaction. ### Method GET ### Endpoint /v1/cashouts/{cashout_id} ### Parameters #### Path Parameters - **cashout_id** (string) - Required - The unique identifier of the cashout to retrieve. Example: `9d44ce43-a227-4566-b107-5a6bc01cbcdf` ### Request Example ```bash cURL curl https://api.onepay.la/v1/cashouts/9d44ce43-a227-4566-b107-5a6bc01cbcdf \ -H "Authorization: Bearer sk_test_xxx" ``` ```javascript JavaScript const cashoutId = '9d44ce43-a227-4566-b107-5a6bc01cbcdf'; const response = await fetch(`https://api.onepay.la/v1/cashouts/${cashoutId}`, { method: 'GET', headers: { 'Authorization': 'Bearer sk_test_xxx' } }); const cashout = await response.json(); console.log(cashout.status); // Estado de la dispersión ``` ```python Python import requests cashout_id = "9d44ce43-a227-4566-b107-5a6bc01cbcdf" url = f"https://api.onepay.la/v1/cashouts/{cashout_id}" headers = { "Authorization": "Bearer sk_test_xxx" } response = requests.get(url, headers=headers) cashout = response.json() print(cashout["status"]) # Estado de la dispersión ``` ```php PHP "https://api.onepay.la/v1/cashouts/{$cashoutId}", CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ "Authorization: Bearer sk_test_xxx" ] ]); $response = curl_exec($ch); $cashout = json_decode($response, true); echo $cashout["status"]; // Estado de la dispersión curl_close($ch); ?> ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier of the cashout. - **customer_id** (string) - The ID of the customer associated with the cashout. - **account_id** (string) - The ID of the account used for the cashout. - **is_test** (boolean) - Indicates if this is a test transaction. - **amount** (integer) - The amount of the cashout. - **status** (string) - The current status of the cashout (e.g., 'processed', 'pending'). - **scheduled_at** (string|null) - The timestamp when the cashout is scheduled. - **created_at** (string) - The timestamp when the cashout was created. - **external_id** (string|null) - An external identifier for the cashout, if applicable. - **method** (string) - The method used for the cashout (e.g., 'ACH'). #### Response Example ```json { "id":"9d44ce43-a227-4566-b107-5a6bc01cbcdf", "customer_id":"9b7c5f38-b2b5-4b0d-8e4c-458192e88eae", "account_id":"9d0ac58c-2226-4f1c-b305-15e6dc3b47f6", "is_test":false, "amount":1000, "status":"processed", "scheduled_at":null, "created_at":"2024-10-17T18:07:18.000000Z", "external_id":null, "method":"ACH" } ``` ``` -------------------------------- ### Account Creation Response Examples Source: https://docs.onepay.la/client/accounts/create Examines successful account creation (200 OK) and idempotency errors (409 Conflict). The 409 response advises generating and using an idempotency token. ```json { "id":"84cc072e-90e8-33cf-9305-098095fed32f", "title":"Ms.", "subtype":"CHECKING", "status":"PENDING", "authorization":true, "customer_id":"9e01d019-b438-40d2-89e1-52430c69dfb7", "re_enroll":false, "external_id":null, "bank_id":"9e01d019-b731-48bc-b111-2baa3ea56ef6", "bank":{ "id":"9e01d019-b731-48bc-b111-2baa3ea56ef6", "name":"Maggio-Hills", "logo":null, "base64_logo":"" }, "customer":{ "id":"9e01d019-b438-40d2-89e1-52430c69dfb7", "first_name":"Izaiah", "last_name":"Rogahn", "email":"", "phone":"+17478695836", "document_type":"CC", "document_number":"156762", "created_at":"2025-01-19T17:03:55.000000Z", "is_test":true } } ``` ```json { "message": "No se puede generar la operación, genera un token de idempotencia y envíelo en los headers como x-idempotency", "code": 10003, "code_name": "idempotency_error" } ``` -------------------------------- ### Get Invoice Details Source: https://docs.onepay.la/client/invoices/index Retrieves the details of a specific invoice. ```APIDOC ## GET /invoices/{id} ### Description Retrieves the details of a specific invoice. ### Method GET ### Endpoint /invoices/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the invoice to retrieve. ``` -------------------------------- ### Get Charge Detail Source: https://docs.onepay.la/client/charges/index Retrieves the details of a specific charge. ```APIDOC ## GET /charges/{id} ### Description Detalle cargo ### Method GET ### Endpoint /charges/{id} ``` -------------------------------- ### Create Company Request (JavaScript) Source: https://docs.onepay.la/client/companies/create This JavaScript example demonstrates how to create a company using the Fetch API. It includes setting the necessary headers like Authorization and idempotency key. ```javascript const response = await fetch('https://api.onepay.la/v1/companies', { method: 'POST', headers: { 'Authorization': 'Bearer sk_test_xxx', 'Content-Type': 'application/json', 'x-idempotency': 'company-001' }, body: JSON.stringify({ type: 'organization', name: 'Acme Inc', legal_name: 'Acme Inc S.A.S', document_type: 'NIT', document_number: '123456789-1', phone: '+573001234567', email: 'contacto@acme.co', website: 'https://acme.co', economic_activity: '0111', industry: '0742', sales: 35, fiscal_responsibilities: ['O_47'], retention_rules: { iva: true, ica: false, fuente: true }, city_id: 1, address: { address: 'Calle 100 #15-20', hint: 'Oficina 301', zipcode: '170004' }, documents: { rut: 'https://storage.example.com/rut.pdf', ccc: 'https://storage.example.com/ccc.pdf', dni: 'https://storage.example.com/dni.pdf', bank: 'https://storage.example.com/bank.pdf', simple: 'https://storage.example.com/simple.pdf' }, company_owner: { name: 'Juan', last_name: 'Pérez', phone: '+573001234568', email: 'juan@acme.co', document_type: 'cc', dni: '10000001' }, account: { type: 'savings', bank_id: '9da58912-101d-46f8-86c9-20a52119c0bf', number: '1234567890', terms: true } }) }); ``` -------------------------------- ### Create Tokenized Card Request (Python) Source: https://docs.onepay.la/client/cards/create-tokenized This Python example shows how to make a POST request to tokenize a card using the requests library. It includes setting the Authorization header and Content-Type. ```python import requests response = requests.post( 'https://api.onepay.la/v1/cards/tokenized', headers={ 'Authorization': 'Bearer sk_test_xxx', 'Content-Type': 'application/json', ``` -------------------------------- ### Get Balance Source: https://docs.onepay.la/client/balance/get Endpoint to retrieve the balance of the OnePay account. ```APIDOC ## GET /balance ### Description Endpoint to obtain the balance of the OnePay account. ### Method GET ### Endpoint /balance ### Response #### Success Response (200) - **id** (string) - The unique identifier for the balance record. - **balance** (number) - The numerical value of the account balance. - **balance_label** (string) - A formatted string representing the account balance. #### Response Example ```json { "id": "0ced28ec-bd54-42a0-844d-00fde7b03300", "balance": 30284766.15, "balance_label": "$30.284.766,15" } ``` #### Error Response (401) - **message** (string) - Error message indicating authentication failure. - **code** (integer) - Error code. - **code_name** (string) - Symbolic name for the error code. #### Response Example ```json { "message": "No autenticado", "code": 10000, "code_name": "unauthenticated" } ``` #### Error Response (404) - **message** (string) - Error message indicating the balance was not found. - **code** (integer) - Error code. - **code_name** (string) - Symbolic name for the error code. #### Response Example ```json { "message": "Balance no encontrado", "code": 10004, "code_name": "not_found" } ``` ``` -------------------------------- ### Request to Create a Card (JavaScript) Source: https://docs.onepay.la/client/cards/create This JavaScript example demonstrates how to create a card using the fetch API. It includes setting the necessary headers and stringifying the request body. ```javascript const response = await fetch('https://cards.onepay.la/v1/cards', { method: 'POST', headers: { 'Authorization': 'Bearer pk_test_xxx', 'Content-Type': 'application/json', 'x-idempotency': 'card-001' }, body: JSON.stringify({ ``` -------------------------------- ### Listar cargos Source: https://docs.onepay.la/llms.txt Endpoint to get the charges registered in the OnePay system. ```APIDOC ## GET /client/charges/list ### Description Endpoint to get the charges registered in the OnePay system. ### Method GET ### Endpoint /client/charges/list ``` -------------------------------- ### Detalle cargo Source: https://docs.onepay.la/llms.txt Endpoint to get the details of a charge in the OnePay system. ```APIDOC ## GET /client/charges/detail ### Description Endpoint to get the details of a charge in the OnePay system. ### Method GET ### Endpoint /client/charges/detail ``` -------------------------------- ### Crear Link de Pago Manual Source: https://docs.onepay.la/guides/cobrar-link-pago Genera un link de pago que puedes compartir manualmente. Este comando `curl` requiere el monto, título y moneda. El cliente recibirá el link para pago. ```bash curl https://api.onepay.la/v1/payments \ -X POST \ -H "Authorization: Bearer sk_test_xxx" \ -H "Content-Type: application/json" \ -H "x-idempotency: pago-link-001" \ -d '{ "amount": 150000, "title": "Factura #1234", "currency": "COP" }' ``` -------------------------------- ### Listar dispersiones Source: https://docs.onepay.la/llms.txt Get the cashouts registered in your company with filters and pagination. ```APIDOC ## GET /client/cashouts/list ### Description Get the cashouts registered in your company with filters and pagination. ### Method GET ### Endpoint /client/cashouts/list ``` -------------------------------- ### Create a payout Source: https://docs.onepay.la/guides/dispersar-dinero Initiate a money transfer to a registered bank account. Change the `method` to `ACH`, `TURBO`, or `INSTANT` based on the desired transfer speed. ```bash curl https://api.onepay.la/v1/cashouts \ -X POST \ -H "Authorization: Bearer sk_test_xxx" \ -H "Content-Type: application/json" \ -H "x-idempotency: dispersion-001" \ -d '{ "amount": 500000, "customer_id": "CUSTOMER_ID", "account_id": "ACCOUNT_ID", "currency": "COP", "method": "ACH", "description": "Pago proveedor Enero 2025" }' ``` -------------------------------- ### Fetch Card Details using Python Source: https://docs.onepay.la/client/cards/detail This Python example shows how to retrieve card details using the `requests` library. It includes setting the Authorization header and parsing the JSON response. ```python import requests response = requests.get( 'https://api.onepay.la/v1/cards/bb02b2fd-154c-4c90-9fdf-cec3a0b25cf5', headers={'Authorization': 'Bearer sk_test_xxx'}, ) card = response.json() ``` -------------------------------- ### Detalle dispersión Source: https://docs.onepay.la/llms.txt Endpoint to get the details of a cashout in the OnePay system. ```APIDOC ## GET /client/cashouts/detail ### Description Endpoint to get the details of a cashout in the OnePay system. ### Method GET ### Endpoint /client/cashouts/detail ``` -------------------------------- ### Listado de cuentas Source: https://docs.onepay.la/llms.txt Endpoint to get the list of bank accounts. ```APIDOC ## GET /client/accounts/list ### Description Endpoint to get the list of bank accounts. ### Method GET ### Endpoint /client/accounts/list ``` -------------------------------- ### Inicializar el SDK de OnePay Source: https://docs.onepay.la/docs/elements/introduction Inicializa el SDK de OnePay proporcionando el identificador del servicio y el ambiente ('production' o 'sandbox'). Guarda la instancia del SDK en una variable para su uso posterior. ```javascript const FT = window.FTCaptures.init("ggMoeO2K3G", "production"); ``` -------------------------------- ### Create Charge Request (Python) Source: https://docs.onepay.la/client/customer-session/create-charge This Python example shows how to create a charge using the requests library. It configures the request with appropriate headers and a JSON payload containing the charge details. ```python import requests response = requests.post( 'https://api.onepay.la/v1/customers/session/charges', headers={ 'Authorization': 'Bearer sk_test_xxx', 'X-Customer-Token': '12|a1b2c3d4e5f6...', 'X-Idempotency': '550e8400-e29b-41d4-a716-446655440000', 'Content-Type': 'application/json' }, json={ 'payment_method_id': 'bb02b2fd-154c-4c90-9fdf-cec3a0b25cf5', 'amount': 50000, 'currency': 'COP', 'description': 'Pago mensualidad marzo' } ) charge = response.json() ``` -------------------------------- ### Get Webhook Details Source: https://docs.onepay.la/client/webhooks/detail Returns the details of a specific webhook by its ID. ```APIDOC ## GET /v1/webhooks/{id} ### Description Retrieves the details of a specific webhook. ### Method GET ### Endpoint /v1/webhooks/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the webhook to consult. ### Request Example ```bash curl https://api.onepay.la/v1/webhooks/a1b2c3d4-e5f6-7890-abcd-ef1234567890 \ -H "Authorization: Bearer sk_test_xxx" ``` ### Response #### Success Response (200) - **data** (object) - Contains the webhook details. - **id** (string) - The unique identifier of the webhook. - **name** (string) - The name of the webhook. - **description** (string) - A description of the webhook. - **url** (string) - The URL where webhook events will be sent. - **events** (array) - A list of events that trigger this webhook. - **header** (object) - Custom headers to be sent with the webhook request. - **is_test** (boolean) - Indicates if this is a test webhook. - **created_at** (string) - The timestamp when the webhook was created. - **updated_at** (string) - The timestamp when the webhook was last updated. #### Response Example ```json { "data": { "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "name": "Webhook de producción", "description": "Notificaciones de pagos aprobados", "url": "https://mi-servidor.com/webhooks/onepay", "events": [ "payment.approved", "payment.rejected", "charge.paid", "charge.failed" ], "header": null, "is_test": false, "created_at": "2025-01-20T14:30:00+00:00", "updated_at": "2025-01-20T14:30:00+00:00" } } ``` #### Error Response (404) - **message** (string) - Error message indicating the webhook was not found. - **code** (integer) - Error code. - **code_name** (string) - Symbolic name for the error code. #### Response Example ```json { "message": "Webhook no encontrado.", "code": 10004, "code_name": "not_found" } ``` ``` -------------------------------- ### Get Invoice Details Source: https://docs.onepay.la/client/invoices Retrieves the details of a specific invoice by its ID. ```APIDOC ## GET /invoices/{id} ### Description Retrieves the details of a specific invoice. ### Method GET ### Endpoint /invoices/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the invoice. ``` -------------------------------- ### List Payment Methods (cURL) Source: https://docs.onepay.la/client/customer-session/list-payment-methods Use this command to list all payment methods for the authenticated customer using cURL. Ensure you replace `sk_test_xxx` with your actual Bearer token and `12|a1b2c3d4e5f6...` with the customer's session token. ```bash curl https://api.onepay.la/v1/customers/session/payment-methods \ -H "Authorization: Bearer sk_test_xxx" \ -H "X-Customer-Token: 12|a1b2c3d4e5f6..." ``` -------------------------------- ### Get Customer Details Source: https://docs.onepay.la/client/customers/detail Fetches the details of a specific customer by their ID. ```APIDOC ## GET /client/customers/{customer_id} ### Description Obtiene los detalles de un cliente específico. ### Method GET ### Endpoint /client/customers/{customer_id} ### Parameters #### Path Parameters - **customer_id** (string) - Required - ID del cliente que deseas consultar. [Crear cliente](/client/customers/create). ### Response #### Success Response (200) - **id** (string) - Identificador único del cliente en formato UUID - **name** (string) - Nombre del cliente - **email** (string) - Correo electrónico del cliente - **phone** (string) - Número de teléfono del cliente - **document_number** (string) - Número de documento de identidad del cliente - **document_type** (string) - Tipo de documento de identidad del cliente (ej. DNI, RUC, CE) - **created_at** (date) - Fecha y hora de creación del cliente #### Response Example ```json { "id":"9da58912-101d-46f8-86c9-20a52119c0bf", "first_name":"John", "last_name":"Doe", "email":"john.doe@example.com", "phone":"+573100001020", "document_type":"CC", "document_number":"1060500333", "created_at":"2024-12-04T20:09:08.000000Z" } ``` #### Error Response (404) - **message** (string) - Mensaje de error indicando que el cliente no fue encontrado. - **code** (integer) - Código de error numérico. - **code_name** (string) - Nombre del código de error. #### Response Example ```json { "message": "Cliente no encontrado", "code": 10004, "code_name": "not_found" } ``` ```