woocommerce-gateway-stripe
woocommerce-gateway-stripe copied to clipboard
Double refunds still happening (triggered through web hook)
Despite this bugfix (https://github.com/woocommerce/woocommerce-gateway-stripe/pull/2581) I can still see double refunds in rare cases. Above bugfix usually prevents this by comparing refund ids and aborting the web hook if the refund id equals an already existing refund. But I think what might happen in rare cases is the following:
- A refund is created in WooCommerce and the stripe api is called returning the refund id.
- This refund id is then save with the order.
- If the response takes unusual long it can happen that the web hook (triggered by the api request) arrives before the api response is handled (and the refund id is saved) and therefore resulting in a double refund.
An easy but maybe not very elegant fix could be a simple sleep(5)
in the first line of the process_webhook_refund()
method.
This would give a bit more time for the original api response to be handled.