@lumnsh/node
v0.2.0
Published
Official Lumn Node.js SDK — provider-agnostic payment orchestration
Maintainers
Readme
@lumnsh/node
Official Lumn Node.js SDK — provider-agnostic payment orchestration.
Installation
npm install @lumnsh/nodeQuick Start
import Lumn from '@lumnsh/node';
const lumn = new Lumn({ apiKey: 'your_secret_key' });
// List customers
const customers = await lumn.customers.list();
// Check entitlement
const check = await lumn.entitlements.check({ customerId: 'cus_xxx', featureKey: 'pro' });
// Create checkout session
const session = await lumn.checkout.create({
customerId: 'cus_xxx',
productId: 'prod_xxx',
successUrl: 'https://example.com/success',
cancelUrl: 'https://example.com/cancel',
});Resources
| Resource | Methods |
|----------|---------|
| customers | list, create, retrieve |
| products | list, create, retrieve |
| features | list, create |
| entitlements | check |
| subscriptions | list |
| payments | list |
| checkout | create |
| events | list |
| meter | record |
| sync | trigger |
| connections | list, create |
| apiKeys | list, create, revoke |
Configuration
const lumn = new Lumn({
apiKey: 'your_secret_key',
baseUrl: 'https://app.lumn.dev', // default
timeout: 30_000, // default: 30s
maxRetries: 2, // default: 2
});Error Handling
import Lumn, { LumnApiError, LumnAuthenticationError } from '@lumnsh/node';
try {
await lumn.customers.retrieve('cus_invalid');
} catch (err) {
if (err instanceof LumnAuthenticationError) {
// Invalid API key
} else if (err instanceof LumnApiError) {
console.error(err.status, err.code, err.message);
}
}License
MIT
