cancel
Showing results for 
Search instead for 
Did you mean: 

Abort refund process

SOLVED

Abort refund process

Hello everyone,

 

I am using the following tutorial to implement a refund process for a payment gateway:

https://www.mageplaza.com/magento-2-create-payment-method/

 

The tutorial describes how to implement a refund function:

    public function refund(\Magento\Payment\Model\InfoInterface $payment, $amount)
    {
        // Your code logic
return $this; }

In this function, I am communicating with a remote gateway in order to issue the refund on the payment processor side.

 

I would like the M2 refund operation to happen only if the remote operation succeeds => if the remote operation fails, the refund in M2 should be aborted.

 

Currently, the M2 refund happens even if the remote operation fails.

How can I abort the M2 refund operation from this function?

 

Thanks a lot for your answers.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Abort refund process

Hello @davidfiaty

 

you need to thrown for that, please check below example for same

 

https://github.com/Inchoo/magento2-Inchoo_Stripe/blob/master/Model/Payment.php#L145

 

 

If works then mark as a solution.

 

 


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer

View solution in original post

1 REPLY 1

Re: Abort refund process

Hello @davidfiaty

 

you need to thrown for that, please check below example for same

 

https://github.com/Inchoo/magento2-Inchoo_Stripe/blob/master/Model/Payment.php#L145

 

 

If works then mark as a solution.

 

 


Problem solved? Click Kudos & Accept as Solution!
Sunil Patel
Magento 2 Certified Professional Developer & Frontend Developer