i'm working on a Payment Provider and particularly PaymentGateway class. My Question is when we click on "Cancel Order" on Commerce Manager Which method it (Workflow) trigger in PaymentGateway Class? Like when we do refunds it trigger ProcessPayment method with Payment TransactionType as Credit.
sdk.episerver.com/commerce/1.1.2/Content/User%20Guide/OrderManagement/OrderProcessReturnExchange.htmUsing Commerec Manager you can create a return and can develop a PamentGateway to ProcessRefunds. You can add a tab with your order details also and can add process refunds from commerce Mannager.
You will need a new Payment Gateway to process refunds.
When you press that button, a magic thing happens, and the payment gateway will be called with method ProcessPayment(Mediachase.Commerce.Orders.Payment payment, ref string message), and payment.TransactionType will be TransactionType.Credit.ToString() (so you can credit money back to customer's account)
I want to Cancel Order and void payments (not refund process - So it is before complete shipment & creating refund - Order is in "InProcess" state). You are saying when "Cancel Order" button Clicked Payment Gateway will be called with method ProcessPayment(Mediachase.Commerce.Orders.Payment payment, ref string message), and payment.TransactionType will be TransactionType.Credit.ToString()??
Note: I'm Developing Custom PaymentGateway. Refunds are working fine but trying to hook functionality around "Cancel Order" Button.
At that point you can refend or void - depends on how your payment gateway works.
On cancelling Order It will call Payment Gateway
Create and a new Payment gate for VOID
Just an update
I have contacted with EpiServer Support and according to them cancel order button does not call Payment Gateway. Below is what they said;
In PurchaseOrder-ObjectView.xml under the directory \wwwroot\Apps\Order\Config\View\Forms\ of your commerce manager site you can find the configuration for this button.
See the Button element at View/Form/ButtonSets/add/ButtonSet/Button with id of "CancelOrderButton". You can see the commandName attribute set to "btn_CancelOrderBtn". If you search further down the file, you can find the configuration for this command in Commands/add/Command; see the matching Command element with id set to "btn_CancelOrderBtn".
There is a type specified here that implements the command handling logic: Mediachase.Commerce.Manager.Order.CommandHandlers.PurchaseOrderHandlers.CancelPurchaseOrderHandler, Mediachase.ConsoleManager
I decompiled this type in my local install, Mediachase.ConsoleManager.dll assembly version 22.214.171.1241. Here you can see the IsCommandEnable() and DoCommand() methods. The underlying classes doing the work are OrderStatusManager and PurchaseOrderManager. These are in the Mediachase.Commerce.dll assembly.
I checked further down the line from OrderStatusManager's CancelOrder() to RecalculatePurchaseOrder() to the proper overload. There I could see the calls down to the workflow manager.
The workflow being called in this case has the string key of "RecalculatePurchaseOrderWorkflow". In ecf.workflow.config under the directory \wwwroot\Configs\ you can find this string key maps to the following element:
<add name="RecalculatePurchaseOrderWorkflow" displayname="Recalculate Purchase Order" description="Recalculate Purchase Order" type="Mediachase.Commerce.Workflow.PurchaseOrderRecalculateWorkflow, Mediachase.Commerce.Workflow" xomlpath="" rulespath="" />
Checking the definition for this workflow there's evidence that shows that the payment gateway is not engaged.
I discussed this with my colleagues and the consensus is that this appears to make sense. At the point that a purchase order is cancellable in this UI, the shipment has not yet been released, so it is likely that there is only an authorization.
Hope this information helps you find what you're looking for.
Any updates on this? I also need to void a payment reservation on order cancel.