From 9e16b83202514cb46f4d72393a06c84f6c3ee9b8 Mon Sep 17 00:00:00 2001 From: lepipele Date: Tue, 13 Mar 2018 12:20:22 -0500 Subject: [PATCH 01/10] Testing Shapeshift integration --- BTCPayServer/Views/Invoice/Checkout.cshtml | 4 ++++ BTCPayServer/wwwroot/js/core.js | 1 + 2 files changed, 5 insertions(+) diff --git a/BTCPayServer/Views/Invoice/Checkout.cshtml b/BTCPayServer/Views/Invoice/Checkout.cshtml index dec3105f2..0e3336193 100644 --- a/BTCPayServer/Views/Invoice/Checkout.cshtml +++ b/BTCPayServer/Views/Invoice/Checkout.cshtml @@ -100,6 +100,10 @@ @crypto.PaymentMethodId } + + + +
diff --git a/BTCPayServer/wwwroot/js/core.js b/BTCPayServer/wwwroot/js/core.js index 8946e2181..56628fbb6 100644 --- a/BTCPayServer/wwwroot/js/core.js +++ b/BTCPayServer/wwwroot/js/core.js @@ -53,6 +53,7 @@ function onDataCallback(jsonData) { $(".payment__spinner").hide(); } + jsonData.shapeshiftUrl = "https://shapeshift.io/shifty.html?destination=" + jsonData.btcAddress + "&output=" + jsonData.paymentMethodId + "&amount=" + jsonData.btcDue; // updating ui checkoutCtrl.srvModel = jsonData; } From 636224d0c8fee26dc6406953624dc7676a2255ad Mon Sep 17 00:00:00 2001 From: lepipele Date: Fri, 16 Mar 2018 22:46:30 -0500 Subject: [PATCH 02/10] Checkout html and js cleanup --- BTCPayServer/Views/Invoice/Checkout.cshtml | 112 ++++++++++----------- BTCPayServer/wwwroot/js/core.js | 25 ++--- 2 files changed, 66 insertions(+), 71 deletions(-) diff --git a/BTCPayServer/Views/Invoice/Checkout.cshtml b/BTCPayServer/Views/Invoice/Checkout.cshtml index 0e3336193..26d9e68ba 100644 --- a/BTCPayServer/Views/Invoice/Checkout.cshtml +++ b/BTCPayServer/Views/Invoice/Checkout.cshtml @@ -178,19 +178,6 @@
-
-
- - - -
- -
@@ -215,7 +202,7 @@ - +
@@ -223,6 +210,59 @@
+
+
+ + + +
+ +
+
+
+ To complete your payment, please send {{ srvModel.btcDue }} {{ srvModel.cryptoCode }} to the address below. +
+
+
+
Amount
+ +
+ {{srvModel.btcDue}} {{ srvModel.cryptoCode }} +
+ Copied +
+
+ +
+
+
+
+
+
+
Address
+ +
+
+ +
{{srvModel.btcAddress}}
+
+
+ Copied +
+
+ +
+
+
+
+
-
-
- To complete your payment, please send {{ srvModel.btcDue }} {{ srvModel.cryptoCode }} to the address below. -
-
-
-
Amount
- -
- {{srvModel.btcDue}} {{ srvModel.cryptoCode }} -
- Copied -
-
- -
-
-
-
-
-
-
Address
- -
-
- -
{{srvModel.btcAddress}}
-
-
- Copied -
-
- -
-
-
-
-
+ -
@@ -615,8 +615,6 @@
- -
@@ -174,7 +170,10 @@
Copy
-
+
+ Altcoins +
+
@@ -263,6 +262,13 @@
+
+

Instructions... understand there is forwarding time...

+ + + + +
-

Instructions... understand there is forwarding time...

- - - - +
+ + You can pay {{ srvModel.btcDue }} {{ srvModel.cryptoCode }} using Altcoins. +

+ This service is provided by 3rd party. Please keep in mind that + we have no control over how providers will forward your funds. + Invoice will only be marked paid once funds are received on {{srvModel.cryptoCode}} Blockchain. +
+
+
+ + + + + + @*Changelly doesn't have TO_AMOUNT support so we can't include it + + + Changelly + *@ +
@@ -265,10 +265,10 @@
- You can pay {{ srvModel.btcDue }} {{ srvModel.cryptoCode }} using Altcoins. + You can pay {{ srvModel.btcDue }} {{ srvModel.cryptoCode }} using altcoins other than the ones merchant directly supports.

