I am trying to integrate Ozow payment method to my bubble.io app and for that first I have to run a javascript code and get an hashcheck code from it. After that I have to pass the hashcheck value to API. So the API will know how much that product cost and know about user profile.
const crypto = require("crypto");
function generateRequestHash() {
const siteCode = "[YOUR SITE CODE]";
const countryCode = "ZA";
const currencyCode = "ZAR";
const amount = 25.01;
const transactionReference = "123";
const bankReference = "ABC123";
const cancelUrl = "http://mydomain.com/cancel.html";
const errorUrl = "http://mydomain.com/error.html";
const successUrl = "http://mydomain.com/success.html";
const notifyUrl = "http://mydomain/notify.html";
const privateKey = "[YOUR PRIVATE KEY]";
const isTest = false;
const inputString = `${siteCode}${countryCode}${currencyCode}${amount}${transactionReference}${bankReference}${cancelUrl}${errorUrl}${successUrl}${notifyUrl}${isTest}${privateKey}`;
const calculatedHashResult = generateRequestHashCheck(inputString);
console.log(`Hashcheck: ${calculatedHashResult}`);
}
function generateRequestHashCheck(inputString) {
const stringToHash = inputString.toLowerCase();
console.log(`Before Hashcheck: ${stringToHash}`);
return getSha512Hash(stringToHash);
}
function getSha512Hash(stringToHash) {
const hash = crypto.createHash("sha512");
hash.update(stringToHash);
return hash.digest("hex");
}
generateRequestHash();
Here is the javascript code but it is not returning me anything. I’m new to bubble so your help will means me a lot. Thank you.