diff --git a/BTCPayServer/Views/Invoice/Checkout-Body.cshtml b/BTCPayServer/Views/Invoice/Checkout-Body.cshtml index e9c046c45..307bddabb 100644 --- a/BTCPayServer/Views/Invoice/Checkout-Body.cshtml +++ b/BTCPayServer/Views/Invoice/Checkout-Body.cshtml @@ -298,11 +298,20 @@ :to-currency-due="srvModel.btcDue" :autoload="selectedThirdPartyProcessor === 'coinswitch'" :to-currency-address="srvModel.btcAddress"> - - +
+ {{$t("Pay with CoinSwitch")}} + + + +
+ } diff --git a/BTCPayServer/wwwroot/checkout/coinswitch.html b/BTCPayServer/wwwroot/checkout/coinswitch.html index e9dd6e509..224a9961c 100644 --- a/BTCPayServer/wwwroot/checkout/coinswitch.html +++ b/BTCPayServer/wwwroot/checkout/coinswitch.html @@ -4,7 +4,6 @@ CoinSwitch diff --git a/BTCPayServer/wwwroot/checkout/js/coinswitchComponent.js b/BTCPayServer/wwwroot/checkout/js/coinswitchComponent.js index 338692206..8503563be 100644 --- a/BTCPayServer/wwwroot/checkout/js/coinswitchComponent.js +++ b/BTCPayServer/wwwroot/checkout/js/coinswitchComponent.js @@ -2,8 +2,14 @@ { props: ["toCurrency", "toCurrencyDue", "toCurrencyAddress", "merchantId", "autoload", "mode"], data: function () { + return { + opened: false + }; }, computed: { + showInlineIFrame: function(){ + return this.url && this.opened; + }, url: function () { return window.location.origin + "/checkout/coinswitch.html?" + "&toCurrency=" + @@ -12,6 +18,8 @@ this.toCurrencyAddress + "&toCurrencyDue=" + this.toCurrencyDue + + "&mode=" + + this.mode + (this.merchantId ? "&merchant_id=" + this.merchantId : ""); } }, @@ -21,17 +29,37 @@ e.preventDefault(); } - var coinSwitchWindow = window.open( - this.url, - 'CoinSwitch', - 'width=600,height=470,toolbar=0,menubar=0,location=0,status=1,scrollbars=1,resizable=0,left=0,top=0'); - coinSwitchWindow.opener = null; - coinSwitchWindow.focus(); - + if(this.mode === 'inline'){ + this.opened = true; + + }else if(this.mode ==="popup"){ + var coinSwitchWindow = window.open( + this.url, + 'CoinSwitch', + 'width=360,height=650,toolbar=0,menubar=0,location=0,status=1,scrollbars=1,resizable=0,left=0,top=0'); + coinSwitchWindow.opener = null; + coinSwitchWindow.focus(); + } + }, + closeDialog(){ + if(this.mode === 'inline'){ + this.opened = false; + } + }, + onLoadIframe(event){ + $("#prettydropdown-DefaultLang").hide(); + var c = this.closeDialog.bind(this); + event.currentTarget.contentWindow.addEventListener("message", function(evt){ + if(evt && evt.data == "popup-closed"){ + c(); + + $("#prettydropdown-DefaultLang").show(); + } + }); } }, mounted: function () { - if(this.autoload && this.mode === 'popup'){ + if(this.autoload){ this.openDialog(); } }