Stripe Connect enables multi-tenant payment processing. Each organization can connect their own Stripe account to accept payments.
sk_)pk_)STRIPE_SECRET_KEY=sk_test_...
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_...
NEXT_PUBLIC_APP_URL=http://localhost:3000
STRIPE_DEFAULT_COUNTRY=US
http://localhost:3000/api/webhooks/stripe (use ngrok)https://yourdomain.com/api/webhooks/stripeSelect these events:
payment_intent.succeededpayment_intent.payment_failedaccount.updatedaccount.application.deauthorizedwhsec_)STRIPE_WEBHOOK_SECRET=whsec_...
The onboarding flow is handled in OpenInvoice:
Track account status:
import Stripe from 'stripe';
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);
const paymentIntent = await stripe.paymentIntents.create({
amount: invoiceAmount,
currency: 'usd',
customer: customerId,
payment_method: paymentMethodId,
application_fee_amount: platformFee, // Optional
}, {
stripeAccount: connectedAccountId, // Organization's Stripe account
});
import Stripe from 'stripe';
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);
const event = stripe.webhooks.constructEvent(
req.body,
signature,
process.env.STRIPE_WEBHOOK_SECRET!
);
if (event.type === 'payment_intent.succeeded') {
// Update invoice status
// Record payment
// Send confirmation email
}
Set platform fee percentage:
STRIPE_PLATFORM_FEE_PERCENTAGE=2.9
Fees are calculated and applied automatically.
4242 4242 4242 42424000 0000 0000 0002