@outerjoyn/js
v1.0.0
Published
OuterJoyn SDK loader and TypeScript definitions
Maintainers
Readme
@outerjoyn/js
The OuterJoyn SDK loader for JavaScript applications. Follows the same pattern as @stripe/stripe-js.
Installation
npm install @outerjoyn/jsUsage
Default (eager loading)
The SDK script starts loading immediately when you import from @outerjoyn/js:
import { loadOuterJoyn } from '@outerjoyn/js';
const oj = await loadOuterJoyn();
if (oj) {
await oj.init({ sessionToken: 'ojsdk_live_...' });
oj.pay.open({
orderTotal: 4999,
container: '#pay-widget',
onPointsChanged: (state) => {
updateCheckoutTotal(state.remainingOrderCents);
},
});
}Deferred loading
Use the /pure import to control when the SDK script is injected:
import { loadOuterJoyn } from '@outerjoyn/js/pure';
// SDK script is NOT loaded until this line executes
const oj = await loadOuterJoyn();Connect (account linking)
oj.connect.open({
sessionToken: 'ojsdk_live_...',
onSuccess: (result) => {
console.log('Linked!', result.member_partner_link_id);
},
onClose: () => console.log('Closed'),
});Exchange (points transfer)
oj.exchange.open({
sessionToken: 'ojsdk_live_...',
sourceBrandId: 123,
targetBrandId: 456,
onSuccess: (result) => {
console.log('Exchanged', result.sourcePoints, '→', result.targetPoints);
},
});Redeem (reward catalog)
oj.redeem.open({
sessionToken: 'ojsdk_live_...',
onSuccess: (result) => {
console.log('Redeemed:', result.rewardName, 'Code:', result.voucherCode);
},
});Wallet Pass
oj.walletPass.open({
sessionToken: 'ojsdk_live_...',
container: '#wallet-section',
onSuccess: (result) => {
console.log('Pass added to', result.addedPlatform);
},
});Promotions
oj.promotions.configure({ apiBaseUrl: 'https://api.outerjoyn.com' });
oj.promotions.render({
arrayId: 'promo_abc123',
container: '#promotions',
onReady: (data) => console.log('Loaded', data.promotions.length, 'promotions'),
});TypeScript
Full type definitions are included. You get autocomplete for all SDK modules, events, and configuration options.
import type { OuterJoynSDK, PayOptions, ConnectResult } from '@outerjoyn/js';SSR
Both imports safely return null in server-side environments (no window/document).
