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!
They show me just “we couldnt load your data” that is for ios and android app, Also on PC cant see
how to fix it can someone help.. Tnx
]]>I have a coupon code set up for one particular email type entered into the ‘Allowed Email’ section via my coupon set up. However, it does not work as expected.
If the code is entered at checkout without ANY details entered into the ‘Billing details’ fields, the discount is still honoured.
Please see screen shot.
Any suggestions as to why this might be will be a big help – thanks
]]>I have overwritten the email template file of my theme but the problem is still there…
Thank you in advance for your help
]]>This is th page with the products listing: https://www.washdoglecco.it/shop/per-il-tuo-cane/
and this is the automatic “page 2” that woocommerce creates and that is not working: https://www.washdoglecco.it/shop/per-il-tuo-cane/page/2/
How can I fix this problem?
]]>I have the following problem, product categories pages content does not opens smoothly.
When on the product page https://armmetals.lv/lv/shop/ and clicking on the product content jerking.
For cahce I use – Lite speed cache.
Website created on: wordpress + woocommerce.
Thank you
]]>Thanky in advance
]]>Hey There, i want to add days for delivery as 0 for same day delivery, but i’m unable to. is there any thing you can do?
Thanks
]]>