Make NFC built in (#4541)

* Make NFC built int

* support checkout v2

* uninstall old plugin

* fix lnurl in unified checkout

* fix tests

* fix tests

* fix old checkout unified qr

* clean up and make nfc submission more sturdy

* support topup invoices for lnurlw

* fix test

* Payment URI fixes

* Fix LNURL exclusion cases

* UI updates

* Adapt test

---------

Co-authored-by: Dennis Reimann <mail@dennisreimann.de>
This commit is contained in:
Andrew Camilleri
2023-02-08 07:47:38 +01:00
committed by GitHub
parent 67254cc30c
commit 85513aa5c3
13 changed files with 421 additions and 53 deletions

View File

@@ -649,12 +649,13 @@ namespace BTCPayServer.Controllers
var storeBlob = store.GetStoreBlob();
var btcId = PaymentMethodId.Parse("BTC");
var lnId = PaymentMethodId.Parse("BTC_LightningLike");
var lnurlId = PaymentMethodId.Parse("BTC_LNURLPAY");
if (paymentMethodId is null)
{
var enabledPaymentIds = store.GetEnabledPaymentIds(_NetworkProvider)
// Exclude LNURL for Checkout v2 + non-top up invoices
.Where(pmId => storeBlob.CheckoutType == CheckoutType.V1 ||
pmId.PaymentType is not LNURLPayPaymentType || invoice.IsUnsetTopUp())
.Where(pmId => storeBlob.CheckoutType == CheckoutType.V1 ||
// Exclude LNURL for Checkout v2 + non-top up invoices
(pmId.PaymentType is not LNURLPayPaymentType || invoice.IsUnsetTopUp()))
.ToArray();
// Exclude Lightning if OnChainWithLnInvoiceFallback is active and we have both payment methods
@@ -802,11 +803,9 @@ namespace BTCPayServer.Controllers
IsMultiCurrency = invoice.GetPayments(false).Select(p => p.GetPaymentMethodId()).Concat(new[] { paymentMethod.GetId() }).Distinct().Count() > 1,
StoreId = store.Id,
AvailableCryptos = invoice.GetPaymentMethods()
.Where(i => i.Network != null &&
.Where(i => i.Network != null && storeBlob.CheckoutType == CheckoutType.V1 ||
// Exclude LNURL for Checkout v2 + non-top up invoices
(storeBlob.CheckoutType == CheckoutType.V1 ||
i.GetId().PaymentType is not LNURLPayPaymentType ||
invoice.IsUnsetTopUp()))
i.GetId().PaymentType is not LNURLPayPaymentType || invoice.IsUnsetTopUp())
.Select(kv =>
{
var availableCryptoPaymentMethodId = kv.GetId();
@@ -836,10 +835,15 @@ namespace BTCPayServer.Controllers
{
var onchainPM = model.AvailableCryptos.Find(c => c.PaymentMethodId == btcId.ToString());
var lightningPM = model.AvailableCryptos.Find(c => c.PaymentMethodId == lnId.ToString());
var lnurlPM = model.AvailableCryptos.Find(c => c.PaymentMethodId == lnurlId.ToString());
if (onchainPM != null && lightningPM != null)
{
model.AvailableCryptos.Remove(lightningPM);
}
if (onchainPM != null && lnurlPM != null)
{
model.AvailableCryptos.Remove(lnurlPM);
}
}
paymentMethodHandler.PreparePaymentModel(model, dto, storeBlob, paymentMethod);