mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-01-19 05:33:31 +01:00
Re-enable lightning sats feature through C# (#1014)
This commit is contained in:
parent
e6cfb6e851
commit
7ab97311be
@ -156,21 +156,22 @@ namespace BTCPayServer.Tests
|
||||
[Fact]
|
||||
public void CanUseLightningSatsFeature()
|
||||
{
|
||||
//uncomment after https://github.com/btcpayserver/btcpayserver/pull/1014
|
||||
// using (var s = SeleniumTester.Create())
|
||||
// {
|
||||
// s.Start();
|
||||
// s.RegisterNewUser();
|
||||
// var store = s.CreateNewStore();
|
||||
// s.AddInternalLightningNode("BTC");
|
||||
// s.GoToStore(store.storeId, StoreNavPages.Checkout);
|
||||
// s.SetCheckbox(s, "LightningAmountInSatoshi", true);
|
||||
// s.Driver.FindElement(By.Name("command")).Click();
|
||||
// var invoiceId = s.CreateInvoice(store.storeName, 10, "USD", "a@g.com");
|
||||
// s.GoToInvoiceCheckout(invoiceId);
|
||||
// Assert.Contains("Sats", s.Driver.FindElement(By.ClassName("payment__currencies_noborder")).Text);
|
||||
//
|
||||
// }
|
||||
using (var s = SeleniumTester.Create())
|
||||
{
|
||||
s.Start();
|
||||
s.RegisterNewUser();
|
||||
var store = s.CreateNewStore();
|
||||
s.AddInternalLightningNode("BTC");
|
||||
s.GoToStore(store.storeId, StoreNavPages.Checkout);
|
||||
s.SetCheckbox(s, "LightningAmountInSatoshi", true);
|
||||
var command = s.Driver.FindElement(By.Name("command"));
|
||||
|
||||
command.ForceClick();
|
||||
var invoiceId = s.CreateInvoice(store.storeName, 10, "USD", "a@g.com");
|
||||
s.GoToInvoiceCheckout(invoiceId);
|
||||
Assert.Contains("Sats", s.Driver.FindElement(By.ClassName("payment__currencies_noborder")).Text);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ using BTCPayServer.Lightning.CLightning;
|
||||
using BTCPayServer.Views.Stores;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using OpenQA.Selenium.Interactions;
|
||||
|
||||
namespace BTCPayServer.Tests
|
||||
{
|
||||
@ -216,6 +217,13 @@ namespace BTCPayServer.Tests
|
||||
SetCheckbox(s.Driver.FindElement(By.Name(inputName)), value);
|
||||
}
|
||||
|
||||
public void ScrollToElement(IWebElement element)
|
||||
{
|
||||
Actions actions = new Actions(Driver);
|
||||
actions.MoveToElement(element);
|
||||
actions.Perform();
|
||||
}
|
||||
|
||||
public void GoToInvoices()
|
||||
{
|
||||
Driver.FindElement(By.Id("Invoices")).Click();
|
||||
|
@ -238,7 +238,6 @@ namespace BTCPayServer.Controllers
|
||||
CustomCSSLink = storeBlob.CustomCSS?.AbsoluteUri,
|
||||
CustomLogoLink = storeBlob.CustomLogo?.AbsoluteUri,
|
||||
CryptoImage = Request.GetRelativePathOrAbsolute(paymentMethodHandler.GetCryptoImage(paymentMethodId)),
|
||||
LightningAmountInSatoshi = storeBlob.LightningAmountInSatoshi,
|
||||
BtcAddress = paymentMethodDetails.GetPaymentDestination(),
|
||||
BtcDue = accounting.Due.ToString(),
|
||||
OrderAmount = (accounting.TotalDue - accounting.NetworkFee).ToString(),
|
||||
@ -295,7 +294,7 @@ namespace BTCPayServer.Controllers
|
||||
.ToList()
|
||||
};
|
||||
|
||||
paymentMethodHandler.PreparePaymentModel(model, dto);
|
||||
paymentMethodHandler.PreparePaymentModel(model, dto, storeBlob);
|
||||
model.UISettings = paymentMethodHandler.GetCheckoutUISettings();
|
||||
model.PaymentMethodId = paymentMethodId.ToString();
|
||||
var expiration = TimeSpan.FromSeconds(model.ExpirationSeconds);
|
||||
|
@ -37,7 +37,8 @@ namespace BTCPayServer.Payments.Bitcoin
|
||||
public Task<BitcoinAddress> ReserveAddress;
|
||||
}
|
||||
|
||||
public override void PreparePaymentModel(PaymentModel model, InvoiceResponse invoiceResponse)
|
||||
public override void PreparePaymentModel(PaymentModel model, InvoiceResponse invoiceResponse,
|
||||
StoreBlob storeBlob)
|
||||
{
|
||||
var paymentMethodId = new PaymentMethodId(model.CryptoCode, PaymentTypes.BTCLike);
|
||||
|
||||
|
@ -37,7 +37,7 @@ namespace BTCPayServer.Payments
|
||||
/// <returns></returns>
|
||||
object PreparePayment(ISupportedPaymentMethod supportedPaymentMethod, StoreData store, BTCPayNetworkBase network);
|
||||
|
||||
void PreparePaymentModel(PaymentModel model, InvoiceResponse invoiceResponse);
|
||||
void PreparePaymentModel(PaymentModel model, InvoiceResponse invoiceResponse, StoreBlob storeBlob);
|
||||
string GetCryptoImage(PaymentMethodId paymentMethodId);
|
||||
string GetPaymentMethodName(PaymentMethodId paymentMethodId);
|
||||
|
||||
@ -68,7 +68,8 @@ namespace BTCPayServer.Payments
|
||||
TSupportedPaymentMethod supportedPaymentMethod,
|
||||
PaymentMethod paymentMethod, StoreData store, TBTCPayNetwork network, object preparePaymentObject);
|
||||
|
||||
public abstract void PreparePaymentModel(PaymentModel model, InvoiceResponse invoiceResponse);
|
||||
public abstract void PreparePaymentModel(PaymentModel model, InvoiceResponse invoiceResponse,
|
||||
StoreBlob storeBlob);
|
||||
public abstract string GetCryptoImage(PaymentMethodId paymentMethodId);
|
||||
public abstract string GetPaymentMethodName(PaymentMethodId paymentMethodId);
|
||||
|
||||
|
@ -162,7 +162,8 @@ namespace BTCPayServer.Payments.Lightning
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
public override void PreparePaymentModel(PaymentModel model, InvoiceResponse invoiceResponse)
|
||||
public override void PreparePaymentModel(PaymentModel model, InvoiceResponse invoiceResponse,
|
||||
StoreBlob storeBlob)
|
||||
{
|
||||
var paymentMethodId = new PaymentMethodId(model.CryptoCode, PaymentTypes.LightningLike);
|
||||
|
||||
@ -172,8 +173,16 @@ namespace BTCPayServer.Payments.Lightning
|
||||
model.PaymentMethodName = GetPaymentMethodName(network);
|
||||
model.InvoiceBitcoinUrl = cryptoInfo.PaymentUrls.BOLT11;
|
||||
model.InvoiceBitcoinUrlQR = cryptoInfo.PaymentUrls.BOLT11.ToUpperInvariant();
|
||||
model.LightningAmountInSatoshi = storeBlob.LightningAmountInSatoshi;
|
||||
if (storeBlob.LightningAmountInSatoshi && model.CryptoCode == "BTC" )
|
||||
{
|
||||
model.CryptoCode = "Sats";
|
||||
model.BtcDue = Money.Parse(model.BtcDue).ToUnit(MoneyUnit.Satoshi).ToString();
|
||||
model.BtcPaid = Money.Parse(model.BtcPaid).ToUnit(MoneyUnit.Satoshi).ToString();
|
||||
model.NetworkFee = new Money(model.NetworkFee, MoneyUnit.BTC).ToUnit(MoneyUnit.Satoshi);
|
||||
model.OrderAmount = Money.Parse(model.OrderAmount).ToUnit(MoneyUnit.Satoshi).ToString();
|
||||
}
|
||||
}
|
||||
|
||||
public override string GetCryptoImage(PaymentMethodId paymentMethodId)
|
||||
{
|
||||
var network = _networkProvider.GetNetwork<BTCPayNetwork>(paymentMethodId.CryptoCode);
|
||||
|
@ -213,12 +213,6 @@
|
||||
this.lineItemsExpanded ? $("line-items").slideUp() : $("line-items").slideDown();
|
||||
this.lineItemsExpanded = !this.lineItemsExpanded;
|
||||
},
|
||||
numberFormatted: function(x) {
|
||||
var rounded = Math.round(x);
|
||||
var parts = rounded.toString().split(".");
|
||||
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, " ");
|
||||
return parts.join(".");
|
||||
},
|
||||
openPaymentMethodDialog: function() {
|
||||
var content = $("#vexPopupDialog").html();
|
||||
vex.open({
|
||||
|
Loading…
Reference in New Issue
Block a user