Skip to content

fix(billing): answer stripe's refusals to end a trial early with a conflict - #10530

Merged
waleedlatif1 merged 2 commits into
stagingfrom
fix/end-trial-stripe-refusals
Dec 1, 2026
Merged

waleedlatif1 merged 2 commits into
stagingfrom
fix/end-trial-stripe-refusals

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Ending a Pro trial early already turned a declined card into a 409, but Stripe can also refuse the first charge itself: an amount past the card currency's maximum, or a subscription past Stripe's daily invoice limit. Those reached the route as unhandled errors and returned 500
  • endProTrial now turns a Stripe invalid-request or rate-limit refusal into a conflict (409) with a plain message that the trial keeps running, and logs Stripe's type, code and message so the refusals stay visible
  • Any other error still propagates unchanged

Type of Change

  • Bug fix

Testing

  • lib/billing/free-plan.integration.ts (real Postgres, Stripe stubbed at its client): a currency-limit refusal and a daily-invoice-limit refusal each end in a conflict and leave the trial running. Both fail on the pre-fix code and pass with the fix; 21/21 green
  • biome on the changed files; type-check, audits and the full suite run in CI

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

…nflict

A declined card already maps to a conflict, but Stripe can also refuse the
first charge itself, such as an amount past the card currency's limit or a
subscription past its daily invoice limit. Those surfaced as server errors;
they now return a clear conflict, keep the trial running, and log Stripe's
type and code.
@vercel

vercel Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Dec 1, 2026 4:16am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge; no actionable issue was established.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issue was established.

Summary

endProTrial returns a conflict for recognized Stripe charge refusals and logs the Stripe error details.

  • Stripe charge refusals now leave the trial running and return a conflict.

No new actionable issues were found. Tests were reviewed but not run.

Reviews (2) · Last reviewed commit: "fix(billing): match only stripe's confir..." · Reviewed by Greptile

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 2 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit 8d73002 into staging Dec 1, 2026
77 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/end-trial-stripe-refusals branch December 1, 2026 04:20

This branch was previously deployed

1 inactive deployment
Preview — 7467b147 Deployed Dec 1, 2026 by vercel[bot]
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.

1 participant