diff --git a/BTCPayServer/Controllers/StoresController.cs b/BTCPayServer/Controllers/StoresController.cs
index 83c174342..d95cfd37d 100644
--- a/BTCPayServer/Controllers/StoresController.cs
+++ b/BTCPayServer/Controllers/StoresController.cs
@@ -1015,7 +1015,7 @@ namespace BTCPayServer.Controllers
ButtonType = 0,
Min = 1,
Max = 20,
- Step = 1,
+ Step = "1",
Apps = apps
};
return View(model);
diff --git a/BTCPayServer/Models/StoreViewModels/PayButtonViewModel.cs b/BTCPayServer/Models/StoreViewModels/PayButtonViewModel.cs
index 963359f98..74b183819 100644
--- a/BTCPayServer/Models/StoreViewModels/PayButtonViewModel.cs
+++ b/BTCPayServer/Models/StoreViewModels/PayButtonViewModel.cs
@@ -21,7 +21,7 @@ namespace BTCPayServer.Models.StoreViewModels
// Slider properties (ButtonType = 2)
public decimal Min { get; set; }
public decimal Max { get; set; }
- public decimal Step { get; set; }
+ public string Step { get; set; }
// Custom Amount properties (ButtonType = 1)
public bool SimpleInput { get; set; }
diff --git a/BTCPayServer/Views/Stores/PayButton.cshtml b/BTCPayServer/Views/Stores/PayButton.cshtml
index b88bcd5e0..3d71075ab 100644
--- a/BTCPayServer/Views/Stores/PayButton.cshtml
+++ b/BTCPayServer/Views/Stores/PayButton.cshtml
@@ -107,21 +107,21 @@
+ v-validate="'required|decimal|min_value:0'" :class="{'is-invalid': errors.has('min') }">
{{ errors.first('min') }}
\n
\n';
- html += srvModel.simpleInput ? '' : addPlusMinusButton("-");
- html += ' ' + addInputPrice(priceInputName, srvModel.price, widthInput, "", srvModel.simpleInput ? "number": null, srvModel.min, srvModel.max, srvModel.step);
- html += srvModel.simpleInput ? '' : addPlusMinusButton("+");
+ html += srvModel.simpleInput ? '' : addPlusMinusButton("-", srvModel.step, srvModel.min, srvModel.max);
+ html += ' ' + addInputPrice(priceInputName, srvModel.price, widthInput, "", "number", srvModel.min, srvModel.max, srvModel.step);
+ html += srvModel.simpleInput ? '' : addPlusMinusButton("+", srvModel.step, srvModel.min, srvModel.max);
html += '
\n';
if(allowCurrencySelection) {
html += addSelectCurrency(srvModel.currency);
@@ -167,8 +167,13 @@ function inputChanges(event, buttonSize) {
}
// Slider
else if (isSlider) {
+ var step = srvModel.step =="any"? 1: srvModel.step;
+ var min = srvModel.min == null? 1: parseInt(srvModel.min);
+ var max = srvModel.max == null? 1: parseInt(srvModel.max);
+ var onChange = "var el=document.querySelector(\'#btcpay-input-price\'); var price = parseInt(el.value); if(price< "+min+") { el.value = "+min+"} else if(price> "+max+") { el.value = "+max+"} document.querySelector(\'#btcpay-input-range\').value = el.value"
+
html += '
\n';
- html += addInputPrice(priceInputName, srvModel.price, width, 'onchange="document.querySelector(\'#btcpay-input-range\').value = document.querySelector(\'#btcpay-input-price\').value"');
+ html += addInputPrice(priceInputName, srvModel.price, width, 'onchange= \"'+onChange+'\"');
if(allowCurrencySelection) {
html += addSelectCurrency(srvModel.currency);
}
@@ -211,12 +216,23 @@ function addInput(name, value) {
return ' \n';
}
-function addPlusMinusButton(type) {
- return ' \n';
-}
+function addPlusMinusButton(type, step, min, max) {
+ step = step =="any"? 1: step;
+ min = min == null? 1: parseInt(min);
+ max = max == null? 1: parseInt(max);
+ var onChange = "event.preventDefault(); var el=document.querySelector(\'#btcpay-input-price\'); var price = parseInt(el.value);"
+ if(type == "-"){
+ onChange += " if((price - "+step+" )< "+min+") { el.value = "+min+"} else {el.value = parseInt(el.value) - "+step + " }";
+ } else if(type == "+"){
+ onChange += " if((price + "+step+" )> "+max+") { el.value = "+max+"} else {el.value = parseInt(el.value) + "+step + " }";
+ }
+
+
+ return ' \n';
+ }
function addInputPrice(name, price, widthInput, customFn, type, min, max, step) {
- return ' \n';
+ return ' \n';
}
function addSelectCurrency(currency) {