-
Notifications
You must be signed in to change notification settings - Fork 5
fix: prevent Stripe users from upgrading with Bitcoin toggle enabled #145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Users on Stripe plans must now cancel their subscription first before switching to Bitcoin payments. When Bitcoin toggle is enabled: - Buttons show "Cancel Stripe First" instead of upgrade/downgrade - Clicking redirects to Stripe portal for subscription management - Prevents confusing overlapping subscriptions 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
WalkthroughThe changes add conditional logic to the pricing page, requiring users with an active Stripe subscription and the Bitcoin payment toggle enabled to cancel their Stripe plan before switching. The UI button text and click handler are updated to reflect this, with platform-specific handling for redirecting users to the Stripe billing portal. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant PricingPage
participant StripePortal
participant TauriOpener
User->>PricingPage: Clicks payment button
PricingPage->>PricingPage: Check if user is on Stripe & Bitcoin toggle is on
alt Stripe + Bitcoin toggle + not free plan
alt Platform is iOS
PricingPage->>TauriOpener: Open Stripe billing portal in Safari
else Other platforms
PricingPage->>StripePortal: Open billing portal in new browser tab
end
PricingPage-->>User: Return early (no further action)
else
PricingPage->>PricingPage: Proceed with normal payment flow
end
Possibly related PRs
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Deploying maple with
|
| Latest commit: |
ac74a1d
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://72e4e92b.maple-ca8.pages.dev |
| Branch Preview URL: | https://disallow-bitcoin-upgrades-fr.maple-ca8.pages.dev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Summary
This PR implements a critical billing protection feature to prevent users from accidentally creating overlapping subscriptions. When a user with an active Stripe subscription enables the Bitcoin payment toggle, the system now:
- Changes all plan buttons to display "Cancel Stripe First"
- Redirects users to the Stripe portal to manage their existing subscription
- Includes special handling for iOS devices to properly open the Stripe portal in Safari
The changes are focused in the pricing page component, specifically around the subscription handling logic. This modification aligns with good billing practices by ensuring clean transitions between payment providers.
Confidence score: 5/5
- This PR is extremely safe to merge as it adds defensive billing logic
- The changes are well-contained, only affect the intended flow, and prevent a clear billing issue
- Key files that warrant attention:
- frontend/src/routes/pricing.tsx - verify the Bitcoin toggle and Stripe portal interaction
1 file reviewed, no comments
Edit PR Review Bot Settings | Greptile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (1)
frontend/src/routes/pricing.tsx (1)
487-503: Consider improving error handling and user feedback.The current implementation handles the platform-specific redirection well, but could benefit from better error handling and user feedback:
- The alert message could be more descriptive
- Consider adding loading states during the redirection attempt
- The iOS-specific error logging could include more context
if (isIOS) { console.log("[Billing] iOS detected, using opener plugin to launch Safari for portal"); + // Could add loading state here import("@tauri-apps/api/core") .then((coreModule) => { return coreModule.invoke("plugin:opener|open_url", { url: portalUrl }); }) .then(() => { console.log("[Billing] Successfully opened portal URL in external browser"); }) .catch((err) => { - console.error("[Billing] Failed to open external browser:", err); - alert("Failed to open browser. Please try again."); + console.error("[Billing] Failed to open external browser for portal URL:", portalUrl, err); + alert("Unable to open your billing portal. Please copy this link and open it manually: " + portalUrl); }); } else { - window.open(portalUrl, "_blank"); + try { + window.open(portalUrl, "_blank"); + } catch (err) { + console.error("[Billing] Failed to open portal URL:", err); + alert("Unable to open your billing portal. Please copy this link and open it manually: " + portalUrl); + } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
frontend/src/routes/pricing.tsx(3 hunks)
🔇 Additional comments (3)
frontend/src/routes/pricing.tsx (3)
313-320: Good implementation of conditional button text logic.The condition correctly checks for Stripe users with Bitcoin toggle enabled and provides clear messaging. The logic is sound and follows the expected flow.
449-449: Good addition of useBitcoin to dependency array.Adding
useBitcointo the dependency array ensures the callback is properly updated when the Bitcoin toggle state changes.
553-553: Good addition of useBitcoin to dependency array.Adding
useBitcointo the dependency array ensures the callback is properly updated when the Bitcoin toggle state changes.
Users on Stripe plans must now cancel their subscription first before switching to Bitcoin payments. When Bitcoin toggle is enabled:
🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Bug Fixes