Skip to content

Fix: Add recovery dialogs for missing payment method and verification required#305

Merged
ben-fornefeld merged 41 commits into
mainfrom
fix/team-blocked-missing-payment-method
May 9, 2026
Merged

Fix: Add recovery dialogs for missing payment method and verification required#305
ben-fornefeld merged 41 commits into
mainfrom
fix/team-blocked-missing-payment-method

Conversation

@sarimrmalik

@sarimrmalik sarimrmalik commented Apr 28, 2026

Copy link
Copy Markdown
Collaborator

Ticket

Summary

  • Show an in-app blocking dialog when the active team is blocked for a missing payment method.
  • Add a billing tRPC mutation for creating payment method setup sessions and render the Stripe Payment Element in the dialog.
  • Poll team state after successful setup and close the dialog once the missing-payment-method block clears.

Test plan

  • Manually verified the diff flow against the billing-server payment methods session contract.

Images

  • When team is blocked, the dialog automatically opens
image - Clicking on banner also opens dialog image - Dialog when reason is `verification required` image

- Introduces a new `PaymentMethodsSession` interface to handle payment method sessions.
- Updates the `BillingRepository` to include a method for creating payment methods sessions.
- Implements a new `MissingPaymentMethodDialog` component to prompt users for payment method input when their team is blocked due to missing payment methods.
- Enhances the `TeamBlockageAlert` to open the payment method dialog when appropriate.
- Adds utility functions to check for missing payment method blockage reasons.

This update improves the user experience by allowing teams to add payment methods directly from the dashboard when blocked.
- Introduces a constant for the loading message in the MissingPaymentMethodDialog component to improve consistency and maintainability.
- Updates the LoadingState component to use the new constant for loading payment method messages, enhancing clarity in the user interface.
- Removes the standalone `parsePaymentMethodsSession` function and integrates its logic directly into the `getCustomerSession` method.
- Updates the API endpoint for fetching the customer session to align with the new structure.
- Enhances error handling for invalid payment methods session responses, ensuring consistent error reporting.
@vercel

vercel Bot commented Apr 28, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
web Ready Ready Preview, Comment May 8, 2026 7:25pm
web-juliett Ready Ready Preview, Comment May 8, 2026 7:25pm

Request Review

@sarimrmalik sarimrmalik marked this pull request as draft April 28, 2026 18:03

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f33b1b3ba6

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread src/features/dashboard/sidebar/missing-payment-method-dialog.tsx Outdated
- Introduces a new `capitalize` utility function for consistent string formatting.
- Updates `TeamBlockageAlert` to use the new `capitalize` function for displaying blocked reasons, improving readability.
- Replaces the deprecated `isMissingPaymentMethodBlockReason` function with a new implementation that utilizes the `capitalize` function.
- Removes the unused `team-blockage.ts` file, streamlining the codebase.
…syntax

- Changes function declarations to arrow function expressions for `MissingPaymentMethodDialog`, `MissingPaymentMethodDialogContent`, `PaymentMethodsSessionError`, `LoadingState`, `PaymentMethodsSetupElements`, and `PaymentMethodsSetupForm`.
- This update enhances consistency in the codebase and aligns with modern React practices.
…remove unused components

- Eliminates the `PaymentMethodsSessionError` component and associated error handling logic, simplifying the dialog's structure.
- Updates the `PaymentMethodsSetupForm` to remove unnecessary state variables and error messages, enhancing clarity and maintainability.
- Integrates toast notifications for error handling, improving user feedback during payment method interactions.
- Adjusts the loading state management to ensure a smoother user experience when loading payment elements.
Comment thread src/features/dashboard/sidebar/missing-payment-method-dialog.tsx Outdated
- Introduced a new `VerificationPaymentResponse` interface to handle verification payment responses.
- Updated `BillingRepository` to include a `createVerificationPayment` method for initiating verification payments.
- Implemented the `createVerificationPayment` method in the billing repository, which fetches the verification payment from the API and handles errors appropriately.
- Added a new `VerificationRequiredDialog` component to prompt users for verification payments, including loading states and error handling.
- Updated the `TeamBlockedIndicator` to open the verification dialog when the team is blocked due to verification requirements.

This change enhances the billing process by allowing teams to verify their accounts through a payment mechanism.
…ation messaging

- Updated the success toast message in the PaymentMethodsSetupForm to clarify that a payment method was added.
- Added a success toast in the VerificationPaymentForm to notify users when their team has been verified and unblocked.
- Changed the dialog title and description in the VerificationRequiredDialogContent to reflect that the team requires verification instead of the account.
@cla-bot

cla-bot Bot commented May 5, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @sarimrmalik on file. You can sign our CLA at https://e2b.dev/docs/cla . Once you've signed, post a comment here that says '@cla-bot check'

@sarimrmalik sarimrmalik changed the title Fix: Add missing payment method recovery dialog Fix: Add recovery dialogs for missing payment method and verification required May 5, 2026
- Renamed BLOCKED_REASONS to TEAM_BLOCKED_REASONS for clarity and consistency across the codebase.
- Updated imports and type definitions in TeamBlockedIndicator and related dialog components to utilize the new TEAM_BLOCKED_REASONS constant.
- Introduced a utility function, getBlockedDialogStorageKey, for managing dismissed dialog states in session storage, enhancing user experience by preventing re-prompting of already dismissed dialogs.
- Streamlined state management in MissingPaymentMethodDialog and VerificationRequiredDialog to improve clarity and performance.
Comment thread src/lib/hooks/use-session-storage.ts Outdated

@ben-fornefeld ben-fornefeld 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.

one more thing — the dismissed-flag ordering is fragile. inline comment.

Comment thread src/features/dashboard/layouts/team-blocked-indicator.tsx Outdated
…rity and functionality

- Introduced TeamBlockedIndicatorContent and TeamBlockedDialogController components to separate concerns and enhance readability.
- Updated useBlockedMessage to return a structured BlockedMessage type for better type safety.
- Replaced direct session storage interactions with a simplified useSessionStorage hook for managing dismissed dialog states.
- Streamlined dialog handling logic in TeamBlockedIndicator to improve user experience and maintainability.
- Removed the deprecated use-session-storage hook, consolidating session storage management.
- Updated MissingPaymentMethodDialog and VerificationRequiredDialog to use onDismiss callback for handling dialog closure, enhancing clarity in state transitions.
- Streamlined dialog open/close logic by consolidating the handling of open state changes, improving maintainability.
- Adjusted props in TeamBlockedRecoveryPaymentElement to replace onOpenChange with onClose for consistency across dialog components.
- Enhanced user experience by ensuring dialogs properly dismiss and manage state without unnecessary complexity.
Add uppercase and md:prose-label! to the dialog-trigger button so the
clickable CTA renders in the same uppercase label style as the rest of
the indicator text.
Iterate the known blocked reasons and remove their sessionStorage keys
once the team is no longer blocked. Without this, a previously dismissed
flag would persist and suppress the auto-open if the team got blocked
again with the same reason.
The dialogs already remove the dismissed flag via removeDismissedDialog
at the right moment — right when the 'Team unblocked' success toast
fires (form-submit path) and on the Stripe URL-return success paths.
The useEffect in the indicator was redundant.

@ben-fornefeld ben-fornefeld 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.

lgtm

@ben-fornefeld ben-fornefeld merged commit 07da540 into main May 9, 2026
14 checks passed
@ben-fornefeld ben-fornefeld deleted the fix/team-blocked-missing-payment-method branch May 9, 2026 01:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants