November Happy Hour will be moved to Thursday December 5th.

How to make serializable carts to work with ICreditCardPayment (Authorize.NET)?

Vote:
 

I am trying to enable serializable carts in our project and after some testing found that it doesn't work with Authorize.NET.

I am adding ICreditCardPayment correctly with new APIs:

var payment = orderGroup.CreateCardPayment(_orderGroupFactory);

// Fill the properties ..

cart.AddPayment(payment, _orderGroupFactory);

_orderRepository.Save(cart);

But when I load the card next time it doesn't have my payment, but instead it has SerializablePayment which doesn't have any of my filled up properties. It also does not have billing address anymore.

Is there a way to configure serializable carts to work with ICreditCardPayment?

I have Commerce 11.2.1.

#183038
Oct 03, 2017 17:04
Vote:
 

Sounds like a bug to me. How do you fill the properties? Do you use the .Properties property? 

#183039
Oct 03, 2017 17:22
Vote:
 

No, I am just setting properties on the ICreditCartPayment:

payment.CardType = CardType;
payment.PaymentMethodId = PaymentMethodId;
payment.PaymentMethodName = SystemKeyword;
payment.Amount = amount;
payment.CreditCardNumber = CreditCardNumber;
payment.CreditCardSecurityCode = CreditCardSecurityCode;
payment.ExpirationMonth = ExpirationMonth;
payment.ExpirationYear = ExpirationYear;
payment.Status = PaymentStatus.Pending.ToString();
payment.CustomerName = CreditCardName;
payment.TransactionType = TransactionType.Sale.ToString();
#183060
Oct 04, 2017 9:19
Vote:
 

That's bad. I'll file a bug for this and we will look into it ASAP. Thanks for bringing it into our attention.

#183062
Oct 04, 2017 9:36
Vote:
 

I checked the database and it looks like that the data is stored properly.

"Payments": [{
    "__MetaClass": "CreditCardPayment",
    "CreatorId": null,
    "ModifierId": null,
    "Created": "2017-10-03T14:48:51.6390544Z",
    "Modified": "2017-10-03T14:48:51.6390544Z",
    "CardType": "Generic",
    "CreditCardNumber": "4007000000027",
    "CreditCardSecurityCode": "123",
    "ExpirationMonth": "10",
    "ExpirationYear": "2017",
    "PaymentStatus": null,
    "ProviderPaymentId": null,
    "ProviderProfileId": null,
    "ImplementationClass": "Mediachase.Commerce.Orders.CreditCardPayment,Mediachase.Commerce",
    "AuthorizationCode": null,
    "OrderGroupId": "0",
    "PaymentMethodId": "4b6e692f-d6fb-4552-9439-3a39d2251316",
    "Status": "Pending",
    "BillingAddressId": "Billing",
    "OrderFormId": "0",
    "PaymentMethodName": "Authorize",
    "ValidationCode": null,
    "PaymentId": "-3",
    "TransactionID": null,
    "Amount": "96.5000000000",
    "PaymentType": "CreditCard",
    "TransactionType": "Sale",
    "ProviderTransactionID": null,
    "CustomerName": "Asda"
}],

It seems that loading the cart does not restore the state properly.

#183063
Oct 04, 2017 9:39
Vote:
 

@Maris: After investigation and tests, Save cart with added payment seems ok to me.

Could you give me more details about how to reproduce your bug ( which methods/API did you use to load the cart, where/when do you use it... ) ?

#183164
Edited, Oct 06, 2017 6:10
Vote:
 
<p>Not the Save is working wrongly, but loading. Instead of loading ICreditCartPayment, it loads SerializablePayment.</p> <p>I am loading the cart like this:</p> <pre class="brush:csharp;auto-links:false;toolbar:false" contenteditable="false">var cart = _orderRepository.LoadCart&lt;ICart&gt;(_customerContext.CurrentContactId, Mediachase.Commerce.Orders.Cart.DefaultName, _currentMarket);</pre> <p></p>
#183217
Oct 09, 2017 8:42
Vote:
 

To be clear, just CreditCard data is missing when loading SerializableCart because SerializablePayment doesn't have any property related to CreditCard data like CreditCardNumber, CreditCardSecurityCode, ExpirationMonth, ExpirationYear ...

Other payment info like Amount, PaymentMethodName... still loaded correctly.

And the BillingAddressId was stored in DB instead of entire BillingAddress so when load data from SerializableCart the BillingAddress will be null.

 

It should be able to deserialize Payment info to CreditCartPayment base on ImplementationClass property. I'm working on it right now .

