@outerjoyn/sdk-js
v1.0.0
Published
Thin loader shim for the OuterJoyn browser SDK — loads sdk.outerjoyn.com/v1/loader.js. Do not bundle the SDK; load it from the CDN.
Downloads
23
Maintainers
Readme
@outerjoyn/sdk-js
Loading wrapper for the OuterJoyn browser SDK — the pay-with-points, multi-currency checkout SDK.
Like @stripe/stripe-js, this package
does not bundle the SDK. It injects the canonical CDN loader tag
(https://sdk.outerjoyn.com/v1/loader.js) and hands you back the initialised
window.OuterJoyn object. Loading from the CDN is required so security fixes,
new loyalty currencies, and new features reach every embed without a merchant
redeploy. Bundling a copy of the SDK into your build is unsupported.
Install
npm install @outerjoyn/sdk-jsUsage
import { loadOuterJoyn } from '@outerjoyn/sdk-js';
// Injects loader.js, then lazily loads the widget bundles you name.
const oj = await loadOuterJoyn({ modules: ['pay'] });
oj.pay.open({
sessionToken, // minted server-side (POST /api/sdk/sessions)
orderTotal: 8500, // cents
onPointsChanged: (state) => updateCheckoutTotal(state.remainingOrderCents),
});Or load modules on demand:
const oj = await loadOuterJoyn();
await oj.load(['pay', 'banner']);
oj.banner.mount({ sessionToken, container: '#promo' });The differentiator: multi-currency split tender
The pay modal lets a shopper split one checkout across multiple loyalty
programs' currencies (airline miles + hotel points + a retailer currency +
card) — up to 10 legs, each its own currency. No other checkout SDK does this.
oj.pay.open() returns the per-leg redemption tokens your server confirms after
the charge succeeds.
API
loadOuterJoyn(options?) → Promise<OuterJoynSDK | null>
Injects the loader and resolves the window.OuterJoyn object. Idempotent —
repeated calls share one injection. Resolves null during server-side
rendering (no window), so you can guard if (oj) ….
| Option | Type | Description |
|--------|------|-------------|
| modules | string[] | Widget modules to load eagerly before resolving (e.g. ['pay','banner']). |
| version | string | Load from a pinned immutable build at /v1/<version>/… (enterprise change control). |
| cdnBase | string | Override the CDN origin. Default https://sdk.outerjoyn.com. |
| nonce | string | CSP nonce stamped on the injected loader <script>. |
oj.load(modules, options?) → Promise<void>
Lazy-injects one or more widget bundles. Known modules: pay, connect,
exchange, redeem, account, walletpass, banner, balance,
promotions, hub, elements.
oj.version / oj.buildTime
The running SDK build (date + git sha) and its build timestamp.
Content-Security-Policy
If your storefront sends a CSP header, allow the three OuterJoyn origins:
script-src 'self' https://sdk.outerjoyn.com;
frame-src https://sdk.outerjoyn.com;
connect-src 'self' https://api.outerjoyn.com;frame-src is required because the pay and connect/OTP modals render inside an
iframe on sdk.outerjoyn.com (the merchant page never touches the card/OTP
fields or the session token). See the retailer SDK-CSP guide.
License
MIT
