Skip to content

Conversation

@AnthonyRonning
Copy link
Contributor

@AnthonyRonning AnthonyRonning commented Jul 14, 2025

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

Summary by CodeRabbit

  • New Features

    • Added a prompt and redirection for users with an active Stripe subscription who attempt to switch to Bitcoin payments, guiding them to cancel their Stripe plan first.
    • Improved platform-specific handling for opening the billing portal, including support for iOS.
  • Bug Fixes

    • Ensured subscription actions correctly respond to changes in the Bitcoin payment toggle.

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>
@coderabbitai
Copy link

coderabbitai bot commented Jul 14, 2025

Walkthrough

The 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

File(s) Change Summary
frontend/src/routes/pricing.tsx Added conditional button text and click handling for Stripe users with Bitcoin enabled; updated dependency arrays for reactivity.

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
Loading

Possibly related PRs

  • Fix stripe managed portal on ios #73: Both PRs modify the handleButtonClick function to conditionally open the Stripe billing portal with Tauri opener on iOS, ensuring platform-specific handling.
  • Add ios pricing #61: Both PRs update pricing.tsx to implement platform-specific logic for payment flows, including iOS Tauri detection and URL opening behavior.

Poem

A toggle for Bitcoin, a Stripe plan in place,
Now users must cancel, before a new chase.
On iOS or Chrome, the portal appears,
With one click, the pathway is crystal clear.
Hop, hop! says the rabbit, the logic refined—
Payment flows smoother, with users in mind!
🐇💳🪙

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@cloudflare-workers-and-pages
Copy link

Deploying maple with  Cloudflare Pages  Cloudflare Pages

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

View logs

Copy link
Contributor

@greptile-apps greptile-apps bot left a 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:

  1. Changes all plan buttons to display "Cancel Stripe First"
  2. Redirects users to the Stripe portal to manage their existing subscription
  3. 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

  1. This PR is extremely safe to merge as it adds defensive billing logic
  2. The changes are well-contained, only affect the intended flow, and prevent a clear billing issue
  3. 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

Copy link

@coderabbitai coderabbitai bot left a 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:

  1. The alert message could be more descriptive
  2. Consider adding loading states during the redirection attempt
  3. 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

📥 Commits

Reviewing files that changed from the base of the PR and between de76539 and ac74a1d.

📒 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 useBitcoin to 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 useBitcoin to the dependency array ensures the callback is properly updated when the Bitcoin toggle state changes.

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