Add metadata to invoice webhook event (#4370)

close #4223
This commit is contained in:
Umar Bolatov
2022-11-28 00:50:52 -08:00
committed by GitHub
parent 45edd330f5
commit 420954ed00
3 changed files with 9 additions and 5 deletions

View File

@@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq;
namespace BTCPayServer.Client.Models namespace BTCPayServer.Client.Models
{ {
@@ -19,6 +16,7 @@ namespace BTCPayServer.Client.Models
[JsonProperty(Order = 1)] public string StoreId { get; set; } [JsonProperty(Order = 1)] public string StoreId { get; set; }
[JsonProperty(Order = 2)] public string InvoiceId { get; set; } [JsonProperty(Order = 2)] public string InvoiceId { get; set; }
[JsonProperty(Order = 3)] public JObject Metadata { get; set; }
} }
public class WebhookInvoiceSettledEvent : WebhookInvoiceEvent public class WebhookInvoiceSettledEvent : WebhookInvoiceEvent

View File

@@ -157,6 +157,7 @@ namespace BTCPayServer.HostedServices
webhookEvent.DeliveryId = delivery.Id; webhookEvent.DeliveryId = delivery.Id;
webhookEvent.WebhookId = webhook.Id; webhookEvent.WebhookId = webhook.Id;
webhookEvent.OriginalDeliveryId = delivery.Id; webhookEvent.OriginalDeliveryId = delivery.Id;
webhookEvent.Metadata = invoiceEvent.Invoice.Metadata.ToJObject();
webhookEvent.IsRedelivery = false; webhookEvent.IsRedelivery = false;
webhookEvent.Timestamp = delivery.Timestamp; webhookEvent.Timestamp = delivery.Timestamp;
var context = new WebhookDeliveryRequest(webhook.Id, webhookEvent, delivery, webhookBlob); var context = new WebhookDeliveryRequest(webhook.Id, webhookEvent, delivery, webhookBlob);

View File

@@ -673,6 +673,11 @@
"type": "string", "type": "string",
"description": "The invoice id of the invoice's event", "description": "The invoice id of the invoice's event",
"nullable": false "nullable": false
},
"metadata": {
"type": "object",
"description": "User-supplied metadata added to the invoice at the time of its creation",
"nullable": false
} }
} }
} }