From 6db9061dd10e2393be3c8d372938c2c0258e973b Mon Sep 17 00:00:00 2001 From: Kukks Date: Sun, 31 Mar 2019 18:55:14 +0200 Subject: [PATCH] add coinswitch shitcoin tax --- BTCPayServer/Controllers/InvoiceController.UI.cs | 1 + BTCPayServer/Controllers/StoresController.CoinSwitch.cs | 4 +++- BTCPayServer/Models/InvoicingModels/PaymentModel.cs | 1 + .../StoreViewModels/UpdateCoinSwitchSettingsViewModel.cs | 6 ++++++ BTCPayServer/Payments/Coinswitch/CoinswitchSettings.cs | 1 + BTCPayServer/Views/Invoice/Checkout-Body.cshtml | 2 +- BTCPayServer/Views/Stores/UpdateCoinSwitchSettings.cshtml | 6 +++++- 7 files changed, 18 insertions(+), 3 deletions(-) diff --git a/BTCPayServer/Controllers/InvoiceController.UI.cs b/BTCPayServer/Controllers/InvoiceController.UI.cs index 528881249..bd7ee438c 100644 --- a/BTCPayServer/Controllers/InvoiceController.UI.cs +++ b/BTCPayServer/Controllers/InvoiceController.UI.cs @@ -316,6 +316,7 @@ namespace BTCPayServer.Controllers ChangellyMerchantId = changelly?.ChangellyMerchantId, ChangellyAmountDue = changellyAmountDue, CoinSwitchEnabled = coinswitch != null, + CoinSwitchAmountMarkupPercentage = coinswitch?.AmountMarkupPercentage?? 0, CoinSwitchMerchantId = coinswitch?.MerchantId, CoinSwitchMode = coinswitch?.Mode, StoreId = store.Id, diff --git a/BTCPayServer/Controllers/StoresController.CoinSwitch.cs b/BTCPayServer/Controllers/StoresController.CoinSwitch.cs index 1e2ace825..d793c06ab 100644 --- a/BTCPayServer/Controllers/StoresController.CoinSwitch.cs +++ b/BTCPayServer/Controllers/StoresController.CoinSwitch.cs @@ -28,6 +28,7 @@ namespace BTCPayServer.Controllers vm.MerchantId = existing.MerchantId; vm.Enabled = existing.Enabled; vm.Mode = existing.Mode; + vm.AmountMarkupPercentage = existing.AmountMarkupPercentage; } [HttpPost] @@ -50,7 +51,8 @@ namespace BTCPayServer.Controllers { MerchantId = vm.MerchantId, Enabled = vm.Enabled, - Mode = vm.Mode + Mode = vm.Mode, + AmountMarkupPercentage = vm.AmountMarkupPercentage }; switch (command) diff --git a/BTCPayServer/Models/InvoicingModels/PaymentModel.cs b/BTCPayServer/Models/InvoicingModels/PaymentModel.cs index 71f45826c..e324da2a2 100644 --- a/BTCPayServer/Models/InvoicingModels/PaymentModel.cs +++ b/BTCPayServer/Models/InvoicingModels/PaymentModel.cs @@ -66,5 +66,6 @@ namespace BTCPayServer.Models.InvoicingModels public string CoinSwitchMode { get; set; } public string CoinSwitchMerchantId { get; set; } public string RootPath { get; set; } + public decimal CoinSwitchAmountMarkupPercentage { get; set; } } } diff --git a/BTCPayServer/Models/StoreViewModels/UpdateCoinSwitchSettingsViewModel.cs b/BTCPayServer/Models/StoreViewModels/UpdateCoinSwitchSettingsViewModel.cs index 424ba255b..fa6c2f001 100644 --- a/BTCPayServer/Models/StoreViewModels/UpdateCoinSwitchSettingsViewModel.cs +++ b/BTCPayServer/Models/StoreViewModels/UpdateCoinSwitchSettingsViewModel.cs @@ -12,6 +12,12 @@ namespace BTCPayServer.Models.StoreViewModels [Display(Name = "Integration Mode")] public string Mode { get; set; } = "inline"; + + [Required] + [Range(0, 100)] + [Display(Name = + "Percentage to multiply amount requested at Coinswitch to avoid underpaid situations due to Coinswitch not guaranteeing rates. ")] + public decimal AmountMarkupPercentage { get; set; } = new decimal(2); public List Modes { get; } = new List { diff --git a/BTCPayServer/Payments/Coinswitch/CoinswitchSettings.cs b/BTCPayServer/Payments/Coinswitch/CoinswitchSettings.cs index 7a4eba1c1..30c5cf836 100644 --- a/BTCPayServer/Payments/Coinswitch/CoinswitchSettings.cs +++ b/BTCPayServer/Payments/Coinswitch/CoinswitchSettings.cs @@ -5,6 +5,7 @@ namespace BTCPayServer.Payments.CoinSwitch public string MerchantId { get; set; } public string Mode { get; set; } public bool Enabled { get; set; } + public decimal AmountMarkupPercentage { get; set; } public bool IsConfigured() { diff --git a/BTCPayServer/Views/Invoice/Checkout-Body.cshtml b/BTCPayServer/Views/Invoice/Checkout-Body.cshtml index 2f01fb714..235e64823 100644 --- a/BTCPayServer/Views/Invoice/Checkout-Body.cshtml +++ b/BTCPayServer/Views/Invoice/Checkout-Body.cshtml @@ -303,7 +303,7 @@ :mode="srvModel.coinSwitchMode" :merchant-id="srvModel.coinSwitchMerchantId" :to-currency="srvModel.paymentMethodId" - :to-currency-due="srvModel.btcDue" + :to-currency-due="srvModel.coinSwitchAmountMarkupPercentage? (1 + (srvModel.coinSwitchAmountMarkupPercentage / 100) :srvModel.btcDue" :autoload="selectedThirdPartyProcessor === 'coinswitch'" :to-currency-address="srvModel.btcAddress">
diff --git a/BTCPayServer/Views/Stores/UpdateCoinSwitchSettings.cshtml b/BTCPayServer/Views/Stores/UpdateCoinSwitchSettings.cshtml index 0013f53e8..2bc56fb03 100644 --- a/BTCPayServer/Views/Stores/UpdateCoinSwitchSettings.cshtml +++ b/BTCPayServer/Views/Stores/UpdateCoinSwitchSettings.cshtml @@ -30,7 +30,11 @@
- +
+ + + +