@lumra/module-payments
v0.1.1
Published
Lumra optional Fastify payments module (checkout + webhook routes)
Readme
@lumra/module-payments
Fastify plugin that registers POST /checkout and POST /webhook routes automatically. Uses whichever payment provider is registered via @lumra/payments.
Install
npm install @lumra/module-payments @lumra/paymentsUsage
import Fastify from 'fastify'
import { registerProvider } from '@lumra/payments'
import { createStripeConnectProvider } from '@lumra/module-stripe-connect'
import { paymentsPlugin } from '@lumra/module-payments'
import { handlePaymentWebhook } from '@lumra/module-entitlements'
registerProvider(createStripeConnectProvider({
secretKey: process.env.STRIPE_SECRET_KEY!,
webhookSecret: process.env.STRIPE_WEBHOOK_SECRET!,
}))
const app = Fastify({ logger: true })
await app.register(paymentsPlugin, {
// Called for every verified payment event
onWebhookEvent: async (event) => {
await handlePaymentWebhook(event, {
savePurchase: (purchase) => db.purchases.create(purchase),
})
},
// Optional: override the checkout route to add auth + pricing lookup
// createCheckout: async (req) => {
// const { resourceId, optionId } = req.body
// const video = await db.videos.findById(resourceId)
// const option = video.pricing.find(p => p.id === optionId)
// return getProvider('stripe').createCheckoutSession({ ...option, resourceId })
// },
})
await app.listen({ port: 3001 })The plugin registers:
POST /checkout— creates a checkout session and returns{ url }POST /webhook— verifies and handles the payment provider webhook
© 2026 Reel Foundry AU. All rights reserved.
MIT License — see LICENSE