You can do a workaround to get the CreditCard info by using Hashtable Properties  of SerializablePayment to store CreditCard info if you can't wait for the change laughing.

For example :

payment.Properties["CreditCardNumber"] = "4007000000027";


#183281
Edited, Oct 10, 2017 13:16
Vote:
 
<p>Thanks, Khiem. I will wait for the fix and then switch over to Serializable carts.</p>
#183282
Oct 10, 2017 13:20
Vote:
 

SerializableCart always return SerializablePayment in OrderForm and we also want to have Credit Card info from ICreditCardPayment.

So I use SerializableCreditCardPayment which inherited from SerializablePayment and ICreditCardPayment to make sure we can load all data about Credit Card payment.

After load Cart, you will have SerializableCreditCardPayment instead of SerializablePayment and you can cast it to ICreditCartPayment if you want.

I hope this can fix your issue laughing.

Thank you for reporting it.

#183364
Edited, Oct 12, 2017 6:25
Vote:
 
<p>In which version it will be available?</p>
#183368
Oct 12, 2017 8:55
Vote:
 

As usual - it's done when it's done :) . The current version under testing is 11.3 so the bug will be fixed in a later version, probably 11.3.1 or 11.4 - we don't know yet 

#183370
Oct 12, 2017 9:24
Vote:
 

There were some issues with the bug fix, and we had to push back. It will probably be in Commerce 11.5 which is CMS-11 compatible. Is that something you can afford? 

#185094
Nov 09, 2017 12:51
Vote:
 

Yes, it is fine. We are not using Serialized carts yet because of this issue. But once it will be available, will move forward.

#185095
Edited, Nov 09, 2017 12:52
Vote:
 
<p>For future visitors, the bug was fixed and released in Commerce 11.4.1&nbsp;</p> <p>We of course recommend to upgrade to latest version possible&nbsp;</p>
#189430
Mar 19, 2018 13:19
Vote:
 

@Khiem Nguyen Duy: Regarding this comment, is this something that has been implemented yet?

"It should be able to deserialize Payment info to CreditCartPayment base on ImplementationClass property. I'm working on it right now ."

The reason I'm asking is that we have our own custom payment method implementations that I'd like to deserialize into from Serializable Payments.

#193499
May 30, 2018 14:33
Vote:
 

@Martin : Yes, we did some changes in PaymentConverter of Commerce 11.4.1 release.


Make sure YourCustomPayment inherit SerializablePayment and specify the converter for it : [JsonConverter(typeof(PaymentConverter))].

When create payment :

public IPayment CreatePayment()
{
  return new YourCustomPayment { ImplementationClass = typeof(YourCustomPayment).AssemblyQualifiedName };
}

Based on ImplementationClass of YourCustomPayment, PaymentConverter can deserialize SerializablePayment into YourCustomPayment.

#193543
Edited, May 31, 2018 6:43
Vote:
 

@Khiem: I am using a custom payment and passing in the ImplementationClass when adding the payment to the cart. Using cart.AddPayment method. However, when ProcessPayment is called in my custom payment gateway I get the IPayment Object which is iternally a 'SerializablePayment' object.

Following your last comment, I understand that I should get a CustomPayment object back. Is there a something I need to do in ProcessPayment method to convert?

    [Serializable]
    [JsonConverter(typeof(PaymentConverter))]
    public class BarclaysFusePayment : SerializablePayment
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="BarclaysFusePayment"/> class.
        /// </summary>
        public BarclaysFusePayment()
        {
            this.Properties = new Hashtable();
            this.BillingAddress = (IOrderAddress)new SerializableOrderAddress();
            this.PaymentType = PaymentType.Other;
            this.ImplementationClass = typeof(BarclaysFusePayment).AssemblyQualifiedName;
        }
        ...
    }

The following code use to work with Mediachase version but now thows an exception as it cant cast 

var cardPayment = payment as BarclaysFusePayment;

Admittedly, we've not upgraded in a few years we are upgrading from Mediachase.Commerce 11.8.3.0 to Mediachase.Commerce 13.32.0.0

#279013
Apr 22, 2022 16:52
Vote:
 

The thread is very old so it's best to create a new thread (And link to this if necessary).

You should not inherit from SerializablePayment. It is an internal implementation. Should extend IPayment instead.

What do you return in your ProcessPayment exactly? 

#279150
Apr 25, 2022 11:18
Vote:
 

Thanks Quan, I've created a new thread. I've also added a bit more of the payment gateway class to give context.

I'll try using IPayment in the meantime and report back if that works

#279165
Edited, Apr 25, 2022 13:45
* 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.