Skip to content

fix(practices): delete the Stripe customer only after the destroy commits - #1142

Open
raulriera wants to merge 1 commit into
masterfrom
fix/stripe-delete-after-commit
Open

fix(practices): delete the Stripe customer only after the destroy commits#1142
raulriera wants to merge 1 commit into
masterfrom
fix/stripe-delete-after-commit

Conversation

@raulriera

Copy link
Copy Markdown
Member

Summary

  • delete_stripe_customer ran as before_destroy, inside the destroy transaction — if the DB destroy rolled back, the practice survived in the database but its Stripe customer (and any subscriptions) had already been deleted externally
  • Moved to after_commit on: :destroy, so Stripe is only touched once the deletion is durable; the existing Stripe::StripeError rescue still keeps destroy resilient when the customer is already gone

Test plan

  • Red test: rolled-back destroy still deleted the Stripe customer
  • Green after fix; existing destroy/no-customer/already-gone tests still pass
  • Full suite passes (523 runs, 0 failures)

…mits

The before_destroy callback called Stripe inside the destroy
transaction, so a rollback left the practice in the database with its
Stripe customer (and subscriptions) already deleted. Move it to
after_commit on: :destroy; the existing StripeError rescue keeps
destroy resilient when the customer is already gone.
@github-actions github-actions Bot added the fix A bug has been resolved label Aug 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix A bug has been resolved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant