Call the function below to display the electronic cash balance.
SCRIPT
function readBalance() {
_uz.api.contentWindow.postMessage({
action: "ecash-api-read-balance"
}, _uz.api.src);
};
Add post message listener to get returned electronic cash balance.
SCRIPT
window.addEventListener("message", windowEvent);
windowEvent function (e) {
if (e.type.match(/(message)/)) try {
_uz.session = !_uz.session ? e.data.session : _uz.session;
if (e.data.action && e.data.action.match(/(ecash-api)/)) {
if (e.data.action && e.data.action.match(/(response)/)) {
if (data.action && data.action.match(/(read-balance)/)) {
document.querySelector("balance-display").innerHTML = data.balance;
};
};
};
} catch (error) {};
};
Add element to display the electronic cash balance.
HTML
<div id="balance-display"></div>