### Root Layout Provider Setup Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/api-reference/hooks.md Example of setting up the root layout with required providers: SessionProvider, SettingsProvider, and QueryProvider. Ensure these providers are correctly imported and nested to provide necessary context for hooks. ```typescript import {SessionProvider} from 'next-auth/react'; import {SettingsProvider} from '@/app/contexts/settings/SettingsProvider'; import {QueryProvider} from '@/app/providers/QueryProvider'; export function RootLayout() { return ( {/* app content */} ); } ``` -------------------------------- ### Install and Start MongoDB Community Edition Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/README.md Commands to install and start MongoDB Community Edition using Homebrew. Refer to official MongoDB documentation for OS-specific instructions. ```bash brew tap mongodb/brew && brew update brew install mongodb-community@7.0 brew services start mongodb-community@7.0 ``` -------------------------------- ### Create a New Salon for Quickstart Accounts Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/api-reference/models.md Shows how to create a Salon instance specifically for quickstart accounts. For these accounts, the password is stored as plain text. ```typescript const quickstart = new Salon({ email: 'quickstart@example.com', password: 'quickstartPassword', quickstartAccount: true, changedPassword: false }); await quickstart.save(); // Password stored as plain text ``` -------------------------------- ### Build and Start Production Server Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/README.md Commands to build the project for production and start the production server. These are standard Yarn commands for deployment. ```bash yarn build # Build for production yarn start # Start production server ``` -------------------------------- ### Install Dependencies with Yarn Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/README.md Use this command to install project dependencies. Ensure you have Yarn installed. ```bash yarn ``` -------------------------------- ### Create Test Account Setup Data Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Creates test payment data for a newly verified account. This includes test payments, a dispute, and payouts. It also marks the account as setup. ```typescript app/api/setup_accounts/route.ts ``` -------------------------------- ### Common Configuration Example Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/types.md Provides a common configuration example for 'ControllerProperties' used in the Stripe account creation flow. This snippet demonstrates setting up custom account, platform liability, and platform fee payment. ```typescript import {ControllerProperties} from '@/types/account'; const config: ControllerProperties = { stripeDashboardType: 'none', // Custom account paymentLosses: 'application', // Platform liability feePayer: 'application' // Platform pays fees }; ``` -------------------------------- ### Stripe Account Details Usage Example Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/api-reference/hooks.md Example of how to use the `useGetStripeAccount` hook to display account information or loading/error states. ```typescript import {useGetStripeAccount} from '@/app/hooks/useGetStripeAccount'; export function AccountDetails() { const {stripeAccount, loading, error} = useGetStripeAccount(); if (loading) return
Loading account...
; if (error) return
Error: {error}
; if (!stripeAccount) return
No account found
; return (

Account ID: {stripeAccount.id}

Email: {stripeAccount.email}

Country: {stripeAccount.country}

); } ``` -------------------------------- ### MONGO_URI Environment Variable Example Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/api-reference/database.md Provides examples of how to set the required `MONGO_URI` environment variable for connecting to a local MongoDB instance or a MongoDB Atlas cluster. ```shell MONGO_URI=mongodb://localhost:27017/furever MONGO_URI=mongodb+srv://user:pass@cluster.mongodb.net/furever ``` -------------------------------- ### SettingsProvider Integration Example Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/api-reference/context-settings.md Demonstrates how to wrap the entire application with the SettingsProvider to make settings globally accessible. Ensure SettingsProvider is imported correctly. ```typescript import {SettingsProvider} from '@/app/contexts/settings/SettingsProvider'; export function RootLayout() { return ( {/* Application content */} ); } ``` -------------------------------- ### Mongoose Model Usage Example Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/api-reference/database.md Demonstrates how to use Mongoose models after successfully connecting to the database using `dbConnect`. This example shows querying for a single document and multiple documents. ```typescript import dbConnect from '@/lib/dbConnect'; import Salon from '@/app/models/salon'; // Connect to database await dbConnect(); // Now Salon model queries work const salon = await Salon.findOne({email: 'user@example.com'}); const salons = await Salon.find({country: 'US'}); ``` -------------------------------- ### Run the Application Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/README.md Start the Furever Demo application using the yarn dev command. Access the app at http://localhost:{process.env.PORT}. ```bash yarn dev ``` -------------------------------- ### Express Dashboard Login Link Usage Example Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/api-reference/hooks.md Example of using `useExpressDashboardLoginLink` to conditionally render a button or link to the Express dashboard. ```typescript import {useExpressDashboardLoginLink} from '@/app/hooks/useExpressDashboardLoginLink'; export function ExpressDashboardButton() { const {hasExpressDashboardAccess, expressDashboardLoginLink} = useExpressDashboardLoginLink(); if (!hasExpressDashboardAccess) { return
No Express dashboard access
; } if (!expressDashboardLoginLink) { return
Loading link...
; } return ( Go to Express Dashboard ); } ``` -------------------------------- ### Test Stripe Connectivity Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/configuration.md Initiates a POST request to the /api/setup_accounts endpoint to test Stripe connectivity after the application has started. ```bash # Create test charge (after app runs) curl -X POST http://localhost:3000/api/setup_accounts ``` -------------------------------- ### Copy Environment File Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/README.md Copy the example environment file to create your own configuration. You will need to add your Stripe API keys to the .env file. ```bash cp .env.example .env ``` -------------------------------- ### API Route Database Connection Example Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/api-reference/database.md Example of how to use `dbConnect` within a Next.js API route to establish a database connection before performing Mongoose operations. Includes basic error handling for connection failures. ```typescript import dbConnect from '@/lib/dbConnect'; // In API route or server function export async function GET(req: NextRequest) { try { await dbConnect(); // Now you can use Mongoose models const user = await Salon.findOne({email}); return Response.json(user); } catch (error) { console.error('Database error:', error); return Response.json({error: 'Database connection failed'}, {status: 500}); } } ``` -------------------------------- ### Financial Account Usage Example Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/api-reference/hooks.md Demonstrates how to use the `useFinancialAccount` hook to display financial account information or relevant states. ```typescript import {useFinancialAccount} from '@/app/hooks/useFinancialAccount'; export function FinancialComponent() { const {financialAccount, loading, error} = useFinancialAccount(); if (loading) return
Loading...
; if (error) return
Error loading account
; if (!financialAccount) return
No financial account
; return
Account: {financialAccount}
; } ``` -------------------------------- ### Dynamic Locale Selection Example Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/api-reference/context-settings.md An example of a component that allows users to select and update the application's locale using the useSettings hook and a select element. Assumes Locales array is available. ```typescript import {Locales} from '@/types/settings'; import {useSettings} from '@/app/hooks/useSettings'; export function LocaleSelector() { const settings = useSettings(); return ( ); } ``` -------------------------------- ### Stripe Client Usage Examples Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/api-reference/stripe-client.md Demonstrates common Stripe API operations using the pre-initialized client, such as retrieving accounts, creating account sessions, and listing financial accounts. Ensure the Stripe client is imported correctly. ```typescript import {stripe} from '@/lib/stripe'; // Retrieve a Stripe account const account = await stripe.accounts.retrieve('acct_123456789'); // Create an account session for Connect embedded components const accountSession = await stripe.accountSessions.create({ account: 'acct_123456789', components: { account_onboarding: {enabled: true}, }, }); // List financial accounts const accounts = await stripe.treasury.financialAccounts.list( {limit: 10}, {stripeAccount: 'acct_123456789'} ); ``` -------------------------------- ### MONGO_URI Examples Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/configuration.md MongoDB connection string for the application database. Supports both local and cloud (Atlas) instances. The database name defaults to 'furever'. ```bash # Local MongoDB MONGO_URI=mongodb://localhost:27017/furever ``` ```bash # MongoDB Atlas (cloud) MONGO_URI=mongodb+srv://username:password@cluster.mongodb.net/furever ``` -------------------------------- ### NEXTAUTH_URL Examples Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/configuration.md The public URL of the application, used for NextAuth callbacks and redirects. Must match the protocol, domain, and port exactly. ```bash # Development NEXTAUTH_URL=http://localhost:3000 ``` ```bash # Production NEXTAUTH_URL=https://furever.dev ``` -------------------------------- ### GET /api/debug/get_demo_account Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Retrieves a demo account for testing purposes. This is useful for setting up test environments. ```APIDOC ## GET /api/debug/get_demo_account ### Description Retrieves a demo account for testing purposes. This is useful for setting up test environments. ### Method GET ### Endpoint /api/debug/get_demo_account ``` -------------------------------- ### Pre-save Password Hashing Hook Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/api-reference/models.md Automatically hashes the password before saving if it has been modified and the account is not a quickstart account. For quickstart accounts, the plain text password is stored. ```typescript SalonSchema.pre('save', function (next) { if (this.isModified('password') && !this.quickstartAccount) { this.password = this.generateHash(this.password); } else if (this.quickstartAccount) { this.password = this.password; // Store plain text } next(); }); ``` -------------------------------- ### Configuration Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/MANIFEST.md Details the environment variables, Stripe API version, database options, session strategy, default settings, and theme constants required for application setup and operation. ```APIDOC ## Configuration ### Description Outlines the necessary configuration parameters, including environment variables, Stripe API settings, database options, and default application constants. ### Environment Variables: - 9 environment variables (5 required, 4 optional). ### Stripe Configuration: - Stripe API version. ### Database Configuration: - Database connection options. ### Authentication Configuration: - NextAuth session strategy. ### Application Defaults: - Default settings and theme constants. ### Security: - Security considerations for the application. ``` -------------------------------- ### NEXT_PUBLIC_STRIPE_PUBLIC_KEY Example Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/configuration.md Stripe publishable key for client-side operations. Must correspond to the same Stripe account as STRIPE_SECRET_KEY. Enables Stripe Connect embedded components. ```bash NEXT_PUBLIC_STRIPE_PUBLIC_KEY=pk_test_51H8u2E4eC39HqLyj ``` -------------------------------- ### useSettings Hook Usage Example Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/api-reference/context-settings.md Shows how to access global settings within a component using the useSettings hook. Import the hook from '@/app/hooks/useSettings'. ```typescript import {useSettings} from '@/app/hooks/useSettings'; export function MyComponent() { const settings = useSettings(); return
Locale: {settings.locale}
; } ``` -------------------------------- ### GET /api/account_link Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Create or redirect to an account link for onboarding flows. Requires JWT authentication. ```APIDOC ## GET /api/account_link ### Description Create or redirect to an account link for onboarding flows. Requires JWT authentication. ### Method GET ### Endpoint /api/account_link ### Parameters #### Query Parameters - **type** (string) - Required - Account link type (e.g., "account_onboarding") - **shouldRedirect** (boolean) - Optional - If true, redirects to Stripe link (307); if false, returns JSON ### Response #### Success Response (200) - **url** (string) - The URL for the account link. #### Response (307/303) Redirects directly to Stripe (if shouldRedirect=true) ### Response Example ```json { "url": "https://connect.stripe.com/ல்கள்" } ``` ### Error Responses - **400**: No connected account or link type missing - **500**: Stripe API error ### Notes - Typical link types: `account_onboarding`, `account_update` - Return/refresh URLs: Return to same endpoint with shouldRedirect=true - Authentication: Required (JWT) - Source: `app/api/account_link/route.ts` ``` -------------------------------- ### Update Settings with Custom Branding Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/api-reference/context-settings.md Example of how to update the settings context with custom branding properties. This function should be called within your application's logic. ```typescript const settings = useSettings(); settings.handleUpdate({ primaryColor: '#FF5733', companyName: 'My Pet Salon', companyLogoUrl: 'https://example.com/logo.png' }); ``` -------------------------------- ### GET /api/capital/get_financing_offer Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Retrieves the most recent financing offer for the account. It provides details about the financing type and state. ```APIDOC ## GET /api/capital/get_financing_offer ### Description Retrieves the most recent financing offer for the account. It provides details about the financing type and state. ### Method GET ### Endpoint /api/capital/get_financing_offer ### Response #### Success Response (200) ```json { "offer": { "id": "dlr_123456", "financing_type": "flex_loan", "state": "delivered" } } ``` #### Error Responses - **403**: Not authenticated - **500**: Stripe API error ``` -------------------------------- ### Find a Salon by Email or Stripe Account ID Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/api-reference/models.md Provides examples for finding a Salon document in the database using either the email address or the Stripe account ID. ```typescript import Salon from '@/app/models/salon'; import dbConnect from '@/lib/dbConnect'; await dbConnect(); // Find by email const salon = await Salon.findOne({email: 'salon@example.com'}); // Find by Stripe account const bySalmon = await Salon.findOne({stripeAccountId: 'acct_123'}); ``` -------------------------------- ### resolveControllerParams() Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/api-reference/utilities.md Converts controller parameter flags to Stripe account controller configuration. Maps input parameters to the correct Stripe API configuration for account setup. ```APIDOC ## resolveControllerParams() ### Description Converts controller parameter flags to Stripe account controller configuration. Maps input parameters to the correct Stripe API configuration for account setup. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **feePayer** (string) - Yes - "application" or "account" - **paymentLosses** (string) - Yes - "application" or "stripe" - **stripeDashboardType** (string) - Yes - "none", "express", or "full" ### Returns Stripe controller configuration object ### Configuration Logic - **Fees payer:** Maps "application" to application, otherwise account - **Losses:** Maps "application" to application, otherwise stripe - **Dashboard:** Maps to corresponding Stripe dashboard type - **Requirement collection:** Set to "application" if both paymentLosses='application' AND stripeDashboardType='none', otherwise "stripe" ### Returns Type ```typescript { fees: {payer: 'application' | 'account'}, losses: {payments: 'application' | 'stripe'}, stripe_dashboard: {type: 'none' | 'express' | 'full'}, requirement_collection: 'application' | 'stripe' } ``` ### Usage Example ```typescript import {resolveControllerParams} from '@/lib/utils'; const controller = resolveControllerParams({ feePayer: 'application', paymentLosses: 'stripe', stripeDashboardType: 'full' }); // Creates Stripe account with: // - Platform pays fees // - Stripe takes payment losses // - Full Stripe dashboard access ``` ``` -------------------------------- ### STRIPE_SECRET_KEY Example Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/configuration.md Stripe secret API key for server-side operations. Used to make authenticated requests to the Stripe API. Store securely and never expose to client-side code. ```bash STRIPE_SECRET_KEY=sk_test_4eC39HqLyjWDarhnowCH82Cq ``` -------------------------------- ### STRIPE_WEBHOOK_SECRET Example Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/configuration.md Webhook signing secret for validating incoming Stripe webhook events. Used to construct and verify webhook signatures. Obtain from the Stripe Dashboard. ```bash STRIPE_WEBHOOK_SECRET=whsec_test_Ghuw6pD1v2QEBT3kVQnQ ``` -------------------------------- ### NEXTAUTH_SECRET Generation and Example Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/configuration.md Secret key used by NextAuth to encrypt JWT tokens and sessions. Must be cryptographically random and kept secret. Changing this requires re-authentication of all users. ```bash openssl rand -base64 32 ``` ```bash NEXTAUTH_SECRET=PkGv2qh8jQ7xRfZ9yL3mK5nW2bD6xC9pT4vS6yH8j+k= ``` -------------------------------- ### POST /api/setup_accounts Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Creates test payment data for a newly verified account. It sets up initial charges, disputes, and payouts, and marks the account as set up. ```APIDOC ## POST /api/setup_accounts ### Description Creates test payment data for a newly verified account. It sets up initial charges, disputes, and payouts, and marks the account as set up. ### Method POST ### Endpoint /api/setup_accounts ### Parameters #### Request Body None ### Response #### Success Response (200) "Success" or "Already setup" #### Error Responses - **403**: Not authenticated - **500**: Stripe API error ``` -------------------------------- ### POST /api/setup_accounts/create_financial_credit Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Creates a test financial account credit. This simulates a credit being applied to the account. ```APIDOC ## POST /api/setup_accounts/create_financial_credit ### Description Creates a test financial account credit. This simulates a credit being applied to the account. ### Method POST ### Endpoint /api/setup_accounts/create_financial_credit ### Parameters #### Request Body None ### Response Financial credit created ``` -------------------------------- ### Create a New Salon Instance Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/api-reference/models.md Demonstrates creating a new Salon instance with basic details and saving it to the database. The password is automatically hashed by a pre-save hook. ```typescript import Salon from '@/app/models/salon'; import dbConnect from '@/lib/dbConnect'; await dbConnect(); const salon = new Salon({ email: 'salon@example.com', password: 'plainTextPassword', firstName: 'John', lastName: 'Doe', businessName: 'John\'s Pet Salon' }); await salon.save(); // Password auto-hashed due to pre-save hook ``` -------------------------------- ### GET /api/company_name Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Retrieves the user's custom company name. ```APIDOC ## GET /api/company_name ### Description Retrieve user's custom company name. ### Method GET ### Endpoint /api/company_name ### Response #### Success Response (200) - **companyName** (string) - Description #### Response Example { "companyName": "Custom Salon" } ``` -------------------------------- ### GET /api/company_logo Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Retrieves the URL for the user's custom company logo. ```APIDOC ## GET /api/company_logo ### Description Retrieve user's custom company logo URL. ### Method GET ### Endpoint /api/company_logo ### Response #### Success Response (200) - **companyLogoUrl** (string) - Description #### Response Example { "companyLogoUrl": "https://stripe.com/logo.png" } ``` -------------------------------- ### POST /api/setup_accounts/create_disputes Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Creates test disputes on a connected account. This endpoint simulates customer disputes against charges. ```APIDOC ## POST /api/setup_accounts/create_disputes ### Description Creates test disputes on a connected account. This endpoint simulates customer disputes against charges. ### Method POST ### Endpoint /api/setup_accounts/create_disputes ### Parameters #### Request Body None ### Response Test disputes created ``` -------------------------------- ### POST /api/setup_accounts/create_bank_account Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Creates a test bank account on a connected account. This is used for payout and other financial operations. ```APIDOC ## POST /api/setup_accounts/create_bank_account ### Description Creates a test bank account on a connected account. This is used for payout and other financial operations. ### Method POST ### Endpoint /api/setup_accounts/create_bank_account ### Parameters #### Request Body None ### Response Bank account created ``` -------------------------------- ### GET /api/login_link Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Generate Express dashboard login link. Requires JWT authentication. ```APIDOC ## GET /api/login_link ### Description Generate Express dashboard login link. Requires JWT authentication. ### Method GET ### Endpoint /api/login_link ### Response #### Success Response (200) - **url** (string) - The login link for the Express dashboard. ### Response Example ```json { "url": "https://dashboard.stripe.com/ல்கள்" } ``` ### Error Responses - **400**: No Stripe account or no Express dashboard access - **500**: Stripe API error ### Notes - Requirements: User must have Express dashboard type (not "none" or "full") - Authentication: Required (JWT) - Source: `app/api/login_link/route.ts` ``` -------------------------------- ### GET /api/capital/get_line_of_credit_summary Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Retrieves a summary of the line of credit for the account. This provides an overview of the credit facility. ```APIDOC ## GET /api/capital/get_line_of_credit_summary ### Description Retrieves a summary of the line of credit for the account. This provides an overview of the credit facility. ### Method GET ### Endpoint /api/capital/get_line_of_credit_summary ``` -------------------------------- ### GET /api/primary_color Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Retrieve user's custom primary color. Requires JWT authentication. ```APIDOC ## GET /api/primary_color ### Description Retrieve user's custom primary color. Requires JWT authentication. ### Method GET ### Endpoint /api/primary_color ### Response #### Success Response (200) - **primaryColor** (string) - The user's custom primary color in hex format. ### Response Example ```json { "primaryColor": "#27AE60" } ``` ### Error Responses - **401**: Unauthorized - **404**: User not found - **500**: Database error ### Notes - Authentication: Required (JWT) - Source: `app/api/primary_color/route.ts` ``` -------------------------------- ### POST /api/setup_accounts/create_payouts Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Creates test payouts on a connected account. This endpoint simulates money being sent out from the account. ```APIDOC ## POST /api/setup_accounts/create_payouts ### Description Creates test payouts on a connected account. This endpoint simulates money being sent out from the account. ### Method POST ### Endpoint /api/setup_accounts/create_payouts ### Parameters #### Request Body None ### Response Test payouts created ``` -------------------------------- ### Create Test Financing Offer Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Creates a test financing offer in test mode with specified parameters. Uses a preview API for capital operations. ```json { "offerState": "delivered" } ``` -------------------------------- ### GET /api/financial_account Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Retrieves the first (newest) financial account associated with the user's Stripe account. ```APIDOC ## GET /api/financial_account ### Description Retrieve the first financial account for the user's Stripe account. ### Method GET ### Endpoint /api/financial_account ### Response #### Success Response (200) - **financial_account** (string) - Description #### Response Example { "financial_account": "fa_123456789" } ``` -------------------------------- ### POST /api/setup_accounts/create_charges Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Creates test charge payments on a connected account. This endpoint is used to simulate incoming payments. ```APIDOC ## POST /api/setup_accounts/create_charges ### Description Creates test charge payments on a connected account. This endpoint is used to simulate incoming payments. ### Method POST ### Endpoint /api/setup_accounts/create_charges ### Parameters #### Request Body None ### Response Test payment data created ``` -------------------------------- ### GET /api/get_stripe_account Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Retrieve complete Stripe account object for the current user. Requires JWT authentication. ```APIDOC ## GET /api/get_stripe_account ### Description Retrieve complete Stripe account object for the current user. Requires JWT authentication. ### Method GET ### Endpoint /api/get_stripe_account ### Response #### Success Response (200) - **id** (string) - The Stripe account ID. - **object** (string) - The object type, always "account". - **email** (string) - The account's email address. - **country** (string) - The account's country. - **type** (string) - The account type (e.g., "custom"). - **controller** (object) - Controller configuration. - **capabilities** (object) - Account capabilities. ### Response Example ```json { "id": "acct_123456789", "object": "account", "email": "user@example.com", "country": "US", "type": "custom", "controller": {}, "capabilities": {}, ... } ``` ### Error Responses - **401**: No Stripe account found - **500**: Stripe API error ### Notes - Contains full Stripe account details: controller configuration, capabilities, requirements, etc. - Authentication: Required (JWT) - Source: `app/api/get_stripe_account/route.ts` ``` -------------------------------- ### GET /api/account_info Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Retrieve current user's local account information. Requires JWT authentication. ```APIDOC ## GET /api/account_info ### Description Retrieve current user's local account information. Requires JWT authentication. ### Method GET ### Endpoint /api/account_info ### Response #### Success Response (200) - **changedPassword** (boolean) - Indicates if the password has been changed. - **password** (string) - The user's password (plain if not changed, empty if changed). - **businessName** (string) - The name of the business. - **setup** (boolean) - Indicates if the account setup is complete. - **email** (string) - The user's email address. ### Response Example ```json { "changedPassword": false, "password": "plain_password", "businessName": "FurEver Services", "setup": false, "email": "user@example.com" } ``` ### Error Responses - **401**: No email in token - **404**: User not found - **500**: Database error ### Notes - Returns empty password if changedPassword is false - Returns plain password if not yet changed (for setup flows) - Authentication: Required (JWT) - Source: `app/api/account_info/route.ts` ``` -------------------------------- ### Enable Preview Components Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/README.md Add this variable to your .env file to enable preview components. Ensure you have requested access for your platforms in the Stripe documentation. ```dotenv NEXT_PUBLIC_ENABLE_PREVIEW_COMPONENTS=1 ``` -------------------------------- ### Get Line of Credit Summary Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Retrieves a summary of the line of credit for the account. This endpoint is part of the capital and financing API. ```typescript app/api/capital/get_line_of_credit_summary/route.ts ``` -------------------------------- ### POST /api/setup_accounts/create_risk_intervention Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Creates test risk intervention requirements. This simulates scenarios that trigger risk assessments. ```APIDOC ## POST /api/setup_accounts/create_risk_intervention ### Description Creates test risk intervention requirements. This simulates scenarios that trigger risk assessments. ### Method POST ### Endpoint /api/setup_accounts/create_risk_intervention ### Parameters #### Request Body None ### Response Risk intervention created ``` -------------------------------- ### POST /api/capital/create_test_financing Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Creates a test financing offer in test mode with specified parameters. This is for simulating financing scenarios. ```APIDOC ## POST /api/capital/create_test_financing ### Description Creates a test financing offer in test mode with specified parameters. This is for simulating financing scenarios. ### Method POST ### Endpoint /api/capital/create_test_financing ### Parameters #### Request Body ```json { "offerState": "delivered" } ``` ### Response #### Success Response (200) ```json {} ``` #### Error Responses - **403**: Not authenticated - **500**: Stripe API error ``` -------------------------------- ### Create Account Link Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Creates or redirects to an account link for onboarding flows. Can return JSON or redirect to Stripe. Requires JWT authentication. ```json { "url": "https://connect.stripe.com/..." } ``` -------------------------------- ### Initialize Stripe Client Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/api-reference/stripe-client.md Initializes the Stripe client with the secret key from environment variables and a specific API version. This instance is intended for server-side operations. ```typescript const stripe = new Stripe(process.env.STRIPE_SECRET_KEY, { apiVersion: latestApiVersion, }); ``` -------------------------------- ### POST /api/capital/fully_repay_test_financing Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Marks a test financing offer as fully repaid. This simulates the complete repayment of a financing offer. ```APIDOC ## POST /api/capital/fully_repay_test_financing ### Description Marks a test financing offer as fully repaid. This simulates the complete repayment of a financing offer. ### Method POST ### Endpoint /api/capital/fully_repay_test_financing ``` -------------------------------- ### Validate Password Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/api-reference/models.md Validates a plain text password against the stored hash. Performs a plain text comparison for quickstart accounts and a bcrypt comparison otherwise. ```typescript SalonSchema.methods.validatePassword = function (password) { if (!this.changedPassword) { return password == this.password; // Plain text comparison for quickstart } return bcrypt.compareSync(password, this.password); // Hash comparison }; ``` -------------------------------- ### Initialize Stripe Connect Instance Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/api-reference/hooks.md Initializes and manages a Stripe Connect instance for embedded components. Fetches account session client secret, initializes Stripe Connect with locale, theme, and appearance settings, and updates settings dynamically. Handles errors during account session fetch. ```typescript export const useConnect = () => { // ... implementation return { hasError: boolean; stripeConnectInstance: StripeConnectInstance | null; }; } ``` ```typescript import {useConnect} from '@/app/hooks/useConnect'; import {ConnectPayments} from '@stripe/react-connect-js'; export function PaymentsPage() { const {stripeConnectInstance, hasError} = useConnect(); if (hasError) { return
Error loading Connect
; } if (!stripeConnectInstance) { return
Loading...
; } return ( ); } ``` -------------------------------- ### POST /api/debug/create_issuing_card_authorization Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Creates a test issuing card authorization for demonstration purposes. ```APIDOC ## POST /api/debug/create_issuing_card_authorization ### Description Creates a test issuing card authorization for demo. ### Method POST ### Endpoint /api/debug/create_issuing_card_authorization ``` -------------------------------- ### POST /api/capital/create_side_by_side_offer Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Creates a side-by-side financing offer. This allows for comparing different financing options. ```APIDOC ## POST /api/capital/create_side_by_side_offer ### Description Creates a side-by-side financing offer. This allows for comparing different financing options. ### Method POST ### Endpoint /api/capital/create_side_by_side_offer ``` -------------------------------- ### POST /api/auth/[...nextauth] Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md NextAuth authentication endpoint handling sign-in, sign-out, session management, and callback routes. Supports various providers for login, signup, and account creation. ```APIDOC ## POST /api/auth/[...nextauth] ### Description NextAuth authentication endpoint handling sign-in, sign-out, session management, and callback routes. Supports various providers for login, signup, and account creation. ### Method POST ### Endpoint /api/auth/[...nextauth] ### Parameters #### Path Parameters - **provider** (string) - Optional - The authentication provider (e.g., `login`, `signup`, `loginas`, `createaccount`, `createprefilledaccount`, `updateemail`). ### Notes - See: [Authentication Module](api-reference/authentication.md) for provider details - Source: `app/api/auth/[...nextauth]/route.ts` ``` -------------------------------- ### Client-side Integration with Connect Embedded Components Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/README.md Demonstrates the client-side integration with Stripe Connect embedded components. This file shows how to use the components within a React application. ```typescript import { ConnectComponentsProvider, ConnectOnboarding, ConnectPayments, ConnectPayouts, ConnectAccountManagement, ConnectNotificationBanner, ConnectDocuments, ConnectTaxSettings, ConnectTaxRegistrations, ConnectCapitalOverview, ConnectFinancialAccount, ConnectFinancialAccountTransactions, ConnectIssuingCardsList, } from '@stripe/connect-react'; import { useRouterEvents, useStripeConnect, } from '~/hooks/useConnect'; export const ConnectComponents = () => { const { account, isTest } = useStripeConnect(); const { navigateTo } = useRouterEvents(); if (!account) { return null; } return (
); }; ``` -------------------------------- ### Default Settings Object Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/api-reference/context-settings.md Represents the default configuration for application settings, including locale, theme, and overlay preferences. ```typescript export const defaultSettings: Settings = { locale: 'en-US', theme: 'light', overlay: 'dialog', } ``` -------------------------------- ### SettingsConsumer Component Usage Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/api-reference/context-settings.md Example of using the SettingsConsumer to access settings values within a React component. This allows child components to read context data like the current locale. ```typescript import {SettingsConsumer} from '@/app/contexts/settings/SettingsConsumer'; export function WithSettings() { return ( {(settings) => (
Current locale: {settings.locale}
)}
); } ``` -------------------------------- ### Set Node Environment to Production Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/configuration.md Sets the Node.js environment to production mode, hiding debug features and optimizing for performance. ```bash NODE_ENV=production ``` -------------------------------- ### React Hook Form Integration with Zod Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/api-reference/forms.md Integrates Zod validation with React Hook Form using zodResolver. This setup automatically handles validation and error messages within a React form component. Requires importing useForm, zodResolver, and UserFormSchema. ```typescript import {useForm} from 'react-hook-form'; import {zodResolver} from '@hookform/resolvers/zod'; import {UserFormSchema} from '@/lib/forms'; function LoginForm() { const {register, handleSubmit, formState: {errors}} = useForm({ resolver: zodResolver(UserFormSchema) }); const onSubmit = (data) => { // data is type-safe and validated console.log(data); }; return (
{errors.email && {errors.email.message}} {errors.password && {errors.password.message}}
); } ``` -------------------------------- ### Create Side-by-Side Offer Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Creates a side-by-side financing offer. This allows for presenting multiple financing options to the account. ```typescript app/api/capital/create_side_by_side_offer/route.ts ``` -------------------------------- ### Create Test Financial Credit Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Creates a test financial credit for an account. This simulates incoming funds or adjustments to the account balance. ```typescript app/api/setup_accounts/create_financial_credit/route.ts ``` -------------------------------- ### Verify Required Environment Variables Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/configuration.md Checks if essential environment variables like Stripe API keys and MongoDB URI are set in the current shell environment. ```bash # Verify required variables echo $STRIPE_SECRET_KEY echo $NEXT_PUBLIC_STRIPE_PUBLIC_KEY echo $MONGO_URI echo $STRIPE_WEBHOOK_SECRET ``` -------------------------------- ### POST /api/capital/approve_test_financing Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Approves a test financing offer. This simulates the acceptance of a financing offer. ```APIDOC ## POST /api/capital/approve_test_financing ### Description Approves a test financing offer. This simulates the acceptance of a financing offer. ### Method POST ### Endpoint /api/capital/approve_test_financing ### Parameters #### Request Body ```json { "offerState": "accepted" } ``` ``` -------------------------------- ### Update Salon Fields Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/api-reference/models.md Demonstrates how to update specific fields of a Salon document using `findOneAndUpdate`. The `new: true` option ensures the updated document is returned. ```typescript import Salon from '@/app/models/salon'; // Update specific fields const updated = await Salon.findOneAndUpdate( {email: 'salon@example.com'}, { primaryColor: '#FF5733', companyName: 'New Salon Name' }, {new: true} // Returns updated document ); ``` -------------------------------- ### POST /api/payment_method_settings/create_checkout_session Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Creates a checkout session specifically for testing payment method configuration. ```APIDOC ## POST /api/payment_method_settings/create_checkout_session ### Description Create checkout session for payment method configuration testing. ### Method POST ### Endpoint /api/payment_method_settings/create_checkout_session ``` -------------------------------- ### Create Stripe Account Session Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/README.md Create a Stripe account session to enable embedded components like account onboarding and payments. Requires a valid Stripe account ID. ```typescript import {stripe} from '@/lib/stripe'; const session = await stripe.accountSessions.create({ account: 'acct_123', components: { account_onboarding: {enabled: true}, payments: {enabled: true} } }); ``` -------------------------------- ### Listen for Stripe Events Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/README.md Run this command in a separate terminal to listen for events sent to your event handler. It forwards events to localhost:3000/api/webhooks. ```bash stripe listen --forward-to localhost:3000/api/webhooks ``` -------------------------------- ### POST /api/capital/reject_test_financing Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Rejects a test financing offer. This simulates the rejection of a financing offer. ```APIDOC ## POST /api/capital/reject_test_financing ### Description Rejects a test financing offer. This simulates the rejection of a financing offer. ### Method POST ### Endpoint /api/capital/reject_test_financing ``` -------------------------------- ### createprefilledaccount Provider Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/api-reference/authentication.md Creates a pre-filled Stripe account with test data and a corresponding local user. This is useful for rapid account creation and demo purposes. ```APIDOC ## createprefilledaccount Provider ### Description This provider creates a Stripe account pre-filled with test data, along with a corresponding local user account. It's designed for rapid setup and demonstration purposes. ### Credentials - **email** (string) - Required - User email address - **password** (string) - Required - User password - **businessName** (string) - Optional - Business name for the Stripe account ### Process 1. Creates a test bank account token with Stripe. 2. Checks if the user already exists. 3. Creates a new local user with a quickstart flag. 4. Creates a unified Stripe account with pre-filled information: - Controller: application as fee payer and loss payer, no dashboard access. - Business type: individual. - Business profile: pre-filled with "Furever" data. - Individual: pre-filled with "Jenny Rosen" test data. - External account: test bank account. ### Returns User payload with id, email, stripeAccountId, businessName ### Test Data Uses hardcoded test data for rapid account creation and demo purposes. ``` -------------------------------- ### API Endpoints Reference Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/MANIFEST.md This section details all available API endpoints for managing authentication, accounts, user settings, capabilities, financial accounts, test data, capital, financing, and debugging. It also covers webhook endpoints. ```APIDOC ## API Endpoints ### Description Provides a comprehensive reference for all API endpoints used within the Stripe Connect FurEver demo application. This includes endpoints for authentication, account management, user settings, financial operations, testing, and debugging. ### Endpoint Categories - Authentication endpoints - Account management (session, info, link, Stripe account) - User settings (color, company name, logo, password, email) - Capabilities and financial accounts - Test data setup - Capital and financing - Debug endpoints - Webhooks ``` -------------------------------- ### useSettings Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/api-reference/hooks.md Accesses the settings context containing locale, theme, branding, and component options. This hook provides access to global application settings managed by SettingsProvider, used for theming and localization. ```APIDOC ## `useSettings` ### Description Accesses the settings context containing locale, theme, branding, and component options. This hook provides access to global application settings managed by SettingsProvider, used for theming and localization. ### Returns - **locale** (string) - Selected locale code (e.g., "en-US") - **theme** (string) - "light" or "dark" theme - **overlay** (OverlayOption) - Overlay type from Stripe: "dialog" or "sheet" - **primaryColor** (string) - Custom primary color hex value - **companyName** (string) - Custom company name - **companyLogoUrl** (string) - Custom company logo URL - **handleUpdate** (function) - Update settings callback - **enableBetaComponents** (boolean) - Preview components enabled flag ### Usage Example ```typescript import {useSettings} from '@/app/hooks/useSettings'; export function SettingsDisplay() { const settings = useSettings(); return (

