@lumra/module-stripe-connect
v0.1.1
Published
Lumra Stripe Connect payment provider implementation
Readme
@lumra/module-stripe-connect
Stripe Connect payment provider for Lumra. Supports direct charges, destination charges (creator payouts), and platform fees. Verifies Stripe webhooks automatically.
Install
npm install @lumra/module-stripe-connect @lumra/paymentsSetup
import { registerProvider } from '@lumra/payments'
import { createStripeConnectProvider } from '@lumra/module-stripe-connect'
registerProvider(createStripeConnectProvider({
secretKey: process.env.STRIPE_SECRET_KEY!,
webhookSecret: process.env.STRIPE_WEBHOOK_SECRET!,
}))Create a checkout session
import { getProvider } from '@lumra/payments'
const session = await getProvider('stripe').createCheckoutSession({
resourceId: 'video-123',
userId: 'user-456',
amount: 999, // cents — always look this up from your DB
currency: 'usd',
successUrl: 'https://yourapp.com/watch/video-123?success=1',
cancelUrl: 'https://yourapp.com/watch/video-123',
// For creator marketplace (Stripe Connect):
creatorAccountId: 'acct_1ExampleStripeID', // creator's connected Stripe account
platformFee: 200, // cents — platform keeps this, rest goes to creator
})
// Redirect the user to session.urlHandle Stripe webhook
Always use the raw request body — do not let your framework parse it as JSON first.
// Express
app.post('/api/webhook', express.raw({ type: 'application/json' }), async (req, res) => {
const sig = req.headers['stripe-signature'] as string
const event = await getProvider('stripe').handleWebhook(req.body as Buffer, sig)
// event.type, event.resourceId, event.userId
res.json({ received: true })
})
// Fastify
app.addContentTypeParser('application/json', { parseAs: 'buffer' }, (_, body, done) => done(null, body))
app.post('/api/webhook', async (req, reply) => {
const event = await getProvider('stripe').handleWebhook(req.body as Buffer, req.headers['stripe-signature'] as string)
reply.send({ received: true })
})Stripe Dashboard setup
- Go to dashboard.stripe.com/test/apikeys → copy your Secret key
- Go to dashboard.stripe.com/test/webhooks → add endpoint → select
checkout.session.completed - Copy the Signing secret → set as
STRIPE_WEBHOOK_SECRET
Local testing:
stripe listen --forward-to localhost:3001/api/webhook/stripeTest cards
| Card number | Result |
|---|---|
| 4242 4242 4242 4242 | Payment succeeds |
| 4000 0000 0000 9995 | Payment declined |
| 4000 0025 0000 3155 | Requires 3D Secure |
Use any future expiry date and any 3-digit CVV.
© 2026 Reel Foundry AU. All rights reserved.
MIT License — see LICENSE
