From 9fc7f287d277fc2812999b4638e677d64bac59b2 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Mon, 5 Nov 2018 17:02:12 +0900 Subject: [PATCH] Expose buyer object to conform to bitpay API --- BTCPayServer/BTCPayServer.csproj | 2 +- BTCPayServer/Models/InvoiceResponse.cs | 2 ++ BTCPayServer/Services/Invoices/InvoiceEntity.cs | 11 ++++++++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj index 1bb0040c4..5bcab711f 100644 --- a/BTCPayServer/BTCPayServer.csproj +++ b/BTCPayServer/BTCPayServer.csproj @@ -2,7 +2,7 @@ Exe netcoreapp2.1 - 1.0.3.6 + 1.0.3.7 NU1701,CA1816,CA1308,CA1810,CA2208 diff --git a/BTCPayServer/Models/InvoiceResponse.cs b/BTCPayServer/Models/InvoiceResponse.cs index 47eeb58b6..df47d65a9 100644 --- a/BTCPayServer/Models/InvoiceResponse.cs +++ b/BTCPayServer/Models/InvoiceResponse.cs @@ -247,6 +247,8 @@ namespace BTCPayServer.Models public Dictionary Addresses { get; set; } [JsonProperty("paymentCodes")] public Dictionary PaymentCodes { get; set; } + [JsonProperty("buyer")] + public JObject Buyer { get; set; } } public class Flags { diff --git a/BTCPayServer/Services/Invoices/InvoiceEntity.cs b/BTCPayServer/Services/Invoices/InvoiceEntity.cs index 9d84bff83..075270822 100644 --- a/BTCPayServer/Services/Invoices/InvoiceEntity.cs +++ b/BTCPayServer/Services/Invoices/InvoiceEntity.cs @@ -423,7 +423,16 @@ namespace BTCPayServer.Services.Invoices #pragma warning restore CS0618 dto.CryptoInfo.Add(cryptoInfo); - + dto.Buyer = new JObject(); + dto.Buyer.Add(new JProperty("name", BuyerInformation.BuyerName)); + dto.Buyer.Add(new JProperty("address1", BuyerInformation.BuyerAddress1)); + dto.Buyer.Add(new JProperty("address2", BuyerInformation.BuyerAddress2)); + dto.Buyer.Add(new JProperty("locality", BuyerInformation.BuyerCity)); + dto.Buyer.Add(new JProperty("region", BuyerInformation.BuyerState)); + dto.Buyer.Add(new JProperty("postalCode", BuyerInformation.BuyerZip)); + dto.Buyer.Add(new JProperty("country", BuyerInformation.BuyerCountry)); + dto.Buyer.Add(new JProperty("phone", BuyerInformation.BuyerPhone)); + dto.Buyer.Add(new JProperty("email", BuyerInformation.BuyerEmail ?? RefundMail)); dto.PaymentCodes.Add(paymentId.ToString(), cryptoInfo.PaymentUrls); dto.PaymentSubtotals.Add(paymentId.ToString(), subtotalPrice.Satoshi); dto.PaymentTotals.Add(paymentId.ToString(), accounting.TotalDue.Satoshi);