Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@steven-tey
Copy link
Collaborator

@steven-tey steven-tey commented Jun 3, 2025

Summary by CodeRabbit

  • New Features

    • The payout connection button now dynamically selects between PayPal and bank account options based on the partner's country.
    • Button text updates automatically to reflect the appropriate payout method.
  • Bug Fixes

    • Ensured only the relevant payout method is executed when connecting a payout account.
  • Style

    • Simplified button display and tooltip logic for a clearer user experience.
    • Removed redundant button text props for a cleaner interface.
  • Chores

    • Updated domain constants for PayPal OAuth and callback URLs to ensure consistent environment handling.
    • Renamed internal functions for Stripe account link generation to improve clarity.

@vercel
Copy link
Contributor

vercel bot commented Jun 3, 2025

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Updated (UTC)
dub βœ… Ready (Inspect) Visit Preview Jun 3, 2025 1:00am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 3, 2025

Walkthrough

The changes update the payout connection logic and UI for partners. The provider selection is now dynamically determined based on the partner's country, toggling between Stripe and PayPal. Button rendering is streamlined, removing explicit text and variant props in some places, while the button's text is now set contextually within its component logic. Additionally, domain constants are used in PayPal callback URLs and OAuth redirect URIs instead of hardcoded strings.

Changes

File(s) Change Summary
.../(dashboard)/settings/payouts/payout-stats-and-settings.tsx, .../sidebar/payout-stats.tsx Removed explicit text (and variant) props from ConnectPayoutButton rendering; class styling retained.
.../partners/connect-payout-button.tsx Replaced import for Stripe account link generation; activated conditional payout method logic based on country; simplified button text logic; removed unused imports.
.../(onboarding)/onboarding/verify/page.tsx Dynamic payout provider selection based on partner's country; removed hardcoded provider and commented-out logic.
.../api/paypal/callback/route.ts Replaced hardcoded dev redirect URL with imported PARTNERS_DOMAIN constant.
.../lib/paypal/oauth.ts Updated OAuth redirect URI to use PARTNERS_DOMAIN_WITH_NGROK instead of APP_DOMAIN_WITH_NGROK.
.../lib/actions/partners/generate-stripe-account-link.ts Renamed exported function from createAccountLinkAction to generateStripeAccountLink; updated error message text.
.../lib/swr/use-partner-profile.ts Removed augmentation of partner with computed supportedPayoutMethod; returned raw partner data.
.../ui/partners/payout-methods-dropdown.tsx Updated Stripe account link hook import and usage to generateStripeAccountLink; no other logic changes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant WebApp
    participant Server
    participant Stripe
    participant PayPal

    User->>WebApp: Clicks "Connect Payout" button
    WebApp->>Server: Fetch user session and partner info
    Server-->>WebApp: Returns partner country and payout status
    alt Country supported by Stripe
        WebApp->>Stripe: Initiate Stripe connection
        Stripe-->>WebApp: Stripe connection flow
    else Country not supported by Stripe
        WebApp->>PayPal: Initiate PayPal connection
        PayPal-->>WebApp: PayPal connection flow
    end
    WebApp-->>User: Show connection result
Loading

Poem

A button now knows what to say,
"Bank account" or "PayPal"β€”it leads the way!
No more hardcoded, the logic is spry,
Stripe or PayPal, it chooses on the fly.
With every click, partners cheer,
Simpler code, connection clear!
πŸ‡βœ¨


πŸ“œ Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between ca9207a and f8a9c2a.

πŸ“’ Files selected for processing (4)
  • apps/web/lib/actions/partners/generate-stripe-account-link.ts (2 hunks)
  • apps/web/lib/swr/use-partner-profile.ts (2 hunks)
  • apps/web/ui/partners/connect-payout-button.tsx (3 hunks)
  • apps/web/ui/partners/payout-methods-dropdown.tsx (2 hunks)
βœ… Files skipped from review due to trivial changes (1)
  • apps/web/lib/actions/partners/generate-stripe-account-link.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/web/ui/partners/connect-payout-button.tsx
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/web/ui/partners/payout-methods-dropdown.tsx (1)
apps/web/lib/actions/partners/generate-stripe-account-link.ts (1)
  • generateStripeAccountLink (13-68)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
πŸ”‡ Additional comments (3)
apps/web/lib/swr/use-partner-profile.ts (2)

1-1: LGTM: Clean architectural improvement.

The removal of the CONNECT_SUPPORTED_COUNTRIES import aligns with the architectural shift to determine payout method support dynamically at usage sites rather than embedding computed properties in the partner profile.


24-24: LGTM: Simplified data flow.

Returning the raw partner data without computed properties is a good architectural decision that promotes separation of concerns and makes the data flow more transparent.

