-
Notifications
You must be signed in to change notification settings - Fork 28
Add a post_save hook to keep Stripe metadata synced to MeshDB #892
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
base: main
Are you sure you want to change the base?
Conversation
e2f2dcc to
fe585c0
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #892 +/- ##
==========================================
+ Coverage 94.95% 95.06% +0.11%
==========================================
Files 98 99 +1
Lines 4180 4277 +97
==========================================
+ Hits 3969 4066 +97
Misses 211 211 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| ) | ||
| if install_number_match: | ||
| install_number = install_number_match.group(1) | ||
| if install_number not in [ |
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.
Can you add a comment or something to explain these magic numbers?
|
|
||
| @receiver(post_save, sender=Install, dispatch_uid="update_stripe_subscription") | ||
| @skip_if_flag_disabled("INTEGRATION_ENABLED_UPDATE_STRIPE_SUBSCRIPTIONS") | ||
| @advisory_lock("update_stripe_subscription") # TODO: Test this race condition |
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.
Take care of this TODO?
Adds a
post_savehook so that when our pointer to the stripe subscription ID is changed, we tell stripe about it. This makes it much easier for humans to do the reverse mapping of "what install number does this subscription correspond to"In the event of a conflict, MeshDB is considered the source of truth and we quietly update Stripe to maintain consistency. However this should be super rare, because editing this metadata is not possible via the stripe UI, and we are the only tool editing it
Also rearranged the
.envfile to hopefully make it a bit less confusing for newcomersAlso edits the reconciliation script to add a basic regex parser for JSON exports from the
#donationsslack channel, since this appears to be the best source of truth we have for mapping subscription to install numberTODO: