Vulnerability in EPiServer.Forms

Try our conversational search powered by Generative AI!

Serialized Cart - Gift Card Payments



We have a requirement that users can apply multiple gift cards in the checkout page. We also need to display the list of applied gift cards (including gift card number). 

When the user adds a new gift card, we create a new GiftCardPayment and we add it on the current user's shopping cart.

We are using Serialized Cart feature, but I haven't found a way to read the Gift Card Number when we load the applied payments (we need this in case the user refreshes the page or comes back to the payment step).

Maybe is something I'm missing.

Thank you!

May 29, 2017 14:25

Have you tried



Edited, Jun 01, 2017 9:30

Yep, it is not populated. After looking at the serialized object in the database, the GiftCardNumber is saved as a property of the payment, but it is not deserialized. And I think this happens because "GiftCardNumber" is not a property of the SerializedPayment object. 





As you can see, the properties property is empty.

Jun 01, 2017 10:11

Ok, interesting.

I assume you're working with IPayment objects when trying to retrieve the data. Have you tried casting to GiftCardPayment? It seems like that's what the cart is ultimately serializing them as.

Edited, Jun 01, 2017 10:41

I tried, but at runtime, the IPayment is actually SerializablePayment which cannot be cast to GiftCardPayment. We ultimately reverted back to regular carts, but as soon as we find a way to deserialize extra payment information we will return to serialized carts. The performance implications are big.

Jun 01, 2017 11:13

Hi Adrian,

The Serializabled Cart feature works only with defined serializable objects such as: SerializableForm, SerializableShipment, SerializableLineItem, SerializablePayment, SerializableNote, SerializableOrderAddress (when deserializing cart components, it casts objetcs to corresponding serializable classes). In your case, the workaround could be: adding SerializablePayment to the cart instead of GiftCardPayment, and put all properties of GiftCardPayment you need into the Properties property of SerializablePayment:

payment.Properties["GiftCardNumber"] = 123;
payment.Properties["GiftCardSecurityCode"] = "abc";

/Bien Nguyen

Jun 13, 2017 6:06

Hi Bien, thank you for your answer, it makes sense. I will play with it and see how the entire workflow (all the way to the place order) will work.

Thanks again.

Jun 26, 2017 20:26
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.