diff --git a/BTCPayServer/Controllers/InvoiceController.UI.cs b/BTCPayServer/Controllers/InvoiceController.UI.cs index f90f93a5e..be4764024 100644 --- a/BTCPayServer/Controllers/InvoiceController.UI.cs +++ b/BTCPayServer/Controllers/InvoiceController.UI.cs @@ -317,6 +317,7 @@ namespace BTCPayServer.Controllers ChangellyAmountDue = changellyAmountDue, CoinSwitchEnabled = coinswitch != null, CoinSwitchMerchantId = coinswitch?.MerchantId, + CoinSwitchMode = coinswitch?.Mode, StoreId = store.Id, AvailableCryptos = invoice.GetPaymentMethods(_NetworkProvider) .Where(i => i.Network != null) diff --git a/BTCPayServer/Controllers/StoresController.CoinSwitch.cs b/BTCPayServer/Controllers/StoresController.CoinSwitch.cs index d60c721e7..1e2ace825 100644 --- a/BTCPayServer/Controllers/StoresController.CoinSwitch.cs +++ b/BTCPayServer/Controllers/StoresController.CoinSwitch.cs @@ -27,6 +27,7 @@ namespace BTCPayServer.Controllers if (existing == null) return; vm.MerchantId = existing.MerchantId; vm.Enabled = existing.Enabled; + vm.Mode = existing.Mode; } [HttpPost] @@ -48,7 +49,8 @@ namespace BTCPayServer.Controllers var coinSwitchSettings = new CoinSwitchSettings() { MerchantId = vm.MerchantId, - Enabled = vm.Enabled + Enabled = vm.Enabled, + Mode = vm.Mode }; switch (command) diff --git a/BTCPayServer/Models/InvoicingModels/PaymentModel.cs b/BTCPayServer/Models/InvoicingModels/PaymentModel.cs index 76e86ac40..6979b777c 100644 --- a/BTCPayServer/Models/InvoicingModels/PaymentModel.cs +++ b/BTCPayServer/Models/InvoicingModels/PaymentModel.cs @@ -63,6 +63,7 @@ namespace BTCPayServer.Models.InvoicingModels public decimal? ChangellyAmountDue { get; set; } public bool CoinSwitchEnabled { get; set; } + public string CoinSwitchMode { get; set; } public string CoinSwitchMerchantId { get; set; } } } diff --git a/BTCPayServer/Models/StoreViewModels/UpdateCoinSwitchSettingsViewModel.cs b/BTCPayServer/Models/StoreViewModels/UpdateCoinSwitchSettingsViewModel.cs index de534df83..12e92a9d4 100644 --- a/BTCPayServer/Models/StoreViewModels/UpdateCoinSwitchSettingsViewModel.cs +++ b/BTCPayServer/Models/StoreViewModels/UpdateCoinSwitchSettingsViewModel.cs @@ -1,4 +1,7 @@ +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using BTCPayServer.Payments.CoinSwitch; +using Microsoft.AspNetCore.Mvc.Rendering; namespace BTCPayServer.Models.StoreViewModels { @@ -7,6 +10,15 @@ namespace BTCPayServer.Models.StoreViewModels public string MerchantId { get; set; } public bool Enabled { get; set; } + [Display(Name = "Mode, Choose how to show CoinSwitch")] + public string Mode { get; set; } = "popup"; + + public List Modes { get; } = new List + { + new SelectListItem { Value = "popup", Text = "Open in a popup" }, + new SelectListItem { Value = "inline", Text = "Embed inside Checkout UI " }, + }; + public string StatusMessage { get; set; } } } diff --git a/BTCPayServer/Payments/Coinswitch/CoinswitchSettings.cs b/BTCPayServer/Payments/Coinswitch/CoinswitchSettings.cs index 7ffc8ca19..7a4eba1c1 100644 --- a/BTCPayServer/Payments/Coinswitch/CoinswitchSettings.cs +++ b/BTCPayServer/Payments/Coinswitch/CoinswitchSettings.cs @@ -3,7 +3,7 @@ namespace BTCPayServer.Payments.CoinSwitch public class CoinSwitchSettings { public string MerchantId { get; set; } - + public string Mode { get; set; } public bool Enabled { get; set; } public bool IsConfigured() diff --git a/BTCPayServer/Views/Invoice/Checkout-Body.cshtml b/BTCPayServer/Views/Invoice/Checkout-Body.cshtml index 4895fe985..1c7d09ab7 100644 --- a/BTCPayServer/Views/Invoice/Checkout-Body.cshtml +++ b/BTCPayServer/Views/Invoice/Checkout-Body.cshtml @@ -292,12 +292,15 @@ { - + + {{$t("Pay with CoinSwitch")}} @@ -307,7 +310,8 @@ +
+ + +
diff --git a/BTCPayServer/wwwroot/checkout/coinswitch.html b/BTCPayServer/wwwroot/checkout/coinswitch.html index 3b8cfe79c..9bae2e697 100644 --- a/BTCPayServer/wwwroot/checkout/coinswitch.html +++ b/BTCPayServer/wwwroot/checkout/coinswitch.html @@ -33,8 +33,11 @@ + - - +sdasd diff --git a/BTCPayServer/wwwroot/checkout/js/coinswitchComponent.js b/BTCPayServer/wwwroot/checkout/js/coinswitchComponent.js index 824e5f1fe..338692206 100644 --- a/BTCPayServer/wwwroot/checkout/js/coinswitchComponent.js +++ b/BTCPayServer/wwwroot/checkout/js/coinswitchComponent.js @@ -1,6 +1,6 @@ var CoinSwitchComponent = { - props: ["toCurrency", "toCurrencyDue", "toCurrencyAddress", "merchantId", "autoload"], + props: ["toCurrency", "toCurrencyDue", "toCurrencyAddress", "merchantId", "autoload", "mode"], data: function () { }, computed: { @@ -31,8 +31,8 @@ } }, mounted: function () { - if(this.autoload){ + if(this.autoload && this.mode === 'popup'){ this.openDialog(); } - }, + } };