Deposit Tracking Session

A Sample Code For Creating A Deposit Tracking Session

Below, you can find an example of how to create a deposit tracking session using TypeScript code. With our infrastructure, customers can keep track of deposits made and monitor the status of each deposit as it progresses through various stages. Start your journey by creating a deposit session.

import {createHmac} from 'crypto';

const hmacSecretKey = 'YOUR HMAC SECRET Key';
const xApiKey = 'YOUR API KEY'

const payloadPgCreateSessionForAUser = {
    userId: 'YOUR_UNIQUE_USER_ID',
    userName: 'YOUR_USER_NAME',
    userNameSurname: 'THE_NAME_AND_SURNAME_OF_YOUR_USER',
    sessionDefaultLanguage: 'en',
    sessionDefaultFiatCurrency: 'USD',
    minPaymentAmountInUSD: 0.5
};

const body = JSON.stringify(payloadPgCreateSessionForAUser);
const xPayloadHash = createHmac('sha512', hmacSecretKey).update(body)
                .digest('base64');

try {
    const sessionCreationResult = await axios.post(
        'https://api-prod.alfa-instap-cpt.uk/pgpub/session', body,
        {
            timeout: 6000,
            headers: {
                "content-type": "application/json",
                "x-api-key": xApiKey,
                "x-payload-hash": xPayloadHash,
            }
        }
    );
    console.log(sessionCreationResult.data);
} catch (error) {
    console.log(error);
    throw new Error('Session creation failed');

}

Creating A Deposit Tracking Session API Endpoint

POST https://api-prod.alfa-instap-cpt.uk/pgpub/session

Session Token and Operation No mean the same thing for our system. Before tracking deposits for your users, you need to create a deposit tracking session. The system associates this session with a session token. The system manages session tokens.

Headers

Name
Type
Description

content-type*

string

application/json

x-api-key*

string

Replace your API key

x-payload-hash*

string

Replace your calculated HMAC hash. See API Security.

Request Body

Name
Type
Description

userId*

string

STRING [Min 1,Max 4000] Characters The userId field is your user's unique Id. The system uses this parameter to track deposit events, and it distinguishes deposit sessions using this parameter. userId parameter must be unique within the customer's infrastructure.

userName*

string

STRING [Min 1,Max 4000] Characters This parameter is for display only, and the system does not use this parameter while tracking deposit events.

userNameSurname

string

STRING [Min 1,Max 4000] Characters This parameter is for display only, and the system does not use this parameter while tracking deposit events.

userEmail

string

STRING [Min 1,Max 4000] Characters This parameter is for display only, and the system does not use this parameter while tracking deposit events.

maxPaymentAmountInUSD

number

NUMBER The system uses this parameter to set the state of the deposit. The state of the deposit can be overpaid, underpaid or correct.

This parameter can not be less than zero or smaller than minPaymentAmountInUSD.

The default value of this parameter is 5000$.

minPaymentAmountInUSD

number

NUMBER The system uses this parameter to set the state of the deposit. The state of the deposit can be overpaid, underpaid or correct.

This parameter can not be less than zero or bigger than maxPaymentAmountInUSD.

If the customer sets this parameter, the system initializes the minimum payment for this amount. If the customer bypasses this parameter, the system uses the system's default which is 10$.

sessionDefaultFiatCurrency

string

STRING 3 Characters If the customer sets this parameter, the system initializes the session for this fiat currency. If the customer bypasses this parameter, the system selects USD as the initial currency of the session. Your users can change this parameter during the checkout process, and the client code of the checkout page will make the necessary conversions. Possible values are USD,EUR,GBP ,KRW, BRL and TRY.

sessionDefaultLanguage

string

STRING 2 Characters The system activates the checkout page for this language. If not present, the checkout page will use the system's default session language.

redirectUrl

string

Upon completion of the deposit tracking session, this field specifies the exact web address to which the user will be automatically redirected. The URL provided should be accessible and lead to the appropriate destination for a seamless user experience.

The system successfully creates the deposit tracking session.

{
    "sessionToken": "Operation No",
    "checkOutUrl": "Redirect URL of your user's checkout page"
}

Querying The Deposit Tracking Session API Endpoint

GET https://api-prod.alfa-instap-cpt.uk/pgpub/session/{sessionToken}

One can learn about the state of the deposit tracking session using this endpoint.

Query Parameters

Name
Type
Description

sessionToken*

string

The session token to be queried

Headers

Name
Type
Description

content-type*

string

application/json

x-api-key*

string

Replace your API key

{
    "sessionState": "The state of the session",
    "checkOutUrl": "The checkout page of the session"
}

The status of the session will be one of the following.

NEW: This state means the system successfully creates a new payment gateway session.

COMPLETED: This state indicates that the system detects a completed blockchain transaction.

EXPIRED: This state means that the payment gateway session has expired without any deposit event.

FAILED: This state suggests the system abnormally terminated the payment gateway session. It can only occur if the system does not push the event to our event source.

Last updated

Was this helpful?