Skip to content

Add billing URL handling for payment required errors#683

Merged
timbastin merged 1 commit intomainfrom
add-billing-check
Mar 16, 2026
Merged

Add billing URL handling for payment required errors#683
timbastin merged 1 commit intomainfrom
add-billing-check

Conversation

@refoo0
Copy link
Copy Markdown
Member

@refoo0 refoo0 commented Mar 10, 2026

No description provided.

Signed-off-by: rafi <refaei.shikho@hotmail.com>
Copilot AI review requested due to automatic review settings March 10, 2026 15:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds handling for HTTP 402 (Payment Required) responses from the backend API. When a user's organization is inaccessible due to a payment issue, they are now redirected to a configurable billing URL instead of silently redirecting to /.

Changes:

  • Detect 402 responses in fetchOrganization and fetchContentTree, throwing a typed HttpError with statusCode: 402
  • Add a billingUrl config option backed by BILLING_URL env var (defaults to https://devguard.org)
  • Catch the 402 HttpError in the organization layout and redirect to the billing URL

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/data-fetcher/fetchOrganization.ts Throws HttpError(402) on 402 response; removes stale console.log
src/data-fetcher/fetchContentTree.ts Adds error checking for non-OK responses including 402 handling
src/config.ts Adds billingUrl config field with BILLING_URL env var support
src/app/(loading-group)/[organizationSlug]/layout.tsx Catches 402 HttpError and redirects to billingUrl

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@timbastin timbastin merged commit 01132c3 into main Mar 16, 2026
15 checks passed
@timbastin timbastin deleted the add-billing-check branch March 16, 2026 10:21
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