mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-01-18 13:26:47 +01:00
Merge pull request #6470 from NicolasDorier/globalcheckoutmodelext
Plugin: Add IGlobalCheckoutModelExtension
This commit is contained in:
commit
fe53424710
@ -936,10 +936,15 @@ namespace BTCPayServer.Controllers
|
||||
var expiration = TimeSpan.FromSeconds(model.ExpirationSeconds);
|
||||
model.TimeLeft = expiration.PrettyPrint();
|
||||
|
||||
if (_paymentModelExtensions.TryGetValue(paymentMethodId, out var extension) &&
|
||||
_handlers.TryGetValue(paymentMethodId, out var h))
|
||||
if (_handlers.TryGetValue(paymentMethodId, out var h))
|
||||
{
|
||||
extension.ModifyCheckoutModel(new CheckoutModelContext(model, store, storeBlob, invoice, Url, prompt, h));
|
||||
var ctx = new CheckoutModelContext(model, store, storeBlob, invoice, Url, prompt, h);
|
||||
if (_paymentModelExtensions.TryGetValue(paymentMethodId, out var extension))
|
||||
{
|
||||
extension.ModifyCheckoutModel(ctx);
|
||||
}
|
||||
foreach (var global in GlobalCheckoutModelExtensions)
|
||||
global.ModifyCheckoutModel(ctx);
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
@ -69,6 +69,7 @@ namespace BTCPayServer.Controllers
|
||||
private readonly UriResolver _uriResolver;
|
||||
|
||||
public WebhookSender WebhookNotificationManager { get; }
|
||||
public IEnumerable<IGlobalCheckoutModelExtension> GlobalCheckoutModelExtensions { get; }
|
||||
public IStringLocalizer StringLocalizer { get; }
|
||||
|
||||
public UIInvoiceController(
|
||||
@ -99,6 +100,7 @@ namespace BTCPayServer.Controllers
|
||||
IAuthorizationService authorizationService,
|
||||
TransactionLinkProviders transactionLinkProviders,
|
||||
Dictionary<PaymentMethodId, ICheckoutModelExtension> paymentModelExtensions,
|
||||
IEnumerable<IGlobalCheckoutModelExtension> globalCheckoutModelExtensions,
|
||||
IStringLocalizer stringLocalizer,
|
||||
PrettyNameProvider prettyName)
|
||||
{
|
||||
@ -124,6 +126,7 @@ namespace BTCPayServer.Controllers
|
||||
_authorizationService = authorizationService;
|
||||
_transactionLinkProviders = transactionLinkProviders;
|
||||
_paymentModelExtensions = paymentModelExtensions;
|
||||
GlobalCheckoutModelExtensions = globalCheckoutModelExtensions;
|
||||
_prettyName = prettyName;
|
||||
_fileService = fileService;
|
||||
_uriResolver = uriResolver;
|
||||
|
10
BTCPayServer/Payments/IGlobalCheckoutModelExtension.cs
Normal file
10
BTCPayServer/Payments/IGlobalCheckoutModelExtension.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace BTCPayServer.Payments
|
||||
{
|
||||
/// <summary>
|
||||
/// <see cref="ModifyCheckoutModel"/> will always run when showing the checkout page
|
||||
/// </summary>
|
||||
public interface IGlobalCheckoutModelExtension
|
||||
{
|
||||
void ModifyCheckoutModel(CheckoutModelContext context);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user