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.
Solved! Go to Solution.
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.
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.