Add a post_save hook to keep Stripe metadata synced to MeshDB#892
Open
Andrew-Dickinson wants to merge 5 commits intomainfrom
Open
Add a post_save hook to keep Stripe metadata synced to MeshDB#892Andrew-Dickinson wants to merge 5 commits intomainfrom
Andrew-Dickinson wants to merge 5 commits intomainfrom
Conversation
e2f2dcc to
fe585c0
Compare
Codecov Report✅ All 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:
|
WillNilges
approved these changes
May 8, 2025
| ) | ||
| if install_number_match: | ||
| install_number = install_number_match.group(1) | ||
| if install_number not in [ |
Collaborator
There was a problem hiding this comment.
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 |
Collaborator
There was a problem hiding this comment.
Take care of this TODO?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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: