Skip to main content

Trio Checkout SDK Example

This project demonstrates how to integrate the Trio Checkout SDK using:
  • A local Node.js backend (server.js)
  • A local frontend (index.html)
  • Python HTTP Server for frontend hosting

Requirements

Before starting, make sure you have installed:
  • Node.js (v18+ recommended)
  • npm
  • Python 3

Project Structure


1. Install Backend Dependencies

Create a package.json file:
Install the required dependencies:

2. Configure Credentials

Inside server.js, replace the following values:
With your Trio Sandbox credentials.

3. Run the Backend Server

Start the server using:
You should see:
The backend will now be available at:

4. Run the Frontend Locally

The frontend 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:
The frontend will now be available at:

5. Open the Application

Open your browser and access:

How It Works

  1. The frontend collects:
    • Transaction type
    • CPF
    • Amount
  2. The frontend sends a request to:
  1. The backend creates a Trio Checkout Session using the Trio API.
  2. The backend returns the session_id.
  3. The frontend initializes the Trio SDK:
  1. The checkout modal opens automatically.

Available Transaction Types


Sandbox Environment

This example uses the Trio Sandbox API:

Important Notes

  • Make sure port 3000 is available for the backend.
  • Make sure port 8080 is available for the frontend.
  • CORS is enabled in the backend for local development.
  • Never expose production credentials publicly.

Example Request Payload

Amount must be sent in cents. Example:

Troubleshooting

Port already in use

Change the port in server.js:
And update the frontend request URL if necessary.

Python command not found

Install Python 3 or use:

CORS errors

Ensure the backend server is running before opening the frontend.

Support

For integration support, contact:

Download Example Project

You can download the complete local example project here: Download the ZIP file The ZIP package includes:
  • server.js
  • index.html
  • Local backend example
  • Frontend checkout example
  • SDK integration example