🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

fix(subscription): make billing account teardown retryable - #1844

Merged
whoAbhishekSah merged 2 commits into
fix/kyc-delete-methodfrom
fix/subscription-teardown-retry
Aug 5, 2026
Merged

fix(subscription): make billing account teardown retryable#1844
whoAbhishekSah merged 2 commits into
fix/kyc-delete-methodfrom
fix/subscription-teardown-retry

Conversation

@whoAbhishekSah

Copy link
Copy Markdown
Member

Part of #1835. Stacked on the kyc delete PR.

DeleteByCustomer failed and could not be run again when the provider side was already gone. That mattered for org delete: after a halfway failure, the Stripe customer was deleted but local rows remained, and every retry died on the first provider call.

Changes

  • A subscription already canceled on the provider now just syncs the local state instead of failing the cancel call.
  • A subscription missing on the provider counts as canceled.
  • Offline accounts skip the provider entirely; only local records are removed.
  • Dropped the SyncWithProvider call, which failed outright when the provider customer was already deleted.

🤖 Generated with Claude Code

@vercel

vercel Bot commented Aug 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
frontier Ready Ready Preview Aug 5, 2026 2:52am

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 4b94f90f-7f6a-4e78-8a92-9edd0434c4b8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@rohilsurana rohilsurana left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The teardown logic checks out: the early return syncs local state when the provider already canceled, and dropping SyncWithProvider is safe because deleting the Stripe customer later cancels anything still live on the provider. One edge case inline.

Also, no tests cover the new Cancel branch, which is the one piece of real logic in this stack. The concrete Stripe client makes unit tests hard here, so a short note in the PR on how this was verified against Stripe test mode would help.

Comment thread billing/subscription/service.go Outdated
whoAbhishekSah and others added 2 commits August 5, 2026 08:17
DeleteByCustomer failed and could not be run again when the provider
side was already gone:

- a subscription already canceled on the provider now just syncs the
  local state instead of failing the cancel call
- a subscription missing on the provider counts as canceled
- offline accounts skip the provider entirely; only local records go
- drop the SyncWithProvider call, which failed outright when the
  provider customer was already deleted

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
createOrGetSchedule returns no schedule for incomplete_expired
subscriptions, so Cancel fell through to the provider cancel call,
which Stripe rejects for that terminal status. Sync the local state
instead, the same as for provider-canceled subscriptions. An
incomplete subscription still goes through the real cancel, which
Stripe allows.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coveralls

coveralls commented Aug 5, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 30970563182

Coverage decreased (-0.003%) to 47.481%

Details

  • Coverage decreased (-0.003%) from the base build.
  • Patch coverage: Could not be determined — this PR's diff is too large for GitHub to return (406 error at GitHub).
  • 167 coverage regressions across 1 file.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

167 previously-covered lines in 1 file lost coverage.

File Lines Losing Coverage Coverage
billing/subscription/service.go 167 42.16%

Coverage Stats

Coverage Status
Relevant Lines: 39323
Covered Lines: 18671
Line Coverage: 47.48%
Coverage Strength: 15.4 hits per line

💛 - Coveralls

@whoAbhishekSah
whoAbhishekSah merged commit 366e24c into main Aug 5, 2026
8 checks passed
@whoAbhishekSah
whoAbhishekSah deleted the fix/subscription-teardown-retry branch August 5, 2026 03:37
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