@lumra/module-paypal
v0.1.1
Published
Lumra PayPal payment provider implementation
Readme
@lumra/module-paypal
PayPal payment provider for Lumra. Supports PayPal Orders API checkout with webhook verification.
Install
npm install @lumra/module-paypal @lumra/paymentsSetup
import { registerProvider } from '@lumra/payments'
import { createPayPalProvider } from '@lumra/module-paypal'
registerProvider(createPayPalProvider({
clientId: process.env.PAYPAL_CLIENT_ID!,
clientSecret: process.env.PAYPAL_CLIENT_SECRET!,
sandbox: process.env.NODE_ENV !== 'production', // true = sandbox mode
}))Create a checkout session
import { getProvider } from '@lumra/payments'
const session = await getProvider('paypal').createCheckoutSession({
resourceId: 'video-123',
userId: 'user-456',
amount: 999, // cents — always from your DB
currency: 'USD',
successUrl: 'https://yourapp.com/watch/video-123?success=1',
cancelUrl: 'https://yourapp.com/watch/video-123',
})
// Redirect user to session.url (PayPal checkout page)Handle PayPal webhook
app.post('/api/webhook/paypal', async (req, res) => {
const event = await getProvider('paypal').handleWebhook(
req.body as Buffer,
req.headers['paypal-transmission-sig'] as string,
)
if (event.type === 'checkout.session.completed') {
await db.purchases.create({
userId: event.userId,
resourceId: event.resourceId,
grantedAt: Date.now(),
})
}
res.json({ received: true })
})PayPal sandbox credentials
- Go to developer.paypal.com → Apps & Credentials
- Create a new app under Sandbox
- Copy Client ID and Secret → set as
PAYPAL_CLIENT_IDandPAYPAL_CLIENT_SECRET - Set
sandbox: trueincreatePayPalProvider()
Test buyer account: use the sandbox buyer account generated in the PayPal Developer Dashboard.
© 2026 Reel Foundry AU. All rights reserved.
MIT License — see LICENSE
