- You have created your API credentials in the Trio App (see Creating your first API credential) and have the
client_idandclient_secretof your company, in the sandbox or in production. - You have read how to create a checkout session in the Initiation API reference.
1
Embed the SDK
Add the SDK through a If you have a mobile application, you can embed the same tag in a WebView inside your application.
script tag just before the closing </head> tag of your HTML:2
Create a payment session
All payment information is sensitive, so the data the front end will use is prepared in your back end beforehand. To use the SDK you create a session, which represents an instance of a transaction inside Trio’s front end application. Every session is created with a payload, and the payload varies with the type of session.The field
options.session_type defines which type is created and must be one of the four available: payin, payout, guest_onboarding or user_onboarding. To learn about each type, its use cases and how to create a session for it, see:After creating a session, save the id it returns: you need it to instantiate the SDK interface. When its expiration time ends, the session expires automatically and cannot be used again.3
Create a new instance of the SDK
With the session
id in hand and the SDK installed, you have access to a module called Trio in the browser. It has two primary functions:create()prepares the information to be sent to your back end;open()pops up the user experience for the end user, so the transaction can be completed.
Trio.create() takes an object with the following properties.4
Open the checkout
Once you have everything needed to initiate a payment, call Then open it by running
Trio.create() and then Trio.open():Trio.open():5
Get information about the transactions
Every payment processed by Trio generates a document: an in document for a PayIn and an out document for a PayOut. You can handle the transactions through the
onEvent callback or by receiving the webhook events of the document.You can also open the documents in the Trio App:Next steps
- PayIn flow: the session payload to receive money.
- PayOut flow: the session payload to pay a user.
- Local example: a runnable back end and front end.
- Webhooks: receive the document events instead of polling.

