-
Notifications
You must be signed in to change notification settings - Fork 69
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
Use fallback methods for updating the next payment date after migrating a stripe billing subscription #7176
Use fallback methods for updating the next payment date after migrating a stripe billing subscription #7176
Conversation
…r migrating a stripe billing subscription
Test the buildOption 1. Jetpack Beta
Option 2. Jurassic Ninja - available for logged-in A12s🚀 Launch a JN site with this branch 🚀 ℹ️ Install this Tampermonkey script to get more options. Build info:
Note: the build is updated when a new commit is pushed to this PR. |
Size Change: 0 B Total Size: 1.41 MB ℹ️ View Unchanged
|
…oopayments subscription
…et to WooPayments as a payment method
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.
I've tested migrating subscriptions under the following cases:
- use existing date just add a second (+1 second)
- delete next payment date and use stripe billing date
- delete next payment date in the stripe subscription data
- delete next payment date non-woopayments subscription and confirm it calculates date
- test calculating an invalid date
- test exception thrown in udpate_dates
I didn't come across any issues.
P.S. I pushed up a small change as per our discussion to remove the "SUCCESS" log because there are some cases were migration completes with errors that aren't recoverable or would not produce any different outcome if retried so we finish the migration.
Changes proposed in this Pull Request
This PR introduces multiple fallback mechanisms for updating a subscription's next payment date when it's migrated from Stripe Billing to on-site billing via tokens.
Prior to this PR it simply added 1 second to the current next payment date if it existed and it was in the future.
This still remains the 1st approach, however there's now 2 additional mechanisms if that first check fails (current next payment date is in the past for some reason):
current_period_end
is in the future, use it.$subscription->calculate_date()
.If all 3 fail, something has seriously gone wrong somewhere along the line and an error is logged to the migration log.
Testing
Setup
Testing scenarios
woopayments-subscription-migration
log file you should notice that the new next payment date is updated by 1 sec._schedule_next_payment
meta.woopayments-subscription-migration
log file you should notice that the new next payment date is pulled from Stripe._schedule_next_payment
meta.update_next_payment_date()
code to simulate missingcurrent_period_end
.woopayments-subscription-migration
log file you should notice that the new next payment date is calculated._schedule_next_payment
meta.update_next_payment_date()
code to simulate missingcurrent_period_end
.update_next_payment_date()
code to simulate$subscription->calculate_date()
returning an invalid date.woopayments-subscription-migration
log file you should notice an error message.npm run changelog
to add a changelog file, choosepatch
to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.Post merge