Portal SDK
The surface where a customer manages their own subscription, invoices and cards. This is the one SDK that supports all four modes.
<script src="https://cdn.lunixi.com/lunixi-loader.min.js"></script>Mode 0 — Anonymous catalog
For a pricing page. No session, no customer identity — it only reads the merchant's active catalog.
const catalog = Lunixi.portal.catalog({
publishableKey: 'mk_live_pk_...',
});
await catalog.plans(); // active plans
await catalog.products(); // active products
await catalog.branding(); // logo, colours, terms linksEndpoints: GET /api/public/v1/subscription/{plans,products,branding}
The key is visible in your page source, and that is expected. The protection comes from the Origin match — if the browser-set Origin is not an exact match in the allow-list registered for that key, you get 401. → Overview
Pass locale and the catalog comes back in that language.
Mode 2 — Session client
Once the customer has authenticated, they reach their own data. The session opens via OTP.
const client = Lunixi.portal.create({ /* … */ });
await client.init();
await client.requestOtp();
await client.verifyOtp(otpCode, otpChallengeId);
const me = await client.me();The session travels in the X-Portal-Session header.
| Read | Write |
|---|---|
me() | startSubscription(payload) |
plans(params) | changePlan(payload) |
subscriptions() | cancelSubscription(payload) |
invoices(params) | addCard(payload) |
cards() | updateCard(payload) |
isAuthenticated() tells you whether a session is open, getSessionState() returns its state, and logout() closes it.
Mode 1 — Pre-built portal
Renders the whole portal in one call:
await Lunixi.portal.mount('#portal', { /* … */ });Mode 3 — Mount individual pieces
When you want one component rather than the whole screen:
Lunixi.portal.plans.mount('#plan-picker', { /* … */ });
Lunixi.portal.cardForm.mount('#card-form', { /* … */ });You keep your own page layout and hand us only the hard parts.
Which mode to pick
| Need | Mode |
|---|---|
| A pricing table on a marketing site | Mode 0 — no session needed |
| A working customer portal, quickly | Mode 1 |
| Entirely your own design | Mode 2 |
| Your page plus a ready plan picker or card form | Mode 3 |
Moving between modes does not change the endpoints or the session model. Shipping with Mode 1 and later moving to Mode 2 does not mean rewriting your backend integration.
Related
- Web SDK Overview — loader, modes, authentication models
- Subscription Pricing SDK — the pricing component in detail