Handle Stripe payment_method.detached webhook events#11171
Open
pieterbeulque wants to merge 1 commit intomainfrom
Open
Handle Stripe payment_method.detached webhook events#11171pieterbeulque wants to merge 1 commit intomainfrom
pieterbeulque wants to merge 1 commit intomainfrom
Conversation
Listen to Stripe's payment_method.detached webhook and soft-delete the corresponding PaymentMethod so the customer portal no longer displays stale last4/brand metadata after the card is removed on Stripe. Fixes #6100
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
OpenAPI ChangesNo changes detected in the OpenAPI schema. |
Contributor
|
Preview Environment |
frankie567
approved these changes
Apr 23, 2026
Member
frankie567
left a comment
There was a problem hiding this comment.
Good! Make sure to enable the event on the webhooks in Stripe:
- Prod: https://dashboard.stripe.com/acct_1LzIVeDG1jUQrXwC/workbench/webhooks/we_1N7wTPDG1jUQrXwCia90pFZ3/edit
- Sandbox: https://dashboard.stripe.com/acct_1Q025lDIA9pgt25r/test/workbench/webhooks/we_1Q0IiTDIA9pgt25rgDDGWh94/edit
Let me know if you need assistance with that :)
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.
I threw #6100 straight into Claude Code , feel free to dismiss the PR.
Summary
Adds support for handling Stripe
payment_method.detachedwebhook events to soft-delete payment methods when they are detached from a customer in Stripe.What
payment_method_detachedtask handler inpolar/integrations/stripe/tasks.pyto process Stripe webhook events when a payment method is detachedget_by_processor_idmethod toPaymentMethodRepositoryto look up payment methods by processor and processor IDpayment_method.detachedevent in Stripe webhook endpoints configurationWhy
When a customer detaches a payment method from their Stripe account, we need to synchronize that change in our system by soft-deleting the corresponding payment method record and clearing it from the customer's default payment method if applicable. This ensures data consistency between Stripe and our database.
How
The implementation:
payment_method.detachedStripe webhook eventsget_by_processor_idrepository methodforce=Trueto handle cases where Stripe has already detached it)Checklist
https://claude.ai/code/session_01NK91AwkotB5cuFJDMi7gkr