Did you create a payment from your payment method and add that payment to the cart?
Yes, I did. I am not sure why it doesn't seem to work in a non-Quicksilver project.
It's pretty damn complex from what I've seen worked for a payments processor so far.
There is an insane number of moveable parts that are required to perfectly mesh for even simple transactions. Not much because of what the code does. The code base on the API alone is massive and basically contains a tonne of interlocking and interdependent data transmission pieces.
The pre-existing payment management systems and norms you will need to work with are not exactly the easiest to use, as others have already said.
If you are implementing your payment gatway as a Generic payment gateway, you may solve this issue by handling "routing" yourself.
Create a class that inherit from IPaymentProcessor, override ProcessPayment and then route to the different gateways depending on payment name.
public PaymentProcessingResult ProcessPayment(IOrderGroup orderGroup, IPayment payment, IShipment shipment)
{
if (payment.PaymentMethodName == PayExPaymentMethod.PaymentMethodSystemName)
{
return _payExPaymentGateway.ProcessPayment(orderGroup, payment);
}
if (payment.PaymentMethodName == VippsConstants.VippsSystemKeyword)
{
return _vippsPaymentGateway.ProcessPayment(orderGroup, payment);
}
return _genericPaymentGateway.ProcessPayment(orderGroup, payment);
}
I am assuming you have created payment options in Commerce Manager using the payment plugin you want to use. During checkout or setting payment method to your cart, cart requires you to use IPaymentMethod to create your payment and add the payment to your cart. Without this, it does not trigger the payment gateway/ plugin you have created.
Code would look something like below:
paymentMethod.CreatePayment(cart.GetTotal().Amount, cart);
cart.AddPayment(payment, _orderGroupFactory);
Whichever implementation you have for IPaymentMethod, ensure you have implemented your create payment to use your custom logic to assign correct payment method id amount etc. Usually a create payment method looks like this.
public override IPayment CreatePayment(decimal amount, IOrderGroup orderGroup)
{
ICreditCardPayment payment = orderGroup.CreateCardPayment(OrderGroupFactory);
payment.PaymentMethodId = PaymentMethodId;
payment.PaymentMethodName = SystemKeyword;
payment.Amount = amount;
payment.Status = PaymentStatus.Pending.ToString();
return payment;
}
Hope this helps!
~ Sujit
Hello everyone,
I am trying to spin up a custom payment gateway in my own project using the Quicksilver approach. If I add a new one in Quicksilver, I can make it work. In my own project, the payment processor never gets called. I see that you have to create a class implementing AbstractPaymentGateway and IPaymentPlugin in a shared project which is then referenced by Commerce and CMS. In Quicksilver they also have PaymentMethodBase (implements IPaymentMethod) which is used to spin up payment methods for each gateway. It appears that you put the magic string, SystemName, into the PaymentMethod you create from PaymentMethodBase, and then make sure to create a Payment type in Commerce Manager using that same magic string, as well as setting its class to the one you put in the shared project.
Then when Quicksilver fires up, there is a new payment method, and it will use your payment gateway code (you also have to add some views to make it not break, but the code is what matters).
Even if I bring in Quicksilver's PaymentMethodBase into my own project and do all the other steps, my payment processor will never be called.
Does anyone have any clues or a working example outside Quicksilver?
Thanks so much!
Kurt