SaaS CMS has officially launched! Learn more now.

"IExtendedProperties" on payment disappear after saving cart as a purchaseOrder


Hi Forum,

I have a question about "IExtendedProperties". After saving a cart as a purchaseOrder, the values added to "IExtendedProperties" on payments disappear.

Is it a bug or intended behavior. Do I misunderstand something? :)

Screenshot cart order form

Screenshot purchaseOrder order form


var orderReference = _orderRepository.SaveAsPurchaseOrder(cart);
var purchaseOrder = _orderRepository.Load<IPurchaseOrder>(orderReference.OrderGroupId);



Edited, Sep 30, 2019 21:01

No, that shouldn't disappear. We are storing Project Name and retrieving that back to show on Order History Block.

OrderName = order.Properties[MetadataPlusFields.ProjectName.Name]?.ToString();

This is propery information

public static readonly MetadataPlusField ProjectName = new MetadataPlusField
    DataType = MetaDataType.ShortString,
    Description = string.Empty,
    FriendlyName = "Project Name",
    IsEncrypted = false,
    IsMultiLanguage = false,
    IsNullable = true,
    IsSearchable = false,
    Length = 512,
    Name = "ProjectName",
    Namespace = OrderContext.Current.OrderGroupMetaClass.Namespace,
Oct 01, 2019 10:12

Hi Praful :)

Thank you for your reply.

Properties on our order forms and line items are working fine. It is only on our payments that the value disappears when saving a cart as a purchaseOrder!


Oct 01, 2019 10:50

Can you share your code where you are setting those values on the payment?

Edited, Oct 01, 2019 13:02

Hej Erik :)

Here is a simplified version of the code:

public IPayment CreatePayment(ICart cart, Guid paymentMethodId, decimal amount) {
            var payment = cart.CreatePayment();
            PopulatePayment(payment, paymentMethodId, amount);
            return payment;

private void PopulatePayment(IPayment payment, Guid paymentMethodId, decimal amount) {
            var row = _paymentService.GetPaymentMethodRow(paymentMethodId);
            payment.Amount = amount;
            payment.PaymentMethodId = paymentMethodId;
            payment.PaymentMethodName = row?.Name;
            payment.Status = PaymentStatus.Pending.ToString();
            payment.TransactionType = TransactionType.Authorization.ToString();

var orderForm = cart.GetFirstForm();
var voucherPayment = CreatePayment(cart, voucherPaymentMethodId, voucherAmountTobeDeducted);
voucherPayment.Properties[Metadata.Payment.VoucherCode] = response.Code;
voucherPayment.Properties[Metadata.Payment.VoucherAvailableAmount] = response.Amount;
_orderRepository.Save(cart) // IOrderRepository

And this is how I experience it when I debug:

        public IPurchaseOrder PlaceOrder(ICart cart)
				// Below is what I see when I debug (Can also be seen on the screenshots I have linked to)
				var cartForm = cart.GetFirstForm(); // Debug shows: Payment in cartForm got properties
                var orderReference = _orderRepository.SaveAsPurchaseOrder(cart);
				var purchaseOrder = _orderRepository.Load<IPurchaseOrder>(orderReference.OrderGroupId);
				var orderForm = purchaseOrder.GetFirstForm(); // Debug shows: Payment in orderForm got no properites


Oct 01, 2019 14:47

Can you try to remove the IPayment and just use GiftCardPayment directly?

public GiftCardPayment CreateVoucherPayment(ICart cart, Guid paymentMethodId, decimal amount, string voucherCode, decimal voucherAmount) {
            var row = _paymentService.GetPaymentMethodRow(paymentMethodId);
            var payment = new GiftCardPayment{
                Amount = amount;
                PaymentMethodId = paymentMethodId;
                PaymentMethodName = row?.Name;
                Status = PaymentStatus.Pending.ToString();
                TransactionType = TransactionType.Authorization.ToString()};
            payment.Properties[Metadata.Payment.VoucherCode] = voucherCode;
            payment.Properties[Metadata.Payment.VoucherAvailableAmount] = voucherAmount;
            return payment;

var voucherPayment = CreateVoucherPayment(cart, voucherPaymentMethodId, voucherAmountTobeDeducted, response.Code, response.Amount);

(Disclaimer: free hand code so might not even be formatted correctly)

Oct 01, 2019 15:16

Did  you add equivalent metafields to your payment? 

Oct 01, 2019 15:33

Hi Quan,

Dooh :/

It helped adding a equivalent metafield to payment? 

Thanks a lot to all of you for spending time looking into my issue. It is much appreciated.

Thanks! :)

Oct 02, 2019 20:13
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.