order.created webhook firing twice
-
Hi:
UPDATE: I had the body of the
nullrequest wrong at first. Updated the text below accordingly.I’ve searched these forums (and google in general): a bunch of ppl have raised Qs about WC webhooks firing multiple times. I’ve read all those, they are not the same as this situation.
Firstly: everything I mention here is configured via WP-CLI, not the UI. Not sure it matters, but it’s probably significant.
Also: all this is only running on dev ATM. There is no live presence.
The environment is dockerised. Also unlikely to be relevant, but I figured I’d mention it anyhow.
We have added a webhook thus:
wp wc webhook create \
--name="Order Created Hook" \
--status="active" \
--topic="order.created" \
--delivery_url="${IV_WEBHOOK_BASE_URL}/api/webhook/order-created" \
--user=adminThis also uses a
woocommerce_webhook_http_argsfilter to add anAuthorizationheader & Bearer token. We do not use the secrets mechanism provided by default for WC webhooks.This works: we’re getting the webhook request on the target server whenever an order is placed. Cool.
However at exactly the same time as the successful webhook with the order payload is made, WC is making a second request to the URL with an empty request body. This also does not include the
Authorizationheader, so the response from our server is a401.This happens on every
order.createdevent being fired.The interesting thing is that if I take the auth-check off the end point, and the “null” request then gets a
200response… the second request stops being made on subsequentorder.createdevents. It’s like WC is “checking” something (incorrectly), but once it gets its200it’s happy and stops asking.Unlikely to be relevant, but slightly edge-case-y… the webhook URL is not HTTPS, as it’s just running across the docker network via
host.docker.internal. The WP container and our app container is on the same VPS. Well: currently it’s just on my own dev PC 😉So how come WC is making this second request, and – more importantly – how do I make it stop? 😉
I’m pretty new to WP/WC (but not new to dev), so unsure what other info might help: I’m happy to provide any other info that might be useful to this situation. I skipped posting the status report thing, because that seemed to be pretty high level, and didn’t contain anything that seemed relevant here: it looked like it’d be clutter.
Cheers for any insight anyone might have!
The topic ‘order.created webhook firing twice’ is closed to new replies.