Fix payment request overriding user provided email

This commit is contained in:
Kukks 2023-04-26 14:06:42 +02:00
parent 92d9c17095
commit 76f32cd064
No known key found for this signature in database
GPG Key ID: 8E5530D9D1C93097

View File

@ -197,12 +197,13 @@ namespace BTCPayServer.Controllers
amount = amountDue;
var redirectUrl = _linkGenerator.PaymentRequestLink(id, request.Scheme, request.Host, request.PathBase);
JObject invoiceMetadata = prData.GetBlob()?.FormResponse is JObject formResponse ? formResponse : new JObject();
JObject invoiceMetadata = prData.GetBlob()?.FormResponse ?? new JObject();
invoiceMetadata.Merge(new InvoiceMetadata
{
OrderId = PaymentRequestRepository.GetOrderIdForPaymentRequest(id),
PaymentRequestId = id,
BuyerEmail = string.IsNullOrEmpty(prBlob.Email) ? null : prBlob.Email
BuyerEmail = invoiceMetadata.TryGetValue("buyerEmail", out var formEmail) && formEmail.Type == JTokenType.String ? formEmail.Value<string>():
string.IsNullOrEmpty(prBlob.Email) ? null : prBlob.Email
}.ToJObject(), new JsonMergeSettings() { MergeNullValueHandling = MergeNullValueHandling.Ignore });
var invoiceRequest =