This service is provided by 3rd party. Please keep in mind that - we have no control over how providers will forward your funds. + we have no control over how providers will forward your funds. Invoice will only be marked paid once funds are received on {{srvModel.cryptoCode}} Blockchain.
From d3befb5b861086cbcc7c3e239d73259ac55addb0 Mon Sep 17 00:00:00 2001 From: lepipele Date: Sat, 17 Mar 2018 23:36:32 -0500 Subject: [PATCH 07/10] Fixing slider style when there are only two tabs --- BTCPayServer/wwwroot/css/normalizer.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BTCPayServer/wwwroot/css/normalizer.css b/BTCPayServer/wwwroot/css/normalizer.css index f5911382d..3cec53042 100644 --- a/BTCPayServer/wwwroot/css/normalizer.css +++ b/BTCPayServer/wwwroot/css/normalizer.css @@ -8562,7 +8562,7 @@ strong { transition: all .2s ease; } - .payment-tabs__slider.two-tabs.slide-copy { + .payment-tabs__slider.slide-copy { right: 0; } From c36a900627f381841b9bc53ef20084e8ef1575c0 Mon Sep 17 00:00:00 2001 From: lepipele Date: Sat, 17 Mar 2018 23:48:06 -0500 Subject: [PATCH 08/10] Store setting for allowing conversion through Shapeshift --- BTCPayServer/Controllers/StoresController.cs | 2 ++ BTCPayServer/Data/StoreData.cs | 4 ++++ BTCPayServer/Models/StoreViewModels/StoreViewModel.cs | 6 ++++++ BTCPayServer/Views/Stores/UpdateStore.cshtml | 8 ++++++-- 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/BTCPayServer/Controllers/StoresController.cs b/BTCPayServer/Controllers/StoresController.cs index 4e5a57824..9331dfab1 100644 --- a/BTCPayServer/Controllers/StoresController.cs +++ b/BTCPayServer/Controllers/StoresController.cs @@ -222,6 +222,7 @@ namespace BTCPayServer.Controllers vm.InvoiceExpiration = storeBlob.InvoiceExpiration; vm.RateMultiplier = (double)storeBlob.GetRateMultiplier(); vm.PreferredExchange = storeBlob.PreferredExchange.IsCoinAverage() ? "coinaverage" : storeBlob.PreferredExchange; + vm.AllowCoinConversion = storeBlob.AllowCoinConversion; return View(vm); } @@ -298,6 +299,7 @@ namespace BTCPayServer.Controllers blob.PreferredExchange = model.PreferredExchange; blob.SetRateMultiplier(model.RateMultiplier); + blob.AllowCoinConversion = model.AllowCoinConversion; if (store.SetStoreBlob(blob)) { diff --git a/BTCPayServer/Data/StoreData.cs b/BTCPayServer/Data/StoreData.cs index 5822e895c..e04ade65d 100644 --- a/BTCPayServer/Data/StoreData.cs +++ b/BTCPayServer/Data/StoreData.cs @@ -213,6 +213,10 @@ namespace BTCPayServer.Data { get; set; } + public bool AllowCoinConversion + { + get; set; + } [DefaultValue(60)] [JsonProperty(DefaultValueHandling = DefaultValueHandling.Populate)] public int MonitoringExpiration diff --git a/BTCPayServer/Models/StoreViewModels/StoreViewModel.cs b/BTCPayServer/Models/StoreViewModels/StoreViewModel.cs index 012132b55..0844ee874 100644 --- a/BTCPayServer/Models/StoreViewModels/StoreViewModel.cs +++ b/BTCPayServer/Models/StoreViewModels/StoreViewModel.cs @@ -94,6 +94,12 @@ namespace BTCPayServer.Models.StoreViewModels get; set; } + [Display(Name = "Allow conversion through third party (Shapeshift, Changelly...)")] + public bool AllowCoinConversion + { + get; set; + } + public string StatusMessage { get; set; diff --git a/BTCPayServer/Views/Stores/UpdateStore.cshtml b/BTCPayServer/Views/Stores/UpdateStore.cshtml index 6b0ea8408..59ad84066 100644 --- a/BTCPayServer/Views/Stores/UpdateStore.cshtml +++ b/BTCPayServer/Views/Stores/UpdateStore.cshtml @@ -70,6 +70,10 @@
+
+ + +
Derivation Scheme
The DerivationScheme represents the destination of the funds received by your invoice on chain. @@ -85,7 +89,7 @@ - @foreach(var scheme in Model.DerivationSchemes) + @foreach (var scheme in Model.DerivationSchemes) { @scheme.Crypto @@ -114,7 +118,7 @@ - @foreach(var scheme in Model.LightningNodes) + @foreach (var scheme in Model.LightningNodes) { @scheme.CryptoCode From 14b70ff35e16910faaf54806bbd3ddba1db99c6b Mon Sep 17 00:00:00 2001 From: lepipele Date: Sat, 17 Mar 2018 23:49:09 -0500 Subject: [PATCH 09/10] Rendering of Conversion tab on Invoice if enabled in store settings --- .../Controllers/InvoiceController.UI.cs | 1 + .../Models/InvoicingModels/PaymentModel.cs | 2 + BTCPayServer/Views/Invoice/Checkout.cshtml | 62 +++++++++++-------- 3 files changed, 39 insertions(+), 26 deletions(-) diff --git a/BTCPayServer/Controllers/InvoiceController.UI.cs b/BTCPayServer/Controllers/InvoiceController.UI.cs index f6e04d78c..8d65f4eef 100644 --- a/BTCPayServer/Controllers/InvoiceController.UI.cs +++ b/BTCPayServer/Controllers/InvoiceController.UI.cs @@ -229,6 +229,7 @@ namespace BTCPayServer.Controllers Status = invoice.Status, CryptoImage = "/" + GetImage(paymentMethodId, network), NetworkFeeDescription = $"{accounting.TxRequired} transaction{(accounting.TxRequired > 1 ? "s" : "")} x {paymentMethodDetails.GetTxFee()} {network.CryptoCode}", + AllowCoinConversion = store.GetStoreBlob().AllowCoinConversion, AvailableCryptos = invoice.GetPaymentMethods(_NetworkProvider) .Where(i => i.Network != null) .Select(kv=> new PaymentModel.AvailableCrypto() diff --git a/BTCPayServer/Models/InvoicingModels/PaymentModel.cs b/BTCPayServer/Models/InvoicingModels/PaymentModel.cs index 964871636..d82f16e74 100644 --- a/BTCPayServer/Models/InvoicingModels/PaymentModel.cs +++ b/BTCPayServer/Models/InvoicingModels/PaymentModel.cs @@ -43,5 +43,7 @@ namespace BTCPayServer.Models.InvoicingModels public int MaxTimeMinutes { get; internal set; } public string PaymentType { get; internal set; } public string PaymentMethodId { get; internal set; } + + public bool AllowCoinConversion { get; set; } } } diff --git a/BTCPayServer/Views/Invoice/Checkout.cshtml b/BTCPayServer/Views/Invoice/Checkout.cshtml index 4d8317795..252208640 100644 --- a/BTCPayServer/Views/Invoice/Checkout.cshtml +++ b/BTCPayServer/Views/Invoice/Checkout.cshtml @@ -170,10 +170,17 @@
Copy
-
- Conversion -
-
+ @if (Model.AllowCoinConversion) + { +
+ Conversion +
+
+ } + else + { +
+ }
@@ -262,29 +269,32 @@
-
-
- - You can pay {{ srvModel.btcDue }} {{ srvModel.cryptoCode }} using altcoins other than the ones merchant directly supports. -

- This service is provided by 3rd party. Please keep in mind that - we have no control over how providers will forward your funds. - Invoice will only be marked paid once funds are received on {{srvModel.cryptoCode}} Blockchain. -
-
-
- - - - + @if (Model.AllowCoinConversion) + { +
+
+ + You can pay {{ srvModel.btcDue }} {{ srvModel.cryptoCode }} using altcoins other than the ones merchant directly supports. +

+ This service is provided by 3rd party. Please keep in mind that + we have no control over how providers will forward your funds. + Invoice will only be marked paid once funds are received on {{srvModel.cryptoCode}} Blockchain. +
+
+
+ + + + - @*Changelly doesn't have TO_AMOUNT support so we can't include it - - - Changelly - *@ -
-
+ @*Changelly doesn't have TO_AMOUNT support so we can't include it + + + Changelly + *@ +
+
+ }