server.js), a local front end (index.html) and a Python HTTP server to host the front end. It runs against the sandbox API at https://api.sandbox.trio.com.br.
Requirements
Before starting, make sure you have installed:- Node.js (v18 or later recommended)
- npm
- Python 3
Project structure
server.js, index.html, the local back end, the front end checkout and the SDK integration.
Run the example
1
Install the back end dependencies
Create a
package.json file and install the required dependencies:2
Configure your credentials
Inside
server.js, replace the following values with your Trio sandbox credentials:3
Run the back end server
http://localhost:3000.4
Run the front end locally
The front end uses the browser SDK and must be served through an HTTP server. Open a new terminal in the project folder and run:If
python3 does not work, try python -m http.server 8080. The front end is now available at http://localhost:8080.5
Open the application
Open
http://localhost:8080 in your browser.How it works
- The front end collects the transaction type, the CPF and the amount.
-
The front end sends a request to
POST http://localhost:3000/create-session. - The back end creates a Trio Checkout session using the Trio API.
-
The back end returns the
session_id. -
The front end initializes the Trio SDK:
- The checkout modal opens automatically.
payin and payout. The front end sends a payload like this one to the back end:
amount is in cents (BRL 150.00 = 15000).
Make sure ports
3000 (back end) and 8080 (front end) are available. CORS is enabled in the back end for local development. Never expose production credentials publicly.Troubleshooting
Port already in use
Change the port inserver.js and update the front end request URL if necessary:
Python command not found
Install Python 3, or run the server withpython3 -m http.server 8080.
CORS errors
Make sure the back end server is running before you open the front end.Next steps
- Using the SDK: what each step of the example does.
- PayIn flow and PayOut flow: the full session payloads.
- Support: contact Trio for integration support.

