AI OnAI Off
Regarding your first attempt,
Activation error occurred while trying to get instance of type, key "TermsPayment"
is not caused by
It is unable to convert it to IPayment and gives a null exception.
The problem is your default constructor (as seen by structuremap) is public TermsPayment(MetaClass metaClass), and it does not know how to create an instance of MetaClass.
I am trying to implement a custom payment type for Serialized carts, it is failing when we convert the cart to a purchase order. Below are the different ways I tried out but I am still having the same issue.
Attempt 1: Inheriting from Payment (I opened the reflector and I see payment types like CashCardPayment, CreditCardPayment etc are doing the same)
I also have a TermsPaymentMethod class that implements PaymentMethodBase which is an abstract class.
I then create a Payment type inside my checkout controller and use the CreatePayment(decimal amount, IOrderGroup orderGroup) of IPaymentMethod which in my case triggers TermsPaymentMethod implementation.
I can see that my implementation class is now TermsPayment as well in the payment object. But it fails when I convert the cart to a purchase order.
https://www.screencast.com/t/y0czxqCnP5m
Below is the stack trace:
Activation error occurred while trying to get instance of type, key "TermsPayment"
Upon checking the reflector I see that Epi tries to create a payment type :
It is unable to convert it to IPayment and gives a null exception.
Attempt 2:
Everything is the same as the previous attempt other than the payment type implementation
I refferd to the article below for the second attempt:
https://world.episerver.com/forum/developer-forum/Episerver-Commerce/Thread-Container/2017/10/how-to-make-serializable-carts-to-work-with-icreditcardpayment-authorize-net/
But still have the same issue when it converts it to a purchase order:
"Value cannot be null"
I am also attaching a screen shot of the PaymentMethod table:
https://www.screencast.com/t/tRdQ5xs4
I have been struggling on this since 2 days now, any help or leads on this is highly appreciated.