diff --git a/coffeecard/CoffeeCard.Models/DataTransferObjects/v2/Purchase/FreeProductPaymentDetails.cs b/coffeecard/CoffeeCard.Models/DataTransferObjects/v2/Purchase/FreeProductPaymentDetails.cs index 159a15d0..8fa95612 100644 --- a/coffeecard/CoffeeCard.Models/DataTransferObjects/v2/Purchase/FreeProductPaymentDetails.cs +++ b/coffeecard/CoffeeCard.Models/DataTransferObjects/v2/Purchase/FreeProductPaymentDetails.cs @@ -1,4 +1,5 @@ using System.Runtime.Serialization; +using System.Text.Json.Serialization; namespace CoffeeCard.Models.DataTransferObjects.v2.Purchase { @@ -12,6 +13,9 @@ namespace CoffeeCard.Models.DataTransferObjects.v2.Purchase /// } /// [KnownType(typeof(FreePurchasePaymentDetails))] + [JsonPolymorphic(TypeDiscriminatorPropertyName = "discriminator")] + [JsonDerivedType(typeof(FreePurchasePaymentDetails), typeDiscriminator: "FreePurchasePaymentDetails")] + public class FreePurchasePaymentDetails : PaymentDetails { /// diff --git a/coffeecard/CoffeeCard.Models/DataTransferObjects/v2/Purchase/MobilePayPaymentDetails.cs b/coffeecard/CoffeeCard.Models/DataTransferObjects/v2/Purchase/MobilePayPaymentDetails.cs index 3fd4795d..765e7f77 100644 --- a/coffeecard/CoffeeCard.Models/DataTransferObjects/v2/Purchase/MobilePayPaymentDetails.cs +++ b/coffeecard/CoffeeCard.Models/DataTransferObjects/v2/Purchase/MobilePayPaymentDetails.cs @@ -1,6 +1,7 @@ using Newtonsoft.Json; using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; +using System.Text.Json.Serialization; namespace CoffeeCard.Models.DataTransferObjects.v2.Purchase { @@ -16,6 +17,8 @@ namespace CoffeeCard.Models.DataTransferObjects.v2.Purchase /// } /// [KnownType(typeof(MobilePayPaymentDetails))] + [JsonPolymorphic(TypeDiscriminatorPropertyName = "discriminator")] + [JsonDerivedType(typeof(MobilePayPaymentDetails), typeDiscriminator: "MobilePayPaymentDetails")] public class MobilePayPaymentDetails : PaymentDetails { /// diff --git a/coffeecard/CoffeeCard.Models/DataTransferObjects/v2/Purchase/PaymentDetails.cs b/coffeecard/CoffeeCard.Models/DataTransferObjects/v2/Purchase/PaymentDetails.cs index 1b72271e..43bf7ad2 100644 --- a/coffeecard/CoffeeCard.Models/DataTransferObjects/v2/Purchase/PaymentDetails.cs +++ b/coffeecard/CoffeeCard.Models/DataTransferObjects/v2/Purchase/PaymentDetails.cs @@ -1,10 +1,13 @@ using System.ComponentModel.DataAnnotations; using System.Runtime.Serialization; +using System.Text.Json.Serialization; namespace CoffeeCard.Models.DataTransferObjects.v2.Purchase { [KnownType(typeof(MobilePayPaymentDetails))] [KnownType(typeof(FreePurchasePaymentDetails))] + [JsonPolymorphic(TypeDiscriminatorPropertyName = "discriminator")] + [JsonDerivedType(typeof(PaymentDetails), typeDiscriminator: "PaymentDetails")] public abstract class PaymentDetails { ///