Revert status of "Return Form" from Complete back to Awaiting Completion when refund transaction was failed


My approach is creating a return form and then process my refund to payment gateway. The status of return form is alway Completed after I click Complete Return and then it will trigger the ProcessPayment which process the refund payment transaction.

In case of the refund transaction is failed, the return form has already completed and cannot trigger refund transaction again. So in this situiation, return form was marked as completed but customer does not recieve money back.

First attemp: I've tried to set the return form status back to Awaiting Completion but the problem is that I cannot determine which was the correct return form to revert. The refund transaction which was failed does not have any relationship to any return form than refund amount.

Second attemp: I try to create new payment transaction to process refund but have no Idea about doing this.

Have anyone dealed with this kind of refund situiation ?

EPiServer Commerce -

Episerver Web Content Management System -

Edited, Jul 16, 2021 11:06

Hi Tuan,

In a standard payment gateway solution; the return will not get completed unless the PaymentProcess method returns a PaymentProcessResult variable marked as successful.

Can you post me a screenshot of the PaymentProcess method inside your payment gateway? Specifically the area where you are checking where the TransactionType is Credit.

Jul 16, 2021 17:56

Hi Surjit, thanks for replying to me.

I've used the QuickSilver sample site & also PayPal payment gateway plugin provided by Episerver.

I just change the code to return an PaymentUnsuccessfulResult to pretend the situiation that error happen like this:

if (cart == null && orderGroup is IPurchaseOrder)
     // When "Refund" shipment in Commerce Manager, this method will be invoked with the TransactionType is Credit
     if (payment.TransactionType == TransactionType.Credit.ToString())
           // Errors happened
           return PaymentProcessingResult.CreateUnsuccessfulResult("some errors happen here");

And then after this, the return was completed and a failed credit payment transaction has been created.

Jul 16, 2021 19:23

That is out of the ordinary.

Are you using Commerce Manager or Order Management to mark the return as complete?

Both use a different set of methods to call the gateway and move the return status along. Try the other one to see if you experience the same behaviour.

Jul 16, 2021 21:40

I've used both Commerce Manager & Order Management.

With Order Management, I return PaymentUnsuccessfulResult it seem like a bug in the Episerver when the Order Management was blank, not thing happen.

And the "completed return when refund fail" issues occcurred when I processed with Commerce Manager.

Jul 19, 2021 3:06

I guess from here it feels like you'll need to do some exploratory debugging.

Posting a screenshot of Order Management blank screen would be good to give more context.

Make sure the breakpoint hits at the point where you think the PaymentUnsuccessfulResult is being returning in the PayPal gateway.

Even making sure the payment settings in Commerce Manager are all correct.

Jul 19, 2021 8:00

Thank you

<a href = ""></a>

Edited, Jul 22, 2021 14:48
* 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.