Complete platform for managing seller accounts and payments using Stripe Connect. This demo showcases all major Stripe Connect features with a modern, interactive interface.
StripeIntegrationDemo/
βββ backend/ # NestJS API
β βββ src/
β β βββ stripe/
β β β βββ controllers/
β β β β βββ connect-account.controller.ts # Connect account management
β β β β βββ payment.controller.ts # Payment Intents and transfers
β β β β βββ checkout.controller.ts # Checkout Sessions and Payment Links
β β β βββ services/
β β β β βββ stripe.service.ts # Stripe integration logic
β β β βββ dto/ # Data Transfer Objects
β β β βββ stripe.module.ts
β β βββ app.module.ts
β β βββ main.ts
β βββ package.json
β
βββ frontend/ # Next.js App
βββ app/
β βββ connect/
β β βββ create-account/ # Create Connect account
β β βββ onboarding/ # Onboarding process
β β βββ accounts/ # Account list
β βββ payments/
β β βββ payment-intent/ # Custom payment with Stripe Elements
β β βββ checkout/ # Checkout Session (redirect)
β β βββ embedded/ # π Embedded Checkout (no redirect)
β β βββ payment-link/ # Payment Link for sharing
β β βββ demo/ # π Complete payment flow demo
β βββ page.tsx # Interactive dashboard
β βββ layout.tsx
βββ components/ # Reusable UI components
βββ lib/
β βββ api.ts # API client
βββ package.json
- β Create seller accounts (Express, Standard, Custom)
- β Complete onboarding process with Stripe verification
- β List and manage account details
- β Balance verification and status checking
- β Multiple country support (US, BR, PT, GB, DE, CA)
- β Payment Intent: Custom payments with full control and Stripe Elements
- β Checkout Session: Stripe-hosted payment page (redirect)
- β π Embedded Checkout: Integrated checkout without redirects
- β Payment Link: Shareable links for social media/email
- β π Payment Demo: Interactive preview of customer experience
- β Multiple currency support (USD, BRL, EUR, GBP)
- β Configurable platform fees and commissions
- β
Local payment methods:
- π΅πΉ Portugal: MB Way, Multibanco, Card
- π§π· Brazil: PIX, Card
- πΊπΈ US: Card, ACH
- π¬π§ UK: Card, BACS
- π©πͺ Germany: Card, SEPA
- β Real-time payment status updates
- β Transfer management between accounts
Before running the application, you need to obtain your Stripe API keys. Follow these steps:
- Go to https://stripe.com
- Click "Start now" or "Sign up"
- Fill in your information:
- Email address
- Full name
- Country (this affects available features)
- Password
- Verify your email address
- Log in to https://dashboard.stripe.com
- You'll see the main dashboard with overview metrics
- Important: Make sure you're in Test Mode (toggle in the left sidebar)
- Look for "Test mode" indicator
- Test mode allows you to simulate payments without real money
- In the left sidebar, click "Developers"
- Click "API keys"
- You'll see two types of keys:
- Safe to expose in frontend code
- Used by Stripe.js and Stripe Elements
- Example:
pk_test_51Abc123... - Copy this key - you'll need it for
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY
- Keep this secret - never expose in frontend
- Used for server-side API calls
- Example:
sk_test_51Abc123... - Copy this key - you'll need it for
STRIPE_SECRET_KEY
- In the left sidebar, click "Developers" β "Webhooks"
- Click "Add endpoint"
- Enter your endpoint URL (e.g.,
https://yourdomain.com/stripe/webhook) - Select events you want to listen to
- Copy the Signing secret (whsec_...) for
STRIPE_WEBHOOK_SECRET
You can verify your keys work by making a test API call:
curl https://api.stripe.com/v1/customers \
-u sk_test_YOUR_SECRET_KEY: \
-d email="test@example.com"- Never commit API keys to version control
- Use test keys (sktest/pktest) for development
- Use live keys (sklive/pklive) only in production
- Rotate keys if they're ever compromised
- Store keys in environment variables, not in code
After completing these steps, you should have:
| Key Type | Environment Variable | Example Value | Usage |
|---|---|---|---|
| Secret Key | STRIPE_SECRET_KEY |
sk_test_51Abc123... |
Backend API calls |
| Publishable Key | NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY |
pk_test_51Abc123... |
Frontend Stripe.js |
| Webhook Secret | STRIPE_WEBHOOK_SECRET |
whsec_abc123... |
Webhook verification |
Prerequisites:
- Docker Desktop installed
- Stripe account (test mode)
# 1. Create configuration files
copy .env.example .env
copy backend\.env.example backend\.env
# 2. Edit .env with your Stripe keys
# STRIPE_SECRET_KEY=sk_test_...
# NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_...
# 3. Build and start
docker-compose up --build -d
# Done! Access:
# Frontend: http://localhost:3000
# Backend: http://localhost:3001Useful commands:
docker-compose up -d # Start
docker-compose down # Stop
docker-compose logs -f # View logs
docker-compose restart # Restart
docker-compose ps # Statusπ Quick guide: QUICK-START.md π Complete documentation: DOCKER.md
Prerequisites:
- Node.js 18+ installed
- Stripe account (test mode)
- Stripe API keys
cd backend
# Install dependencies
npm install
# Configure environment variables
cp .env.example .env
# Edit .env and add your Stripe keys
# Start development server
npm run start:devBackend will be running at http://localhost:3001
cd frontend
# Install dependencies
npm install
# Configure environment variables
# Create a .env.local file and add:
# NEXT_PUBLIC_API_URL=http://localhost:3001
# NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_your_key
# Start development server
npm run devFrontend will be running at http://localhost:3000
- Access the home page at
http://localhost:3000 - Fill in the "Create Connect Account" form:
- Email: Seller's email address
- Country: Choose from supported countries (US, BR, PT, GB, DE, CA)
- Type: Express (recommended), Standard, or Custom
- Click "Create Connect Account"
- Important: Copy the generated Account ID - you'll need it for payments
- In the "Onboarding" section on the home page
- Paste the Account ID from step 1
- Click "Generate Verification Link"
- Click "Open Onboarding Link" to complete Stripe's verification process
- Use Stripe's test data for verification (see test data section below)
Choose from multiple payment methods:
- Best for: Integrated user experience
- Access:
/payments/embeddedor click "View Embedded" on home page - Features: No redirects, stays on your site, professional UI
- Supports: All payment methods including Multibanco for EUR
- Best for: Full control over payment flow
- Access:
/payments/payment-intent - Features: Custom UI with Stripe Elements, advanced customization
- Use case: When you need complete control over the payment experience
- Best for: Quick implementation
- Access:
/payments/checkout - Features: Stripe-hosted page, automatic mobile optimization
- Use case: When you want Stripe to handle the entire payment UI
- Best for: Social media, email, messaging
- Access:
/payments/payment-link - Features: Shareable URL, works anywhere
- Use case: WhatsApp, Instagram, email campaigns
- Best for: Testing and demonstrations
- Access:
/payments/demo - Features: Shows customer experience with mockup preview
- Use case: Understanding the complete payment flow
STRIPE_SECRET_KEY=sk_test_your_secret_key
STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secret
APP_URL=http://localhost:3000
PORT=3001NEXT_PUBLIC_API_URL=http://localhost:3001
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_your_publishable_key| Country | Code | Currency | Local Methods |
|---|---|---|---|
| πΊπΈ United States | US | USD | Card |
| π§π· Brazil | BR | BRL | Card, PIX |
| π΅πΉ Portugal | PT | EUR | Card, MB Way, Multibanco |
| π¬π§ United Kingdom | GB | GBP | Card |
| π©πͺ Germany | DE | EUR | Card, SEPA |
POST /stripe/connect/accounts- Create Connect accountGET /stripe/connect/accounts- List all accountsGET /stripe/connect/accounts/:id- Get account detailsPOST /stripe/connect/account-links- Create onboarding linkGET /stripe/connect/accounts/:id/balance- Get account balance
POST /stripe/payments/payment-intents- Create Payment IntentPOST /stripe/payments/payment-intents/:id/confirm- Confirm paymentPOST /stripe/payments/payment-intents/:id/cancel- Cancel paymentGET /stripe/payments/payment-intents/:id- Get Payment Intent detailsGET /stripe/payments/payment-methods/available- Get available payment methods
POST /stripe/checkout/sessions- Create Checkout Session (standard or embedded)POST /stripe/checkout/payment-links- Create Payment LinkPOST /stripe/checkout/payment-links/with-fee- Create Payment Link with platform feePOST /stripe/checkout/payment-intents-elements- Create Payment Intent for Stripe Elements
POST /stripe/payments/transfers- Create transfer to Connect account
- Test Mode: Always use test keys (sktest...) during development
- Onboarding: Accounts must complete onboarding before receiving payments
- Platform Fees: Configure
application_fee_amountto retain your commission - Webhooks: Configure webhooks to receive real-time event notifications
- Security: Never expose secret keys in frontend code
- Testing: Use Stripe's test card numbers for comprehensive testing
- Local Payments: Enable local payment methods for better conversion rates
- Mobile: All payment methods are mobile-optimized automatically
- Success:
4242 4242 4242 4242 - Requires authentication:
4000 0025 0000 3155 - Declined:
4000 0000 0000 9995 - Insufficient funds:
4000 0000 0000 9995 - Expired card:
4000 0000 0000 0069
- Expiration: Any future date (e.g., 12/34)
- CVC: Any 3 digits (e.g., 123)
- ZIP: Any postal code (e.g., 12345)
- Name: Any name
- Email: Any valid email format
- Phone: Any phone number format
- Address: Any address (use real format for country)
Solution:
- Verify
.envfiles exist in both root and backend directories - Check that keys start with
sk_test_andpk_test_ - Restart Docker containers after changing environment variables
Solution:
- Complete the onboarding process through the verification link
- Check that
charges_enabledistruein account details - Verify account status is not restricted
Solution:
- Ensure backend is running on port 3001
- Verify
NEXT_PUBLIC_API_URL=http://localhost:3001in frontend - Check Docker containers are both running:
docker-compose ps
Solution:
- Verify Stripe.js is loaded (check browser console)
- Ensure
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEYis set correctly - Check that the client secret is valid and not expired
Solution:
- Verify the currency is supported in the seller's country
- Check that the Connect account supports the payment method
- Ensure the account has completed onboarding for that region
This project is provided as an educational example.
Developed with β€οΈ using Stripe Connect