btcpayserver/BTCPayServer/wwwroot/checkout/coinswitch.html
2018-12-18 20:00:30 +01:00

86 lines
2.6 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CoinSwitch</title>
<script>
var script = document.createElement('script'),
head = document.head || document.getElementsByTagName('head')[0];
script.src = window.location.protocol + '//files.coinswitch.co/public/js/cs_switch.js';
head.insertBefore(script, head.firstChild);
script.addEventListener('load', function () {
var qs = (function (a) {
if (a == "") return {};
var b = {};
for (var i = 0; i < a.length; ++i) {
var p = a[i].split('=', 2);
if (p.length == 1)
b[p[0]] = "";
else
b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
}
return b;
})(window.location.search.substr(1).split('&'));
var merchantId = qs["merchant_id"];
var toCurrencyDue = qs["toCurrencyDue"];
var toCurrencyAddress = qs["toCurrencyAddress"];
var toCurrency = qs["toCurrency"];
var payment = new Coinswitch(merchantId);
var config = {
to_currency: toCurrency,
to_currency_address: toCurrencyAddress,
to_amount: toCurrencyDue
};
waitForCoinSwitch();
function waitForCoinSwitch() {
if (typeof payment.open !== "function") {
setTimeout(waitForCoinSwitch, 1000);
return;
}
payment.open(config);
payment.on("Exchange:Complete", function () {
window.close();
});
payment.on("Exchange:Closed", function () {
window.close();
})
}
});
</script>
<style>
#CoinSwitchPayment .cs-pay {
width: 100%;
height: 100%;
}
#CoinSwitchPayment .cs-pay__main {
width: 100%;
height: 100%;
padding-bottom: 20px;
}
#CoinSwitchPayment .cs-pay__dismiss-row {
display: none;
}
#CoinSwitchPayment .cs-pay__footer {
position: absolute;
left: 0;
bottom: 0px;
width: 100%;
height: 20px;
z-index: 10001;
}
#CoinSwitchPayment .cs-pay__powered-text {
color: black;
}
</style>
</head>
<body>
</body>
</html>