mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-03-10 09:19:24 +01:00
Plugin: Add IGlobalCheckoutModelExtension
This commit is contained in:
parent
1214367503
commit
4f63f08aeb
3 changed files with 21 additions and 3 deletions
|
@ -936,10 +936,15 @@ namespace BTCPayServer.Controllers
|
||||||
var expiration = TimeSpan.FromSeconds(model.ExpirationSeconds);
|
var expiration = TimeSpan.FromSeconds(model.ExpirationSeconds);
|
||||||
model.TimeLeft = expiration.PrettyPrint();
|
model.TimeLeft = expiration.PrettyPrint();
|
||||||
|
|
||||||
if (_paymentModelExtensions.TryGetValue(paymentMethodId, out var extension) &&
|
if (_handlers.TryGetValue(paymentMethodId, out var h))
|
||||||
_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;
|
return model;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,6 +69,7 @@ namespace BTCPayServer.Controllers
|
||||||
private readonly UriResolver _uriResolver;
|
private readonly UriResolver _uriResolver;
|
||||||
|
|
||||||
public WebhookSender WebhookNotificationManager { get; }
|
public WebhookSender WebhookNotificationManager { get; }
|
||||||
|
public IEnumerable<IGlobalCheckoutModelExtension> GlobalCheckoutModelExtensions { get; }
|
||||||
public IStringLocalizer StringLocalizer { get; }
|
public IStringLocalizer StringLocalizer { get; }
|
||||||
|
|
||||||
public UIInvoiceController(
|
public UIInvoiceController(
|
||||||
|
@ -99,6 +100,7 @@ namespace BTCPayServer.Controllers
|
||||||
IAuthorizationService authorizationService,
|
IAuthorizationService authorizationService,
|
||||||
TransactionLinkProviders transactionLinkProviders,
|
TransactionLinkProviders transactionLinkProviders,
|
||||||
Dictionary<PaymentMethodId, ICheckoutModelExtension> paymentModelExtensions,
|
Dictionary<PaymentMethodId, ICheckoutModelExtension> paymentModelExtensions,
|
||||||
|
IEnumerable<IGlobalCheckoutModelExtension> globalCheckoutModelExtensions,
|
||||||
IStringLocalizer stringLocalizer,
|
IStringLocalizer stringLocalizer,
|
||||||
PrettyNameProvider prettyName)
|
PrettyNameProvider prettyName)
|
||||||
{
|
{
|
||||||
|
@ -124,6 +126,7 @@ namespace BTCPayServer.Controllers
|
||||||
_authorizationService = authorizationService;
|
_authorizationService = authorizationService;
|
||||||
_transactionLinkProviders = transactionLinkProviders;
|
_transactionLinkProviders = transactionLinkProviders;
|
||||||
_paymentModelExtensions = paymentModelExtensions;
|
_paymentModelExtensions = paymentModelExtensions;
|
||||||
|
GlobalCheckoutModelExtensions = globalCheckoutModelExtensions;
|
||||||
_prettyName = prettyName;
|
_prettyName = prettyName;
|
||||||
_fileService = fileService;
|
_fileService = fileService;
|
||||||
_uriResolver = uriResolver;
|
_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…
Add table
Reference in a new issue