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
To ensure that your POST requests are handled correctly, follow these steps: Firstly, convert the request body to a string using JSON.stringify(). Then, calculate the x-payload-hash based on this stringified body and pass it on to the x-payload-hash header. Additionally, use the same stringified body while making the POST request and ensure that the HMAC payload is base 64 encoded. It's crucial to examine the sample code carefully to ensure that these steps are implemented correctly. Failing to complete these steps will result in your request being rejected with an error code of errorHmacDoesNotMatch.
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
content-type*
string
application/json
x-api-key*
string
Replace your API key
Request Body
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
You can use this endpoint to fetch a straightforward report for a deposit session token at a later time. It is important to note that customers are not required to query this endpoint immediately after receiving a deposit event notification. This endpoint provides a convenient way to report a deposit session token. When a deposit is made, it triggers a deposit notification, providing all the required information related to the incoming transaction. This notification is designed to give you a clear understanding of the final outcome of the deposit, including the amount of cryptocurrency deposited by your user, the date and time of the blockchain transaction, and all the other essential details. By relying on this notification, you can be confident that you have accurate and up-to-date information about your deposit, and you can take any necessary action based on that information.
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
sessionToken*
string
The session token to be queried
Headers
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?