-
Notifications
You must be signed in to change notification settings - Fork 28
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 stripe subscription upgrade failures #831
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅ ✅ All tests successful. No failed tests found. 📢 Thoughts on this report? Let us know! |
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## main #831 +/- ##
===========================================
Coverage 96.23000 96.23000
===========================================
Files 812 812
Lines 18575 18587 +12
===========================================
+ Hits 17876 17888 +12
Misses 699 699
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
# Only update if there isn't a scheduled subscription | ||
if not subscription_schedule_id: | ||
if not subscription.schedule: |
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.
love this ngl
extra=dict(pending_update=indication_of_payment_failure), | ||
) | ||
else: | ||
# payment successful |
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.
will delinquent ever be true at this point where we'd want to set to false?
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.
love this suggestion, but "yes and"ed it with this change https://github.com/codecov/codecov-api/pull/831/files#diff-dda355f2f33801fe525e8ba51493017a8957e35710e9dc1d4affed3940e18685R56 (clearing delinquency in update_plan
!)
From what I could tell, we are only using plan_service.update_plan
in a situation where the owner
should not be delinquent
, so just make sure that field is set correctly while we're updating the owner obj.
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.
looks good! Could we add the stripe docs you were looking at to the review description?
081b72c
to
a6fdc8f
Compare
a6fdc8f
to
536f112
Compare
❌ 1 Tests Failed:
View the top 1 failed tests by shortest run time
To view individual test run time comparison to the main branch, go to the Test Analytics Dashboard |
Test Failures Detected: Due to failing tests, we cannot provide coverage reports at this time. ❌ Failed Test Results:Completed 2303 tests with View the full list of failed testspytest
|
Purpose/Motivation
We were eagerly updating the user's
plan
in the specific case where they already have asubscription
and they are upgrading. We were updating without checking that the payment was successful, so in the case where we have updated theplan
but the stripe payment fails, we were bumping the user all the way back to free tier.Links to relevant tickets
codecov/engineering-team#2407
stripe's docs: https://docs.stripe.com/billing/subscriptions/pending-updates
What does this PR do?
Only update the plan if the payment was successful. If it's not successful, reject the changes and give they user the delinquent pop-up. The user in our db and in Stripe's system stays on the original plan until they payment is successful.