Skip to content

fix: update DB immediately on subscription cancellation#726

Merged
apetkov98 merged 1 commit intopodkrepi-bg:masterfrom
sashko9807:fix/cancel-user-subscription
Apr 1, 2026
Merged

fix: update DB immediately on subscription cancellation#726
apetkov98 merged 1 commit intopodkrepi-bg:masterfrom
sashko9807:fix/cancel-user-subscription

Conversation

@sashko9807
Copy link
Copy Markdown
Member

The cancel method had inverted logic — it treated a successful Stripe cancellation (status: 'canceled') as a failure, returning null without updating the DB record. The status was only corrected later when Stripe sent the webhook. Fix by updating the DB immediately after Stripe confirms cancellation.

Also adds idempotency guards for already-canceled subscriptions, fixes missing awaits on webhook handlers that silently swallowed errors, and makes updateStatus resilient to concurrent cancel/webhook race conditions via a NOT filter with P2025 fallback

The cancel method had inverted logic — it treated a successful Stripe
cancellation (status: 'canceled') as a failure, returning null without
updating the DB record. The status was only corrected later when Stripe
sent the webhook. Fix by updating the DB immediately after Stripe
confirms cancellation.

Also adds idempotency guards for already-canceled subscriptions, fixes
missing awaits on webhook handlers that silently swallowed errors, and
makes updateStatus resilient to concurrent cancel/webhook race
conditions via a NOT filter with P2025 fallbackk
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 1, 2026

✅ Tests will run for this PR. Once they succeed it can be merged.

@sashko9807 sashko9807 added the run tests Allows running the tests workflows for forked repos label Apr 1, 2026
@github-actions github-actions bot removed the run tests Allows running the tests workflows for forked repos label Apr 1, 2026
@apetkov98 apetkov98 merged commit 1ada47d into podkrepi-bg:master Apr 1, 2026
9 of 10 checks passed
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.

2 participants