purchaseProductIdEvery time when the user makes withdrawal, Enabl3 will send callback request to the Application backend with details.
You need to create POST endpoint on your backend side, which will be requested by Enabl3.
{
"userId": "14813ccc-83b6-11ee-b962-0242ac120002",
"optionId": "97cf7320-25f0-485d-a2c9-2ae60c05574e",
"purchaseProductId": "product123",
"amount": 100.00,
"tokenAmount": 500.00,
"tokenRate": 5.0,
"transactionId": "709a45bd-2b9a-452d-9ae2-a9aa479c29e6",
"createdAt" : "2024-05-30T12:14:40.988257"
}
public String getSignature(String requestBody, String secret) {
String md5Hex = DigestUtils.md5Hex(requestBody);
try {
Mac shaHMAC = Mac.getInstance("HmacSHA512");
SecretKeySpec secretKey = new SecretKeySpec(secret.getBytes(), "HmacSHA512");
shaHMAC.init(secretKey);
return Base64.getEncoder().encodeToString(shaHMAC.doFinal(md5Hex.getBytes()));
} catch (GeneralSecurityException ex) {
log.error(ex.getMessage(), ex);
throw new RuntimeException("Request signing error", ex);
}
}
const crypto = require('crypto');
function getSignature(requestBody, secret) {
const md5Hex = crypto.createHash('md5').update(requestBody).digest('hex');
const hmac = crypto.createHmac('sha512', secret);
const signature = hmac.update(md5Hex).digest('base64');
return signature;
}
const requestBody = 'your_request_body';
const secret = 'your_secret_key';
const signature = getSignature(requestBody, secret);
console.log(signature);