mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +01:00
Can set LazyPaymentMethod at the invoice creation level
This commit is contained in:
@@ -86,6 +86,7 @@ namespace BTCPayServer.Client.Models
|
||||
public bool? RequiresRefundEmail { get; set; } = null;
|
||||
public string DefaultLanguage { get; set; }
|
||||
public CheckoutType? CheckoutType { get; set; }
|
||||
public bool? LazyPaymentMethods { get; set; }
|
||||
}
|
||||
}
|
||||
public class InvoiceData : InvoiceDataBase
|
||||
|
||||
@@ -248,6 +248,7 @@ namespace BTCPayServer.Controllers
|
||||
entity.RedirectAutomatically = invoice.Checkout.RedirectAutomatically ?? storeBlob.RedirectAutomatically;
|
||||
entity.CheckoutType = invoice.Checkout.CheckoutType;
|
||||
entity.RequiresRefundEmail = invoice.Checkout.RequiresRefundEmail;
|
||||
entity.LazyPaymentMethods = invoice.Checkout.LazyPaymentMethods ?? storeBlob.LazyPaymentMethods;
|
||||
IPaymentFilter? excludeFilter = null;
|
||||
if (invoice.Checkout.PaymentMethods != null)
|
||||
{
|
||||
@@ -460,7 +461,7 @@ namespace BTCPayServer.Controllers
|
||||
var storeBlob = store.GetStoreBlob();
|
||||
|
||||
// Checkout v2 does not show a payment method switch for Bitcoin-only + BIP21, so exclude that case
|
||||
var preparePayment = storeBlob.LazyPaymentMethods && !storeBlob.OnChainWithLnInvoiceFallback
|
||||
var preparePayment = entity.LazyPaymentMethods && !storeBlob.OnChainWithLnInvoiceFallback
|
||||
? null
|
||||
: handler.PreparePayment(supportedPaymentMethod, store, network);
|
||||
var rate = await fetchingByCurrencyPair[new CurrencyPair(network.CryptoCode, entity.Currency)];
|
||||
|
||||
@@ -447,19 +447,9 @@ namespace BTCPayServer
|
||||
try
|
||||
{
|
||||
createInvoice.Checkout ??= new InvoiceDataBase.CheckoutOptions();
|
||||
createInvoice.Checkout.LazyPaymentMethods = false;
|
||||
createInvoice.Checkout.PaymentMethods = new[] { pmi.ToStringNormalized() };
|
||||
i = await _invoiceController.CreateInvoiceCoreRaw(createInvoice, store, Request.GetAbsoluteRoot(), additionalTags);
|
||||
var pm = i.GetPaymentMethod(pmi);
|
||||
if (pm is null)
|
||||
return NotFound("LNUrl is enabled, but the invoice couldn't use it. Check the invoice's events for more information.");
|
||||
// If LNUrl isn't activated, make sure it is
|
||||
var pmd = pm.GetPaymentMethodDetails();
|
||||
if (!pmd.Activated)
|
||||
{
|
||||
if (!await _invoiceActivator.ActivateInvoicePaymentMethod(pmi, i, store))
|
||||
return NotFound("Unable to activate LNURL. Check the invoice's events for more information.");
|
||||
i = await _invoiceRepository.GetInvoice(i.Id);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -461,6 +461,7 @@ namespace BTCPayServer.Services.Invoices
|
||||
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public CheckoutType? CheckoutType { get; set; }
|
||||
public bool LazyPaymentMethods { get; set; }
|
||||
|
||||
public bool IsExpired()
|
||||
{
|
||||
|
||||
@@ -1173,6 +1173,11 @@
|
||||
"nullable": true,
|
||||
"description": "Default payment type for the invoice (e.g., BTC, BTC-LightningNetwork). Default payment method set for the store is used if this parameter is not specified."
|
||||
},
|
||||
"lazyPaymentMethods": {
|
||||
"type": "boolean",
|
||||
"nullable": true,
|
||||
"description": "If true, payment methods are enabled individually upon user interaction in the invoice. Default to store's settings'"
|
||||
},
|
||||
"expirationMinutes": {
|
||||
"nullable": true,
|
||||
"description": "The number of minutes after which an invoice becomes expired. Defaults to the store's settings. (The default store settings is 15)",
|
||||
|
||||
Reference in New Issue
Block a user