### New Session Response - Tuna API Source: https://dev.tuna.uy/api/payment-integration The response from starting a new customer session with the Tuna API, containing a unique sessionId. ```json { "sessionId":"qsTfE2PUGhuncSiaSkFxwJ5vqtsMDrUQsnyM4ZbeTKvx5EJutFovAHEt2/QGjHe61spKmCY8saNoht+VfqTGgxqu2r49ShW2", "code":1, "message":null } ``` -------------------------------- ### Start New Session - Tuna API Source: https://dev.tuna.uy/api/payment-integration Initiates a new session for a customer with the Tuna API. This is a prerequisite for tokenizing credit card data. Requires customer ID and email. ```curl curl -X 'POST'\ 'https://token.tuna-demo.uy/api/Token/NewSession'\ -H 'accept: application/json'\ -H 'x-tuna-account: demo'\ -H 'x-tuna-apptoken: a3823a59-66bb-49e2-95eb-b47c447ec7a7'\ -H 'Content-Type: application/json'\ -d '{ "customer": { "id": "7", "email": "maju.cheapetta@synapcom.com.br" } }' ``` -------------------------------- ### Direct Payment Request Initialization Source: https://dev.tuna.uy/api/payment-integration Initiates a payment transaction directly through the api/Payment/Init endpoint for payment methods like Boleto, PIX, and Bitcoin. This method differs from card tokenization by not requiring a sessionId. ```HTTP POST /api/Payment/Init Host: api.tuna.uy Content-Type: application/json { "amount": 10000, "currency": "BRL", "paymentMethod": "Boleto", "customer": { "name": "John Doe", "document": "12345678900" } } ``` -------------------------------- ### Tuna API Sandbox Request Example (cURL) Source: https://dev.tuna.uy/api/sandbox-environment This snippet demonstrates how to make a POST request to the Tuna API sandbox environment using cURL. It includes essential headers for authentication and content type. ```bash curl -X 'POST' \ 'https://sandbox.tuna-demo.uy/api/' \ -H 'accept: application/json' \ -H 'x-tuna-account: demo' \ -H 'x-tuna-apptoken: a3823a59-66bb-49e2-95eb-b47c447ec7a7' \ -H 'Content-Type: application/json' ``` -------------------------------- ### Generate Token Response - Tuna API Source: https://dev.tuna.uy/api/payment-integration The response from generating a credit card token with the Tuna API, including the token, brand, and status code. ```json { "token":"ct_NjJmM2QxOTUtYTM4OS00YmYyLTg4MDAtOTE3YzY1NzM0NmE30", "brand":"Visa", "validFor":null, "code":1, "message":null } ``` -------------------------------- ### POST Request with Idempotency Key Source: https://dev.tuna.uy/api/idempotent-requests This example demonstrates how to make an idempotent POST request to the Tuna API's Merchant Register endpoint. It includes the necessary headers such as 'Idempotency-Key', 'x-tuna-account', 'x-tuna-apptoken', and 'Content-Type'. ```bash curl -X 'POST' \ 'https://sandbox.tuna-demo.uy/api/Merchant/Register' \ -H 'accept: application/json' \ -H 'x-tuna-account: demo' \ -H 'x-tuna-apptoken: a3823a59-66bb-49e2-95eb-b47c447ec7a7' \ -H 'Idempotency-Key: YzHfUsJHm79qhTZr' \ -H 'Content-Type: application/json' ``` -------------------------------- ### Register Person Merchant API Request Source: https://dev.tuna.uy/api/split-integration This snippet shows how to register an individual merchant using the Tuna API. It details the POST request, required headers, and a JSON payload with personal information and banking details. ```curl curl -X 'POST' \ 'https://sandbox.tuna-demo.uy/api/Merchant/Register' \ -H 'accept: application/json' \ -H 'x-tuna-account: demo' \ -H 'x-tuna-apptoken: a3823a59-66bb-49e2-95eb-b47c447ec7a7' \ -H 'Content-Type: application/json' \ -d '{ \ "externalId": "##003", \ "document": "225.465.960-04", \ "documentType": "CPF", \ "condition": "1", \ "acceptedContract": true, \ "websiteUrl": "www.synapcom.com.br", \ "registrationDate": "2022-03-16", \ "name": "Natalia Cheapetta", \ "birthday": "1985-01-01", \ "occupation": "Desenvolvedor de Software", \ "motherName": "Salete Cheapetta", \ "pixKeyType": "1", \ "pixKey": "225.465.960-04", \ "contact": { \ "email": "natalia.cheapetta@synapcom.com.br", \ "cellPhone": "(11) 98071-9391" \ }, \ "bankAccounts": [ \ { \ "externalId": "1", \ "document": "225.465.960-04", \ "documentType": "CPF", \ "accountType": "C", \ "bankCode": "001", \ "bankName": "Banco Do Brasil S.A (BB)", \ "agency": "2946", \ "number": "0733-7" \ } \ ], \ "address": { \ "street": "Rua João Longo", \ "number": "1004", \ "neighborhood": "Jandira", \ "complement": "", \ "city": "São Paulo", \ "state": "SP", \ "postalCode": "06608-420" \ } \ }' ``` -------------------------------- ### Register Company Merchant API Request Source: https://dev.tuna.uy/api/split-integration This snippet demonstrates how to register a company merchant using the Tuna API. It includes the necessary POST request, headers for authentication and content type, and a JSON payload with company-specific details. ```curl curl -X 'POST' \ 'https://sandbox.tuna-demo.uy/api/Merchant/Register' \ -H 'accept: application/json' \ -H 'x-tuna-account: demo' \ -H 'x-tuna-apptoken: a3823a59-66bb-49e2-95eb-b47c447ec7a7' \ -H 'Content-Type: application/json' \ -d '{ \ "externalId": "##004", \ "document": "90.920.135/0001-68", \ "documentType": "CNPJ", \ "condition": "1", \ "acceptedContract": true, \ "websiteUrl": "www.synapcom.com.br", \ "registrationDate": "2022-02-15", \ "stateFiscalDocument": "ISENTO", \ "mccCode": "5812", \ "name": "Synacomp Corp.", \ "fantasyName": "Synacomp", \ "pixKeyType": "2", \ "pixKey": "90.920.135/0001-68", \ "contact": { \ "name": "Natalia Cheapetta", \ "email": "natalia.cheapetta@synapcom.com.br", \ "cellPhone": "(11) 98071-9391" \ }, \ "bankAccounts": [ \ { \ "externalId": "1", \ "document": "90.920.135/0001-68", \ "documentType": "CNPJ", \ "accountType": "C", \ "bankCode": "001", \ "bankName": "Banco Do Brasil S.A (BB)", \ "agency": "2946", \ "number": "0733-7" \ } \ ], \ "address": { \ "street": "Rua João Longo", \ "number": "1004", \ "neighborhood": "Jandira", \ "complement": "", \ "city": "São Paulo", \ "state": "SP", \ "postalCode": "06608-420" \ } \ }' ``` -------------------------------- ### Generate Credit Card Token - Tuna API Source: https://dev.tuna.uy/api/payment-integration Generates a credit card token using the Tuna API's /api/Token/Generate endpoint. This is used for new credit card payments and requires a sessionId and card details. ```curl curl -X 'POST'\ 'https://token.tuna-demo.uy/api/Token/Generate'\ -H 'accept: application/json'\ -H 'x-tuna-account: demo'\ -H 'x-tuna-apptoken: a3823a59-66bb-49e2-95eb-b47c447ec7a7'\ -H 'Content-Type: application/json'\ -d '{ "sessionId": "qsTfE2PUGhuncSiaSkFxwJ5vqtsMDrUQsnyM4ZbeTKvx5EJutFovAHEt2/QGjHe61spKmCY8saNoht+VfqTGgxqu2r49ShW2", "card": { "cardHolderName": "Captured", "cardNumber": "4111111111111111", "expirationMonth": 12, "expirationYear": 2023, "cvv": "222", "singleUse": false } }' ``` -------------------------------- ### Initiate Payment Transaction (cURL) Source: https://dev.tuna.uy/api/payment-integration This snippet shows how to initiate a payment transaction using a validated credit card token via the Tuna API's /api/Payment/Init endpoint. It includes customer details, payment items, and card information. ```cURL curl -X 'POST'\ 'https://sandbox.tuna-demo.uy/api/Payment/Init'\ -H 'accept: application/json'\ -H 'x-tuna-account: demo'\ -H 'x-tuna-apptoken: a3823a59-66bb-49e2-95eb-b47c447ec7a7'\ -H 'Content-Type: application/json'\ -d '{\ "tokenSession": "Tqra0uZACXDPFRYlvWExU++QIjhQBnQTSNbvFY6/uLLn31fjqVT6y5jeEwpMzQT/vR6xXxz1AGkDMBj1dtsCfESDolhTolMr+VZNIPO7CsM=",\ "partnerUniqueId": "#000.001",\ "customer": {\ "id": "7",\ "email": "maju.cheapetta@synapcom.com.br",\ "document": "744.479.870-23",\ "documentType": "CPF",\ "name": "Maju Cheapetta"\ },\ "paymentItems": {\ "items": [\ {\ "amount": 20,\"detailUniqueId\": \"A01\",\ "productDescription": "Test product",\ "itemQuantity": 1\ }\n]\n},\"paymentData\": {\"paymentMethods\": [\ {\"paymentMethodType\": \"1\", \"amount\": 20, \"installments\": 1, \"cardInfo\": {\"token\": \"ct_NjJmM2QxOTUtYTM4OS00YmYyLTg4MDAtOTE3YzY1NzM0NmE30\", \"tokenProvider\": \"Tuna\", \"cardHolderName\": \"Captured\", \"expirationMonth\": 12, \"expirationYear\": 2023, \"brandName\": \"Visa\", \"tokenSingleUse\": 0, \"saveCard\": false, \"billingInfo\": {\"document\": \"744.479.870-23\", \"documentType\": \"CPF\" } } }\n],\"deliveryAddress\": {\"street\": \"Rua João Longo\", \"number\": \"1004\", \"neighborhood\": \"Jandira\", \"city\": \"São Paulo\", \"state\": \"SP\", \"postalCode\": \"06608-420\", \"phone\": \"(11) 6536-8864\", \"country\": \"BR\" }, \"countryCode\": \"BR\" }\n}' ``` -------------------------------- ### Split Payment Request - Init API (cURL) Source: https://dev.tuna.uy/api/split-integration This cURL command demonstrates how to make an Init request to the Tuna Payment API, including the 'split' object within 'paymentItems' to specify split payment details for an item. It shows the necessary headers and the JSON payload with customer, payment items, and payment data. ```curl curl -X 'POST' \ 'https://sandbox.tuna-demo.uy/api/Payment/Init' \ -H 'accept: application/json' \ -H 'x-tuna-account: demo' \ -H 'x-tuna-apptoken: a3823a59-66bb-49e2-95eb-b47c447ec7a7' \ -H 'Content-Type: application/json' \ -d '{ \ "tokenSession": "RXD+8UFZiK3nipWGtsXasurjeM5e0vwDkPWYaQR0nco1HankASsxfvFZ99upUq1vbIjeuGFYbby42tLAcpQordpoeOmRb0MJDkFDyQ==", \ "partnerUniqueId": "#040", \ "customer": { \ "id": "7", \ "email": "maju.cheapetta@synapcom.com.br", \ "document": "744.479.870-23", \ "documentType": "CPF", \ "name": "Maju Cheapetta" \ }, \ "paymentItems": { \ "items": [ \ { \ "amount": 20, \ "detailUniqueId": "A01", \ "productDescription": "Test product", \ "itemQuantity": 1, \ "split": { \ "merchantId": "##001" \ } \ } \ ] \ }, \ "paymentData": { \ "paymentMethods": [ \ { \ "paymentMethodType": "1", \ "amount": 20, \ "installments": 1, \ "cardInfo": { \ "token": "ct_NjJmM2QxOTUtYTM4OS00YmYyLTg4MDAtOTE3YzY1NzM0NmE30", \ "tokenProvider": "Tuna", \ "cardHolderName": "Captured", \ "expirationMonth": 12, \ "expirationYear": 2023, \ "brandName": "Visa", \ "tokenSingleUse": 0, \ "saveCard": false, \ "billingInfo": { \ "document": "744.479.870-23", \ "documentType": "CPF" \ } \ } \ } \ ], \ "deliveryAddress": { \ "street": "Rua João Longo", \ "number": "1004", \ "neighborhood": "Jandira", \ "city": "São Paulo", \ "state": "SP", \ "postalCode": "06608-420", \ "phone": "(11) 6536-8864", \ "country": "BR" \ }, \ "countryCode": "BR" \ } \ }' ``` -------------------------------- ### Register Merchant Programmatically - Tuna API Source: https://dev.tuna.uy/api/split-integration This snippet demonstrates how to register a merchant programmatically using the Tuna API. It references the official documentation for the Merchant Registration endpoint and provides links to supporting JSON files for banks, MCC codes, occupations, and error codes. ```text Endpoint: api/Merchant/Register Supporting files: - banks.json - mccCodes.json - occupations.json - srvTunaCodes.json ``` -------------------------------- ### Payment Notification Payload Example Source: https://dev.tuna.uy/api/webhooks-notifications This JSON object represents a typical payload received from the Tuna API for payment notifications. It includes transaction details, payment method information, and itemized product data. ```JSON { "id":104574372, "paymentKey":"134D946015A08C9", "partnerUniqueId":"668ecbaff060e8001162eef6", "statusId":"2", "amount":19.50, "operationId":"O005B134D946015E4CF0", "methods":[ { "methodType":"D", "status":"2", "methodId":0, "operationId":"O005B134D946015E4CF000", "additionalInfo":{ "EndToEndId":"E60701190202407101759DY5BQ4HFISM" }, "operationAmount":19.50 } ], "items":[ { "paymentItemId":0, "productID":1, "productDescription":"841", "amount":19.500000, "quantity":1, "categoryID":1, "categoryName":"Pedido", "data":{ "ProductID":1, "CategoryID":1, "CategoryName":"Pedido", "DetailUniqueID":"668ecbaff060e8001162eef6", "ExternalMerchantId":"65677b704f42a50019188852", "ProductDescription":"841" } } ] } ``` -------------------------------- ### Webhook Notification for Successful Merchant Registration (Tuna PIX) Source: https://dev.tuna.uy/api/split-integration This JSON payload represents a successful merchant registration notification via webhook for Tuna PIX. It includes merchant details, a success code, and a confirmation message from the service. ```json { "merchantId":2, "code":1, "message":{ "source":3, "code":"SRVMerchantRegisterOk", "message":"Service registration done" }, "externalId":"36189", "serviceId":40, "serviceName":"Tuna Split para PIX" } ``` -------------------------------- ### Split Payment Request - Payment Items Object (JSON) Source: https://dev.tuna.uy/api/split-integration This JSON object represents the 'paymentItems' structure for the Tuna Payment API's Init request. It includes an 'items' array where each item can have a 'split' object to define split payment details, such as the 'merchantId'. ```json { "paymentItems":{ "items":[ { "amount":20, "detailUniqueId":"A01", "productDescription":"Test product", "itemQuantity":1, "split":{ "merchantId":"##001" } } ] } } ``` -------------------------------- ### Webhook Notification for Failed Merchant Registration (Tuna Card) Source: https://dev.tuna.uy/api/split-integration This JSON payload illustrates a webhook notification for a failed merchant registration attempt related to Tuna Card. It indicates an error code and a message detailing the registration failure. ```json { "merchantId":2, "code":1, "message":{ "source":3, "code":"SRVMerchantRegisterError", "message":"Service registration error" }, "externalId":"36189", "serviceId":41, "serviceName":"Tuna Split para Cartão" } ``` -------------------------------- ### List Stored Credit Card Tokens (cURL) Source: https://dev.tuna.uy/api/payment-integration This snippet shows how to request a list of stored credit card tokens for a recurring customer using the Tuna API's /api/Token/List endpoint. It requires session ID and specific headers for authentication and content type. ```cURL curl -X 'POST'\ 'https://token.tuna-demo.uy/api/Token/List'\ -H 'accept: application/json'\ -H 'x-tuna-account: demo'\ -H 'x-tuna-apptoken: a3823a59-66bb-49e2-95eb-b47c447ec7a7'\ -H 'Content-Type: application/json'\ -d '{\ "sessionId":"k4cUOKYig2artPWooVru/GoYbQU2Jc1PhbEZtZcnlQqXHO7kLPXAgFhjJJuPsb8DIij/RgNyxx7NpNBhkT6w+CEfzrfjpeyP"\ }' ``` -------------------------------- ### Bind CVV to Stored Credit Card Token (cURL) Source: https://dev.tuna.uy/api/payment-integration This snippet demonstrates how to bind a customer's CVV to a previously obtained credit card token using the Tuna API's /api/Token/Bind endpoint. This is a security step required before processing a payment. ```cURL curl -X 'POST'\ 'https://token.tuna-demo.uy/api/Token/Bind'\ -H 'accept: application/json'\ -H 'x-tuna-account: demo'\ -H 'x-tuna-apptoken: a3823a59-66bb-49e2-95eb-b47c447ec7a7'\ -H 'Content-Type: application/json'\ -d '{\ "sessionId": "qsTfE2PUGhuncSiaSkFxwJ5vqtsMDrUQsnyM4ZbeTKvx5EJutFovAHEt2/QGjHe61spKmCY8saNoht+VfqTGgxqu2r49ShW2",\ "token": "ct_NjJmM2QxOTUtYTM4OS00YmYyLTg4MDAtOTE3YzY1NzM0NmE30",\ "cvv": "222"\ }' ``` -------------------------------- ### Authenticate with Tuna API Headers Source: https://dev.tuna.uy/api/customer Demonstrates the required HTTP headers for authenticating with Tuna APIs, including the account name and app token. These are provided during account signup and can be rotated. ```HTTP "x-tuna-account": "demo" "x-tuna-apptoken": "a3823a59-66bb-49e2-95eb-b47c447ec7a7" ``` -------------------------------- ### Customer Login Request Sample Source: https://dev.tuna.uy/api/customer This JSON payload represents a sample request for customer login. It includes the customer's key (email or phone) and the OTP code sent to them. ```json { "customerKey": { "type": "string", "description": "The key of the customer login. Should be a valid email or phone.", "nullable": false }, "code": { "type": "integer", "description": "The OTP sent to the customer by email or phone", "nullable": false } } ``` -------------------------------- ### Customer Login Response Sample (200 OK) Source: https://dev.tuna.uy/api/customer This JSON payload represents a successful (200 OK) response for a customer login request. It contains a status code, a message, a customer token, and the token's validity period. ```json { "code": { "type": "string", "description": "Numeric code that states if the execution was successful or not. Positive numbers mean success; negative numbers indicate failures. Please refer to the [message code table](/api/tuna-codes#message-code-list) for a detailed list of all possible values.", "nullable": true }, "message": { "type": "string", "description": "A human readable message that gives details about what the code means.", "nullable": true }, "token": { "type": "string", "description": "The customer login token", "nullable": false }, "validUntil": { "type": "datetime", "description": "The token validity date", "nullable": false } } ``` -------------------------------- ### Customer Login Response (200 Success) Source: https://dev.tuna.uy/api/customer Details the JSON response structure for a successful customer login API request. It includes a numeric code, a human-readable message, and the validity period of the OTP in minutes. ```JSON { "code": { "type": "string", "description": "Numeric code that states if the execution was successful or not. Positive numbers mean success; negative numbers indicate failures. Please refer to the [message code table](/api/tuna-codes#message-code-list) for a detailed list of all possible values.", "nullable": true }, "message": { "type": "string", "description": "A human readable message that gives details about what the code means.", "nullable": true }, "passwordValidityInMinutes": { "type": "integer", "description": "The validity time of the OTP sent in minutes.", "nullable": false } } ``` -------------------------------- ### Customer Logout Request Sample Source: https://dev.tuna.uy/api/customer This JSON payload is a sample request for logging out a customer. It requires the customer's key and their active token to invalidate the session. ```json { "customerKey": { "type": "string", "description": "The key of the customer login. Should be a valid email or phone.", "nullable": false }, "token": { "type": "string", "description": "The customer token key", "nullable": false } } ``` -------------------------------- ### Confirm Customer Login Request Payload Source: https://dev.tuna.uy/api/customer Specifies the JSON payload for confirming a customer login. It requires the customer's key and the OTP sent to their contact (email or phone). ```JSON { "customerKey": "string", "otp": "integer" } ``` -------------------------------- ### Customer Logout Response Sample (200 OK) Source: https://dev.tuna.uy/api/customer This JSON payload represents a successful (200 OK) response after a customer logout request. It includes a status code and a message indicating the outcome of the operation. ```json { "code": { "type": "string", "description": "Numeric code that states if the execution was successful or not. Positive numbers mean success; negative numbers indicate failures. Please refer to the [message code table](/api/tuna-codes#message-code-list) for a detailed list of all possible values.", "nullable": true }, "message": { "type": "string", "description": "A human readable message that gives details about what the code means.", "nullable": true } } ``` -------------------------------- ### Customer Login Request Payload Source: https://dev.tuna.uy/api/customer Defines the JSON payload structure for the customer login API endpoint. It includes the customer's key (email or phone) and the login type (0 for email, 1 for SMS). ```JSON { "customerKey": { "type": "string", "description": "The key of the customer login. Should be a valid email or phone.", "nullable": false }, "loginType": { "type": "integer", "description": "The type of login. Use 0 for email and 1 for SMS", "nullable": false } } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.