Furever: Stripe Connect Embedded Components Demo

repository·master·Indexed 40 days ago

https://github.com/stripe/stripe-connect-furever-demo

A full-stack SaaS demonstration platform for pet groomers built with Next.js, Express, and React. It showcases the integration of Stripe Connect and embedded components, including <ConnectOnboarding />, <ConnectBalanceReport />, and <ConnectAccountManagement />, to manage onboarding, payments, and account settings within a vertical SaaS application.

Tokens
2K
Snippets
7
Records
9
Agent score
99%

What's inside Furever

  1. Overview of FurEver: Stripe Connect embedded components demo

    master

    FurEver is a full-stack demo application for a vertical SaaS grooming platform. It demonstrates how to integrate Stripe Connect and Stripe Connect embedded components directly into a platform's website.

    Key features include:

    • Embedded Onboarding: Users onboard via Stripe without leaving the platform.
    • Account Management: Using embedded components to manage settings, tax, and documents.
    • Financial Visibility: Displaying payments, payouts, balance reports, and tax settings.
    • Unified Account Configuration: The demo uses a configuration where Stripe owns loss liability, the platform owns pricing, Stripe is the onboarding owner, and connected accounts have no access to the Stripe dashboard.
  2. Setup and Installation Guide

    master

    Follow these steps to run the FurEver demo locally:

    1. Prerequisites

    2. Install Dependencies

    yarn

    3. Configure Environment Variables

    Copy the example environment file and add your Stripe API keys:

    cp .env.example .env

    4. Start MongoDB (macOS example)

    brew tap mongodb/brew && brew update
    brew install mongodb-community@7.0
    brew services start mongodb-community@7.0

    5. Run the Application

    yarn dev

    Access the app at http://localhost:{process.env.PORT}.

    yarn
    cp .env.example .env
    # Start MongoDB
    brew tap mongodb/brew && brew update
    brew install mongodb-community@7.0
    brew services start mongodb-community@7.0
    # Run app
    yarn dev
  3. Testing Stripe Webhooks

    master

    To test events sent to your local event handler, use the Stripe CLI in a separate terminal.

    1. Listen for webhooks: stripe listen --forward-to localhost:3000/api/webhooks

    2. Trigger a test event: stripe trigger payment_intent.succeeded

    # In one terminal
    stripe listen --forward-to localhost:3000/api/webhooks
    
    # In another terminal
    stripe trigger payment_intent.succeeded
  4. Initialize the Stripe client

    master

    The project uses a centralized Stripe client instance initialized with a specific API version. To use the project's configured Stripe client, ensure the STRIPE_SECRET_KEY environment variable is set. The client is configured to use the 2026-08-26.preview API version.

    import { stripe } from './lib/stripe';
    
    // Use the exported stripe instance to make API calls
    const customers = await stripe.customers.list();
  5. Configure NextAuth authentication options

    master

    The authOptions object defines the authentication configuration for the application using next-auth. It uses a jwt session strategy and specifies custom pages for signing in (/login) and signing out (/).

    Key callback behaviors include:

    • signIn: A hook to perform logic during the sign-in process.
    • session: Populates the session object with user data from the JWT token, including email, setup, primaryColor, companyName, companyLogoUrl, and stripeAccountId.
    • jwt: Manages the JWT token lifecycle. It supports an update trigger to refresh specific user fields like primaryColor, companyName, companyLogoUrl, and setup without requiring a full re-authentication.
    export const authOptions: AuthOptions = {
      session: {
        strategy: 'jwt',
      },
      pages: {
        signIn: '/login',
        signOut: '/',
      },
      callbacks: {
        async signIn({user}) { ... },
        async session({session, token}) { ... },
        async jwt({token, trigger, session, user}) { ... },
      },
      providers: [ ... ],
    };
  6. Supported Stripe Connect embedded components

    master

    The demo utilizes several supported Stripe Connect embedded components to provide UI surfaces for account management:

    • <ConnectOnboarding />: Enables an embedded onboarding experience.
    • <ConnectBalanceReport />: Provides a downloadable financial report of balance activity.
    • <ConnectPayments />: Displays Stripe payments, refunds, and disputes (includes filtering, pagination, and CSV exports).
    • <ConnectPayouts />: Displays Stripe payouts and balance (includes filtering, pagination, and CSV exports).
    • <ConnectPayoutReconciliationReport />: Provides a downloadable report for reconciling payouts.
    • <ConnectAccountManagement />: Allows users to edit Stripe account settings.
    • <ConnectNotificationBanner />: Displays current and future risk requirements.
    • <ConnectDocuments />: Displays a list of tax invoice documents.
    • <ConnectTaxSettings />: Allows users to set up Stripe Tax.
    • <ConnectTaxRegistrations />: Allows users to control tax compliance settings.
  7. Preview Stripe Connect embedded components

    master

    The following components are currently in preview mode. They are disabled by default and require access requested via the Stripe documentation. To enable them, add NEXT_PUBLIC_ENABLE_PREVIEW_COMPONENTS=1 to your .env file.

    • <ConnectCapitalOverview />: Checks eligibility for financing and reviews paydown transactions.
    • <ConnectFinancialAccount />: Renders a view of an individual Financial Account.
    • <ConnectFinancialAccountTransactions />: Provides a list of transactions associated with a financial account.
    • <ConnectIssuingCardsList />: Provides a list of all issued cards.
    NEXT_PUBLIC_ENABLE_PREVIEW_COMPONENTS=1
  8. Available Authentication Providers

    master

    The application provides several CredentialsProvider options for different user flows:

    1. login (Email & Password): Standard login using email and password stored in the Salon model.
    2. loginas (Account ID): Allows logging in using a stripeAccountId. If the user does not exist locally, it attempts to retrieve the account from Stripe and creates a local Salon record.
    3. signup (Email & Password): Creates a new local Salon record with setup: true and changedPassword: true.
    4. createprefilledaccount: A specialized flow for testing/demoing. It creates a dummy bank account token, a local Salon record, and a fully configured Stripe Connect account with pre-filled business and individual details.
    5. createaccount: Creates a Stripe account based on provided business details (country, business type, name, etc.) and links it to a local Salon record.
    6. updateemail: A provider specifically for updating the user's email.
    providers: [
      CredentialsProvider({ id: 'updateemail', ... }),
      CredentialsProvider({ id: 'login', ... }),
      CredentialsProvider({ id: 'loginas', ... }),
      CredentialsProvider({ id: 'createprefilledaccount', ... }),
      CredentialsProvider({ id: 'createaccount', ... }),
      CredentialsProvider({ id: 'signup', ... }),
    ]