mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 14:22:40 +01:00
Webhooks: Fix invoice interpolation (#5586)
* Webhooks: Fix invoice interpolation Fixes #5584. * Syntax cleanups
This commit is contained in:
parent
ad89139e07
commit
c585a0b276
4 changed files with 7 additions and 12 deletions
|
@ -59,15 +59,12 @@ public class StoreEmailRuleProcessorSender : EventHostedServiceBase
|
|||
var sender = await _emailSenderFactory.GetEmailSender(storeWebhookEvent.StoreId);
|
||||
foreach (UIStoresController.StoreEmailRule actionableRule in actionableRules)
|
||||
{
|
||||
|
||||
|
||||
var request = new SendEmailRequest()
|
||||
var request = new SendEmailRequest
|
||||
{
|
||||
Subject = actionableRule.Subject, Body = actionableRule.Body, Email = actionableRule.To
|
||||
};
|
||||
request = await webhookDeliveryRequest.Interpolate(request, actionableRule);
|
||||
|
||||
|
||||
var recipients = (request?.Email?.Split(",", StringSplitOptions.RemoveEmptyEntries) ?? Array.Empty<string>())
|
||||
.Select(o =>
|
||||
{
|
||||
|
@ -77,7 +74,7 @@ public class StoreEmailRuleProcessorSender : EventHostedServiceBase
|
|||
.Where(o => o != null)
|
||||
.ToArray();
|
||||
|
||||
if(recipients.Length == 0)
|
||||
if (recipients.Length == 0)
|
||||
continue;
|
||||
|
||||
sender.SendEmail(recipients.ToArray(), null, null, request.Subject, request.Body);
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.Globalization;
|
||||
using System.Threading.Tasks;
|
||||
using BTCPayServer.Client.Models;
|
||||
using BTCPayServer.Controllers;
|
||||
using BTCPayServer.Data;
|
||||
using BTCPayServer.Services.Invoices;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using WebhookDeliveryData = BTCPayServer.Data.WebhookDeliveryData;
|
||||
|
||||
namespace BTCPayServer.HostedServices.Webhooks;
|
||||
|
@ -46,7 +44,7 @@ public class InvoiceWebhookDeliveryRequest : WebhookSender.WebhookDeliveryReques
|
|||
.Replace("{Invoice.OrderId}", Invoice.Metadata.OrderId);
|
||||
|
||||
|
||||
res = InterpolateJsonField(str, "Invoice.Metadata", Invoice.Metadata.ToJObject());
|
||||
res = InterpolateJsonField(res, "Invoice.Metadata", Invoice.Metadata.ToJObject());
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,14 +37,14 @@ public class PaymentRequestWebhookDeliveryRequest : WebhookSender.WebhookDeliver
|
|||
|
||||
private string Interpolate(string str, PaymentRequestBaseData blob)
|
||||
{
|
||||
var res= str.Replace("{PaymentRequest.Id}", _evt.Data.Id)
|
||||
var res = str.Replace("{PaymentRequest.Id}", _evt.Data.Id)
|
||||
.Replace("{PaymentRequest.Price}", blob.Amount.ToString(CultureInfo.InvariantCulture))
|
||||
.Replace("{PaymentRequest.Currency}", blob.Currency)
|
||||
.Replace("{PaymentRequest.Title}", blob.Title)
|
||||
.Replace("{PaymentRequest.Description}", blob.Description)
|
||||
.Replace("{PaymentRequest.Status}", _evt.Data.Status.ToString());
|
||||
|
||||
res= InterpolateJsonField(res, "PaymentRequest.FormResponse", blob.FormResponse);
|
||||
res = InterpolateJsonField(res, "PaymentRequest.FormResponse", blob.FormResponse);
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ public class PayoutWebhookDeliveryRequest(PayoutEvent evt, string? webhookId, We
|
|||
|
||||
private string Interpolate(string str)
|
||||
{
|
||||
var res= str.Replace("{Payout.Id}", evt.Payout.Id)
|
||||
var res = str.Replace("{Payout.Id}", evt.Payout.Id)
|
||||
.Replace("{Payout.PullPaymentId}", evt.Payout.PullPaymentDataId)
|
||||
.Replace("{Payout.Destination}", evt.Payout.Destination)
|
||||
.Replace("{Payout.State}", evt.Payout.State.ToString());
|
||||
|
|
Loading…
Add table
Reference in a new issue