Install the SDK using your favorite package manager
npm install @yosle/tropipayjs
yarn add @yosle/tropipayjs
pnpm install @yosle/tropipayjs
Initialize the Tropipay class
You can instantiate the Tropipay class passing the client_Id
,
client_secret
, scopes
and optionally the serverMode parameter,
if no serverMode is provided, Development
will be used as default.
Make sure you use the test environment credentials when serverMode is on Development
.
// test environment server tropipay-dev.herokuapp.com
const config = {
clientId: process . env . TROPIPAY_CLIENT_ID ,
clientSecret: process . env . TROPIPAY_CLIENT_SECRET ,
scopes: [
" ALLOW_GET_PROFILE_DATA " ,
" ALLOW_PAYMENT_IN " ,
" ALLOW_EXTERNAL_CHARGE " ,
" KYC3_FULL_ALLOW " ,
" ALLOW_GET_BALANCE " ,
" ALLOW_GET_MOVEMENT_LIST " ,
] ,
serverMode: " Development " , // it will be used as default if omited
} ;
const tpp = new Tropipay ( config );
Using Production environment:
//real account credentials
const config = {
clientId: process . env . TROPIPAY_CLIENT_ID ,
clientSecret: process . env . TROPIPAY_CLIENT_SECRET ,
// Optionally you can request wich scopes of the credential are you gonna use.
// this should be a subset of the scopes marked for this credential.
// trying to use a scope that is not set for the credential will throw error
// on authentication. Note: if no scopes array is passed ALL scopes are requested!
scopes: [
' ALLOW_GET_PROFILE_DATA ' ,
' ALLOW_PAYMENT_IN ' ,
' ALLOW_EXTERNAL_CHARGE ' ,
' KYC3_FULL_ALLOW ' ,
' ALLOW_GET_BALANCE ' ,
' ALLOW_GET_MOVEMENT_LIST ' ]
serverMode : " Production " , //live account
} ;
const tpp = new Tropipay ( config );
Important
The Tropipay instance, allows you to access all the method available in the API.
This Object is meant to be used only in server side.
Do not use the Tropipay object on the client side (browser).
This would expose your app credentials (the client secret of your account).
You can create an endpoint at your back-end using express and consume it in your front-end,
or use SSR if you’re using NextJS.