apps/web/ui/partners/payout-methods-dropdown.tsx (1)

4-4: LGTM: Import change aligns with function rename.

The import change from createAccountLinkAction to generateStripeAccountLink is correct and matches the function signature based on the relevant code snippet provided.

✨ 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.

@steven-tey steven-tey requested a review from Copilot June 3, 2025 00:31
Copy link
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 enables the PayPal connection flow by uncommenting and integrating the PayPal branch in the payout button logic, and updates component usage across various pages.

  • Uncomments and activates the PayPal flow in ConnectPayoutButton.
  • Adjusts button text based on the country support for payouts.
  • Updates the verify page to fetch session and partner details for proper provider selection.

Reviewed Changes

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

File Description
apps/web/ui/partners/connect-payout-button.tsx Uncomments PayPal flow and updates text property; potential duplicate call to executeStripeAsync.
apps/web/ui/layout/sidebar/payout-stats.tsx Removes explicit text prop from ConnectPayoutButton.
apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/verify/page.tsx Uncomments and implements session and partner fetching for provider selection.
apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/payout-stats-and-settings.tsx Removes explicit text prop from ConnectPayoutButton.
Comments suppressed due to low confidence (1)

apps/web/ui/partners/connect-payout-button.tsx:54

  • The unconditional call to executeStripeAsync() after the if-else block appears redundant and may lead to duplicate calls when the payout method is already handled. Consider removing this call to ensure only the intended payout action is executed.
await executeStripeAsync();

Copy link
Contributor

@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: 2

πŸ“œ Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

πŸ“₯ Commits

Reviewing files that changed from the base of the PR and between a945a5e and 77f804d.

