-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(esp-sync): schedule second sync upon subscription reactivation, just in case #3603
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Beautiful. It works.
I just have one comment/question/suggestion... Maybe we could use a different name for the Data Even, instead of subscription_renewed
...
This name gives the impression that it will be triggered after a successful renewal, and might lead to confusion when people hook into it in the future. Maybe "renewal_attempt"?
@leogermani good suggestion! 660fe4d updates the data event name (and the handlers/methods that use it) to clarify that distinction. (EDIT: and 0d6b92a removes some unintended changes that got swept up in this commit.) |
Co-authored-by: leogermani <leogermani@automattic.com>
## [5.8.2](v5.8.1...v5.8.2) (2024-12-09) ### Bug Fixes * **esp-sync:** schedule second sync upon subscription reactivation, just in case ([#3603](#3603)) ([9334295](9334295))
🎉 This PR is included in version 5.8.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
All Submissions:
Changes proposed in this Pull Request:
We fire an ESP contact sync whenever a Woo subscription status is updated. When a subscription undergoes automatic renewal, it rapidly changes status to
on-hold
when payment processing begins, and then toactive
once successful payment is confirmed. However, since this can happen so quickly it's possible that sync after theactive
update can happen before theon-hold
sync completes (a sort of race condition).Rather than trying to untangle the Woo Subscriptions logic here, the easiest thing to do is to schedule a second "backup" sync a few minutes later when a subscription status changes to
active
. This should ensure that the ESP contact is updated toactive
after a successful renewal even if the race condition occurs.How to test the changes in this Pull Request:
on-hold
status and again when the status changes toactive
(but note that it might not always happen in this order).active
sync completes, runwp cron event list
and confirm that a non-repeatingnewspack_scheduled_esp_sync
job is scheduled roughly two minutes in the future.wp cron event run newspack_scheduled_esp_sync
and confirm that the contact is synced to the ESP again with the correct "active" status.Other information: