I’m developing a custom payment gateway for WooCommerce that integrates with SATIM (payment operator in Algeria). Everything works fine, including processing payments and refunds. However, I encounter an issue with the refund process where the loading icon keeps spinning indefinitely, even though the refund is processed successfully, and I receive the confirmation email, refunded status.
Here are the details of my setup:
The refund is processed correctly, and the status is updated in WooCommerce.
I receive a 200 success response from the SATIM API.
There are no errors in the console or logs.
Code Overview:
Here’s the relevant part of my gateway class where I handle the refund:
public function process_refund($order_id, $amount = null, $reason = '') {
$order = wc_get_order($order_id);
if (!$order) {
return false;
}
if ($amount < 50) {
$notice = sprintf(esc_html__('Refund amount is less than 50%s'), $this->currency_symbol);
$this->log($notice);
$order->add_order_note('Refund Failed: ' . $notice);
} else {
$args = [
'body' => [
'userName' => $this->userName,
'password' => $this->password,
'orderId' => $order->get_transaction_id(),
'amount' => $amount * 100
]
];
$response = wp_remote_get(add_query_arg($args['body'], $this->api_refund_url));
$this->log(is_wp_error($response) ? $response : $response['body']);
if (!is_wp_error($response)) {
$response = json_decode($response['body'], true);
$response_code = intval($response['errorCode']);
$refund_message = intval($response['errorMessage']);
if ($response_code == 0) {
$refund_message = sprintf(esc_html__('Refunded %s%s'), $amount, $this->currency_symbol);
$this->log('Success: ' . wp_strip_all_tags($refund_message));
$order->add_order_note( $refund_message );
// Tried various methods to reload the page here
return true;
} else {
$this->log('Refund Failed: ' . $refund_message, 'error');
$order->add_order_note('Refund Failed: ' . $refund_message);
return false;
}
}
}
}
What I’ve Tried:
JavaScript Injection:
I attempted to inject JavaScript to reload the page using echo ‘<script type=”text/javascript”>window.location.reload();</script>’;, but it didn’t work.
Redirect with PHP:
Using wp_safe_redirect followed by exit to reload the page, but it seems WooCommerce’s AJAX handling doesn’t allow for PHP redirections directly.
Admin Footer Action:
Added a script in admin_footer to check a flag and reload the page, but this didn’t resolve the issue either.
Question:
How can I properly reload the WooCommerce admin page after a successful refund to stop the loading icon from spinning indefinitely? Has anyone encountered a similar issue or have any suggestions on how to resolve this?
Thank you in advance for your help!
I am using this shortcode site_reviews
and applied filters to it. When I click on one of the links of the pagination the page reloads to show them, is there a way to not have the page reload? Is there a way to make it work like filters? They refresh the content without reloading the page.
Just FYI, when pagination is set to “load more”, the content is updating without reloading the page.
Thanks in advance,
Vahan
It says connected at LMS Chat plugin but the page is always reloading.
If I force to stop de reload, clicking at the “cross”, I can open the chat and write messages. But If I dont stop de loading page, it will be reloading over and over
]]>I am configuring Complianz cookie banner, but when I got to the page ‘cookie banner’ where you can define the lay-out of the cookie banner, I clicked ‘save’ and since then this page keeps loading, reloading, reloading and reloading again and again.
This makes the plugin unmanagable. How can I stop this?
I already deleted the cookies from Complianz, logged out and in of the site dashboard and deactivated some other plugins.
Thanks for helping me out.
David
]]>It just reloads the current category archive/dynamic page. Am I missing something?
]]>I wonder if you could help. I’ve a problem with a form (Multistep). Unfortunately the form continuously tries to reload after donation is received, without success.
https://capture.dropbox.com/v4usKQB2iMbBnbaf
It’s all set up and working correctly other than that…
Payment received in Stripe –
https://capture.dropbox.com/kPy3isO2HICbjw4H
Payment notifications received in website GiveWP dashboard –
https://capture.dropbox.com/1XYIo4Y8cAibQSN1
The logs confirm the web hook is receiving data and working correctly –
https://capture.dropbox.com/OadO9rpuSweCtB3D
…but the form is not reloading.
I took a quick look in the Chrome Console, it’s showing a website error: ‘Port closed before a response was received’ that relates to the form –
https://capture.dropbox.com/UK1BdioPZg0fjn3o
Not sure if that’s relevant.
If you could take a look a suggest a solution, it would be greatly appreciated. Thank you.
All the best.
]]>I am having an issue which just started occurring today.
The pages of my site just refresh themselves randomly, often while I am working and I end up having to redo my work.
It has happened:
– On the theme options page
– While editing a page
– While editing a product
– While viewing a product on the front-end
This only started happening after I enabled the page cache and preloading. I have now disabled the page cache and the plugin but am still having this issue.
]]>I’ve tried disabling plugins to solve the issue but haven’t found something that works yet.
Any help would be greatly appreciated! Thanks.
]]> console error: tcx-fa.min.js?ver=9.3.0:1 Uncaught TypeError: Failed to execute ‘observe’ on ‘MutationObserver’: parameter 1 is not of type ‘Node’.
at Gt (tcx-fa.min.js?ver=9.3.0:1)
at tcx-fa.min.js?ver=9.3.0:1
the errors comes straight out of your plugin.
]]>