πŸ“’ Files selected for processing (4)
  • apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/payout-stats-and-settings.tsx (1 hunks)
  • apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/verify/page.tsx (2 hunks)
  • apps/web/ui/layout/sidebar/payout-stats.tsx (1 hunks)
  • apps/web/ui/partners/connect-payout-button.tsx (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
apps/web/ui/layout/sidebar/payout-stats.tsx (1)
apps/web/ui/partners/connect-payout-button.tsx (1)
  • ConnectPayoutButton (12-74)
apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/payout-stats-and-settings.tsx (1)
apps/web/ui/partners/connect-payout-button.tsx (1)
  • ConnectPayoutButton (12-74)
πŸ”‡ Additional comments (6)
apps/web/ui/layout/sidebar/payout-stats.tsx (1)

95-95: LGTM! Text logic centralized in ConnectPayoutButton.

Removing the explicit text prop is appropriate since the ConnectPayoutButton component now handles text determination internally based on the partner's country and supported payout method.

apps/web/app/(ee)/partners.dub.co/(dashboard)/settings/payouts/payout-stats-and-settings.tsx (1)

27-27: LGTM! Consistent with centralization pattern.

Removing both text and variant props is consistent with centralizing the button's appearance and text logic within the ConnectPayoutButton component itself.

apps/web/app/(ee)/partners.dub.co/(onboarding)/onboarding/verify/page.tsx (2)

1-4: LGTM! Necessary imports for dynamic provider selection.

The added imports (getSession, prisma, CONNECT_SUPPORTED_COUNTRIES) are appropriate for implementing dynamic payout provider selection based on the partner's country.


109-118: LGTM! Dynamic provider selection improves flexibility.

The implementation correctly determines the payout provider based on the partner's country support rather than hardcoding "stripe". This aligns well with the ConnectPayoutButton's logic that also uses CONNECT_SUPPORTED_COUNTRIES to determine button text and functionality.

apps/web/ui/partners/connect-payout-button.tsx (2)

7-7: LGTM! Cleaned up unused import.

Removing the COUNTRIES import is appropriate since only CONNECT_SUPPORTED_COUNTRIES is used for the country-based logic.


65-70: LGTM! Dynamic button text based on country support.

The text logic correctly displays "Connect PayPal" for countries not in CONNECT_SUPPORTED_COUNTRIES and "Connect bank account" for supported countries. This aligns well with the conditional payout method execution logic.

@steven-tey
Copy link
Collaborator Author

@CodeRabbit final review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 3, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

@steven-tey I'll conduct a comprehensive final review of this PayPal connection implementation. Let me examine the key changes first.


🏁 Script executed:

#!/bin/bash
# First, let's examine the core ConnectPayoutButton implementation
cat apps/web/ui/partners/connect-payout-button.tsx

Length of output: 2358


🏁 Script executed:

#!/bin/bash
# Check the onboarding provider selection logic
cat apps/web/app/\(ee\)/partners.dub.co/\(onboarding\)/onboarding/verify/page.tsx

Length of output: 4585


🏁 Script executed:

#!/bin/bash
# Examine the PayPal OAuth configuration
cat apps/web/lib/paypal/oauth.ts

Length of output: 2450


🏁 Script executed:

#!/bin/bash
# Check for any remaining hardcoded references that might need updating
rg -i "stripe.*connect|connect.*stripe" --type ts --type tsx -A 2 -B 2

Length of output: 100


🏁 Script executed:

#!/bin/bash
# Look for any TODO comments or incomplete implementations
rg -i "todo|fixme|hack" --type ts --type tsx -A 2 -B 2

Length of output: 84


🏁 Script executed:

#!/bin/bash
# Check the CONNECT_SUPPORTED_COUNTRIES usage across the codebase
rg "CONNECT_SUPPORTED_COUNTRIES" --type ts --type tsx -A 3 -B 1

Length of output: 91


🏁 Script executed:

#!/bin/bash
# Check for any remaining hardcoded references that might need updating
rg -i "stripe.*connect|connect.*stripe" -g "*.ts" -g "*.tsx" -A 2 -B 2

Length of output: 36392


🏁 Script executed:

#!/bin/bash
# Look for any TODO comments or incomplete implementations
rg -i "todo|fixme|hack" -g "*.ts" -g "*.tsx" -A 2 -B 2

Length of output: 33798


🏁 Script executed:

#!/bin/bash
# Check the CONNECT_SUPPORTED_COUNTRIES usage across the codebase
rg "CONNECT_SUPPORTED_COUNTRIES" -g "*.ts" -g "*.tsx" -A 3 -B 1

Length of output: 6996


🏁 Script executed:

#!/bin/bash
# Check the PayPal callback implementation
cat apps/web/app/\(ee\)/api/paypal/callback/route.ts

Length of output: 2683


🏁 Script executed:

#!/bin/bash
# Check if there are any error handling issues or missing validations
rg "partner\.country" -g "*.ts" -g "*.tsx" -A 2 -B 2

Length of output: 14047


@steven-tey Here's my comprehensive final review of the PayPal connection implementation:

βœ… Excellent Implementation - Ready for Production

This PR represents a well-architected solution for dynamic payout provider selection. The implementation demonstrates strong engineering principles and attention to detail.

πŸ—οΈ Architecture Strengths

  1. Clean Separation of Concerns: Moving from computed properties in usePartnerProfile to dynamic determination at usage sites is a smart architectural decision that promotes maintainability.

  2. Robust Country-Based Logic: The CONNECT_SUPPORTED_COUNTRIES logic is consistently applied across:

    • ConnectPayoutButton component
    • Onboarding verification flow
    • Provider selection logic
    • Error messaging
  3. Comprehensive Error Handling: Excellent validation and user feedback:

    if (!partner.country) {
      toast.error("You haven't set your country yet. Please go to partners.dub.co/settings to set your country.");
      return;
    }

πŸ” Security & OAuth Implementation

The PayPal OAuth flow is properly implemented with:

  • State verification for CSRF protection
  • Secure token exchange
  • Proper session validation
  • Development environment handling

🎯 User Experience

  1. Dynamic Button Text: Button intelligently displays "Connect PayPal" vs "Connect bank account" based on country support
  2. Clear Error Messages: Users get specific guidance on unsupported countries
  3. Seamless Flow: Onboarding dynamically shows the correct provider without user intervention

πŸ“¦ Code Quality

  • Consistent Naming: Function rename from createAccountLinkAction β†’ generateStripeAccountLink applied consistently
  • Domain Constants: Proper use of PARTNERS_DOMAIN and PARTNERS_DOMAIN_WITH_NGROK instead of hardcoded values
  • Type Safety: Excellent TypeScript usage with proper validation schemas

Minor Notes

The TODO comments I found are for future enhancements (email notifications, verification checks) and don't impact the core functionality. The implementation is production-ready as-is.

πŸš€ Recommendation

LGTM - Approve and Merge

This is a high-quality implementation that:

  • βœ… Maintains backward compatibility
  • βœ… Follows solid architectural principles
  • βœ… Implements robust error handling
  • βœ… Provides excellent user experience
  • βœ… Uses consistent coding patterns

The PayPal integration will significantly expand Dub's global reach for partner payouts. Well done! πŸŽ‰

    🐰
   /   \
  ( ^.^ )  Great work on this PayPal integration!
   \   /   The architecture is clean and the
    ---    implementation is solid! ✨

@steven-tey steven-tey merged commit b5a5fc3 into main Jun 3, 2025
7 of 8 checks passed
@steven-tey steven-tey deleted the connect-paypal branch June 3, 2025 01:07
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