From b5f0924651bec8d6c44abab312aef80a24b1b9ca Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Tue, 11 Jul 2023 15:49:16 +0900 Subject: [PATCH] Serialize PosAppCartItem.value as decimal instead of string --- BTCPayServer.Tests/FastTests.cs | 8 ++++++++ BTCPayServer/Services/Invoices/PosAppData.cs | 10 ++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/BTCPayServer.Tests/FastTests.cs b/BTCPayServer.Tests/FastTests.cs index 157aa6371..0e2c08891 100644 --- a/BTCPayServer.Tests/FastTests.cs +++ b/BTCPayServer.Tests/FastTests.cs @@ -1162,6 +1162,14 @@ namespace BTCPayServer.Tests } }.ToString(); Assert.Equal(1.65m, JsonConvert.DeserializeObject(data).Price); + data = new JObject() + { + ["price"] = new JObject() + { + ["value"] = "1.6305" + } + }.ToString(); + Assert.Equal(1.6305m, JsonConvert.DeserializeObject(data).Price); data = new JObject() { diff --git a/BTCPayServer/Services/Invoices/PosAppData.cs b/BTCPayServer/Services/Invoices/PosAppData.cs index 0671874e3..f41e894af 100644 --- a/BTCPayServer/Services/Invoices/PosAppData.cs +++ b/BTCPayServer/Services/Invoices/PosAppData.cs @@ -85,13 +85,7 @@ public class PosAppCartItemPriceJsonConverter : JsonConverter public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { - switch (value) - { - case null: - break; - case decimal x: - writer.WriteValue(x.ToString(CultureInfo.InvariantCulture)); - break; - } + if (value is decimal x) + writer.WriteValue(x); } }