#
API Guide#
Table of Contents- Introduction
- Payment Integration
- Split Integration
- Tuna Codes
- Webhooks Notifications
- Sandbox Environment
- Idempotent Requests
#
Payment IntegrationTo perform credit card payments or have a significant integration with multiple payments methods at Tuna, you will need first to use our api/Token endpoint. The api/Token endpoint is responsible for creating a unique session for your user at Tuna and the tokenization process of credit card data following Payment Card Industry Data Security Standard ("PCI DSS").
There are three steps in performing a payment transaction. They are as follows:
- Setp 1: Start a new session for your customer.
- Setp 2: Create a valid credit card token. This process can be done in two ways:
- using a new credit card;
- using a stored credit card (from previous sessions).
- Step 3: Request for the Payment
Then, you will be able to request a payment transaction at Tuna's api/Payment/Init endpoint.
This page shows how to perform these steps using Tuna's Sandbox Environment.
Let's start it out.
Frontend or Backend!?
All requests for Tuna serves must come from a backend application due to security reasons with your production keys. Thus, if a request is handling data that comes from your frontend application, your frontend must request for your backend to communicate with Tuna servers. Finally, your backend will handle the response and pass the result to your frontend.
#
Step 1: Start a new session for your customerIn this step, the request is for the endpoint api/Token/NewSession. If you need more information about this endpoint, check it out here.
You can do this step only at the checkout page.
- Request
- Response
#
Step 2: Create a valid credit card tokenThere are two ways to create a valid credit card token:
#
Using a New Credit CardWhen you have a new customer, it is the first the credit card is going to be used. So, you need to create the token for the credit card. This is done through the endpoint api/Token/Generate. The exemplary request and response is shown bellow:
- Request
- Response
#
Using a Stored Credit CardIf you have a recurring customer, you can ask Tuna for stored credit card tokens. This is performed by making a request for the endpoint api/Token/List, which will respond with a list of available tokens. Then, at your frontend, the customer will select a credit card and confirm its CVV for security reasons. After the confirmation, a request for the api/Token/Bind endpoint is required to validate the token with its CVV. Now, please, check out the examples that follow.
Exemplary request and response for the api/Token/List endpoint
- Request
- Response
Exemplary request and response for the api/Token/Bind endpoint
- Request
- Response
#
Step 3: Request for the PaymentOnce the tokenization process is successful, you can request the payment transaction, which is performed through the endpoint api/Payment/Init.
Examples for all payment methods
Check the documentation of the api/Payment/Init endpoint and look for more examples on the right side of the page. You will find examples of requests and responses for Boleto, PIX, Bitcoin, Split, Gift Card, and much more.
Here is shown a request and response for a credit card transaction:
- Request
- Response
#
ResourcesAPI Guide: are you looking for a guide for our APIs? Check out the introduction to the API Guide.
Payment Integration: do you need to be able to perform secure credit card payments and/or also use other payment methods such as Debit Card, Boleto, PIX, Bitcoin? Checkout how to perform a Payment Integration with our Payment API and Token API.
Split Integration: are you looking to set up a marketplace, so your merchants will use split payment solutions in your marketplace? Check out how to perform a Split Integration with our Merchant API.
Tuna Codes: do you need to learn about your codes and status? Please, check out the Tuna Codes.
Webhooks Notifications: learn more about our notifications in the guide Webhooks Notifications.
Sandbox Environment: check out for information about test data and a full description of the Sandbox Environment.
Idempotent Requests: do you require idempotent requests? Take a look how to make Idempotent Requests.