Serialized Cart - Gift Card Payments

Member since: 2010


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!

#179008 May 29, 2017 14:25
  • Member since: 2016

    Have you tried



    #179145 Edited, Jun 01, 2017 9:30
  • Member since: 2010

    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.

    #179148 Jun 01, 2017 10:11
  • Member since: 2016

    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.

    #179149 Edited, Jun 01, 2017 10:41
  • Member since: 2010

    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.

    #179151 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

    #179458 Jun 13, 2017 6:06
  • Member since: 2010

    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.

    #179949 Jun 26, 2017 20:26