Automattic / woocommerce-payments

Accept payments via credit card. Manage transactions within WordPress.
https://wordpress.org/plugins/woocommerce-payments/
Other
173 stars 69 forks source link

Ensure that subscriptions webhooks do not cause duplicate actions #4032

Open htdat opened 2 years ago

htdat commented 2 years ago

Description

Similar to https://github.com/Automattic/woocommerce-payments/issues/3814 and with more reasoning in this comment https://github.com/Automattic/woocommerce-payments/issues/3814#issuecomment-1066691553, we'd like to ensure that if somehow the same webhook event is processed multiple times, it does not cause duplicate actions, for example, updating order status or adding notes in the order management page.

Acceptance criteria

Dev notes

An approach used in this PR https://github.com/Automattic/woocommerce-payments/pull/3975 is to check if a specific order note exists with WC_Payments_Order_Service::order_note_exists. We only allow processing data if the note does not exist.

Additional context

cc @Automattic/helix

thracefulton commented 2 years ago

4858048-zen appears to be experiencing this issue. They are using WooCommerce Payments Subscriptions and are seeing duplicated order notes and email notifications for single payment events.

haszari commented 2 years ago

Labeling as high priority in case there's something that we can tidy up here.

Next step: timeboxed investigation and log any specific follow up if needed.