Locale: {settings.locale}

Theme: {settings.theme}

{settings.primaryColor && (
Custom Color
)}
); } ``` ``` -------------------------------- ### createaccount Provider Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/api-reference/authentication.md Creates a Stripe account for an existing local user with custom configuration. Allows specifying business type, name, country, dashboard type, payment losses, and fee payer. ```APIDOC ## createaccount Provider ### Description This provider creates a Stripe account for an existing local user, allowing for custom configuration of various settings including business details, country, dashboard access, payment losses, and fee payer. ### Credentials - **email** (string) - Required - User email address - **businessType** (string) - Optional - Business type: "individual", "company", or undefined - **businessName** (string) - Optional - Business name - **country** (string) - Optional - Country code (defaults to "US") - **stripeDashboardType** (string) - Required - Dashboard access: "none", "express", or "full" - **paymentLosses** (string) - Required - Loss liability: "stripe" or "application" - **feePayer** (string) - Required - Fee payer: "account" or "application" ### Process 1. Connects to MongoDB. 2. Looks up the existing user by email. 3. Creates the Stripe account with the specified configuration. 4. Updates the local user record with the newly created `stripeAccountId`. ### Configuration Uses `resolveControllerParams()` to translate dashboard and fee settings into Stripe controller parameters. ``` -------------------------------- ### Environment Variables Template Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/configuration.md A template for the .env file, outlining required environment variables for Stripe API keys, MongoDB connection, and NextAuth configuration. ```dotenv # Stripe API Keys STRIPE_SECRET_KEY=sk_test_... NEXT_PUBLIC_STRIPE_PUBLIC_KEY=pk_test_... # MongoDB MONGO_URI=mongodb+srv://user:pass@cluster.mongodb.net/furever # NextAuth NEXTAUTH_SECRET= NEXTAUTH_URL=http://localhost:3000 # Stripe Webhooks STRIPE_WEBHOOK_SECRET=whsec_test_... # Optional NEXT_PUBLIC_ENABLE_PREVIEW_COMPONENTS=0 NODE_ENV=development ``` -------------------------------- ### authOptions Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/api-reference/authentication.md The NextAuth configuration object that defines authentication providers, session strategy, and callbacks. It supports multiple credential providers for different authentication flows and Stripe account creation scenarios. ```APIDOC ## authOptions ### Description This is the main NextAuth configuration object. It defines the authentication providers, session strategy (JWT), and callback functions used by the FurEver platform. ### Type `AuthOptions` (from `next-auth`) ### Session Strategy JWT ### Sign-in/Sign-out Pages - **Sign In:** `/login` - **Sign Out:** `//` ``` -------------------------------- ### Retrieve Financing Offer Source: https://github.com/stripe/stripe-connect-furever-demo/blob/master/_autodocs/endpoints.md Fetches the most recent financing offer for an account. Requires JWT authentication and uses a preview API version. ```json { "offer": { "id": "dlr_123456", "financing_type": "flex_loan", "state": "delivered" } } ```