Integration Processing mint requests The typical flow to process mint requests from your user
Using a user account's API key, you can process mint requests for the specified user. To do so, you can use the POST /api/transaction/mint-request
endpoint. Here is an example implementation.
Copy import { createSignature } from "./createSignature";
const axios = require('axios');
const apiKey = "{YOUR API KEY}";
const secret = "{YOUR SECRET}";
async function mintRequest() {
const path = "https://idrx.co/api/transaction/mint-request";
const req = {
"toBeMinted" : "51500",
"destinationWalletAddress" : "0x8BD53F7fF88fD895D3686fe6369a07432822d30F",
"expiryPeriod" : 3600, // 1 hour
"networkChainId" : "137", // Polygon
"requestType" : "idrx", // 'idrx' or empty to receive IDRX, 'usdt' to receive USDT
};
const bufferReq = Buffer.from(JSON.stringify(req), 'base64').toString('utf8');
const timestamp = Math.round((new Date()).getTime()).toString();
const sig = createSignature('POST', path, bufferReq, timestamp, secret);
const res = await axios.post(path, req, {
headers: {
'Content-Type': 'application/json',
'idrx-api-key': apiKey,
'idrx-api-sig': sig,
},
});
console.log('res.data: ');
console.log(res.data);
}
mintRequest();
After a successful request, you will get a response as follows:
Copy {
statusCode: 200,
message: 'success',
data: {
merchantCode: 'D11808',
reference: 'D11808T8GVTL81VV2U7HV',
paymentUrl: 'https://app-prod.duitku.com/redirect_checkout?reference=D11808T8GVTL81VV2U7HV',
amount: '54500.00',
statusCode: '00',
statusMessage: 'SUCCESS',
merchantOrderId: '20231219101707'
}
}
Note that the amount returned is the amount after fees. The user can then do the payment through the payment page in the paymentUrl
. To check the status of the transaction, you can use the Transaction History API . Here is an example code to do so:
Copy import { createSignature } from "./createSignature";
const axios = require('axios');
const apiKey = "{YOUR API KEY}";
const secret = "{YOUR SECRET}";
async function transactionHistory(txType) {
const path = "https://idrx.co/api/transaction/user-transaction-history?transactionType="+txType+"&page=1&take=10";
const bufferReq = Buffer.from('', 'base64').toString('utf8');
const timestamp = Math.round((new Date()).getTime()).toString();
const sig = createSignature('GET', path, bufferReq, timestamp, secret);
const res = await axios.get(path, {
headers: {
'Content-Type': 'application/json',
'idrx-api-key': apiKey,
'idrx-api-sig': sig,
},
});
console.log('res.data: ');
console.log(res.data);
}
transactionHistory('MINT');
The response as follows:
Copy {
statusCode: 200,
message: 'success',
metadata: { page: 1, perPage: 10, pageCount: 1, totalCount: 1 },
records: [
{
id: 311,
paymentAmount: 54500,
merchantOrderId: '20231219101707',
productDetails: 'Minting IDRX',
customerVaName: 'JOHN SMITH',
email: 'john.smith@gmail.com;IDRX',
minted: false,
deleted: false,
chainId: 137,
destinationWalletAddress: '0x8BD53F7fF88fD895D3686fe6369a07432822d30F',
toBeMinted: '51500',
merchantUserInfo: 411,
createdAt: '2023-12-19T10:17:07.903Z',
updatedAt: '2023-12-19T10:17:07.903Z',
paymentStatus: 'WAITING_FOR_PAYMENT',
expiryTimestamp: '1703197027900',
reference: 'D11808T8GVTL81VV2U7HV',
txHash: null,
qredoTxId: null,
signedTx: null,
adminMintStatus: 'REQUESTED',
userMintStatus: 'NOT_AVAILABLE',
isApproved: false,
reportStatus: 'NONE',
requestType: '',
refundStatus: null
}
]
}
After a successful payment, IDRX tokens will be minted to the specified wallet address.
Next, we will explore on processing redeem requests.
Last updated 5 months ago