- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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