Skip to content

Conversation

@Andrew-Dickinson
Copy link
Member

@Andrew-Dickinson Andrew-Dickinson commented May 6, 2025

Adds a post_save hook 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 .env file to hopefully make it a bit less confusing for newcomers

Also edits the reconciliation script to add a basic regex parser for JSON exports from the #donations slack channel, since this appears to be the best source of truth we have for mapping subscription to install number

TODO:

  • Do integration testing with the live Stripe API after I get keys from Olivier
  • Prep data for MeshDB backfill so that after this merges we can populate all the existing subscriptions

@Andrew-Dickinson Andrew-Dickinson marked this pull request as ready for review May 6, 2025 04:57
@codecov
Copy link

codecov bot commented May 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.06%. Comparing base (8452a59) to head (c661182).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

)
if install_number_match:
install_number = install_number_match.group(1)
if install_number not in [
Copy link
Collaborator

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
Copy link
Collaborator

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants