- Make sure you have created your API Keys through our console (API Keys page), and the
client_idandclient_secretthat belongs to your company from either in a sandbox or production environment. - Read the API Reference on how to create a Checkout Session.
1. Embed the SDK
First, you need to embed our SDK through ascript tag just before the closing of the <head> tag in your HTML:
2. Create a payment session
Since all payment information is sensitive, we allow ourselves to handle information that will be used in the front-end in the back-end beforehand. In order to use the SDK, then, we offer the creation of a session, which represents an instance of a transaction inside our front-end application. All sessions must be created with a payload, and the payload will vary depending on the type of session you want to create.The field “options.session_type” defines which type will be created, and must be one of the four available “pay in”, “payout”, “guest_onboarding”, “user_onboarding”. To understand more about each type, its use cases and how to create a session for each one, please follow the links below: After creating a session, make sure that you saved the
id returned. It will be necessary in order to instance the SDK interface. After the expiration time ends, a created session automatically expires, and cannot be used again.
📘Be wary
A session must always be generated inside the back-end of your application, for security reasons. Generating it inside your front-end may expose your client_secret, making it interceptable by your end-users.
3. Create a new instance of the SDK
With thesession_id in hand and the SDK installed, you have access to a module called Trio in the browser console. This module has 2 primary functions:
create(), which is responsible for preparing the information to be sent to your backendopen(), which pops up the user experience for the final user, so the transaction can be completed.
Trio.create, which requires an object as parameter that must contain such information:
Environment
A property defining the environment:
onSuccess: is triggered when a payment is completed successfully. The data object is returned, containing information about the created payment.onExit: is triggered when the Trio Checkout is closed by the end-user.onEvent: is triggered after each event during the initiation flow. Allows for more fine-grained control of event, such as failures and secondary events.onLoad: is triggered when the SDK Bridge is successfully initialized (through theTrio.create()function).
4. Open checkout
Once you have prepared all the necessary information to initiate a payment, use the functionsTrio.create() and Trio.open():
Trio.open()
5. Getting information about transactions
Every payment processed by Trio will generate a new document. You can handle the transactions either by dealing with theonEvent callback, or by receiving webhooks for the document:
You can also access the documents inside our Dashboard:
- In Sandbox:
- Pay-in -
app.sandbox.trio.com.br/documents/in/{document_id} - Payout -
app.sandbox.trio.com.br/documents/out/{document_id}
- Pay-in -
- In Production
- Pay-in -
app.trio.com.br/documents/in/{document_id} - Payout -
app.trio.com.br/documents/out/{document_id}
- Pay-in -

