Minimal path from SDK install to paywall, entitlements, and payment.
Quickstart
Placeholders used everywhere in these docs:
| Placeholder | Meaning |
|---|---|
YOUR_API_URL | Platform API base URL |
YOUR_APP_CODE | Application code from admin |
YOUR_PUBLIC_KEY | Public SDK key rb_pub_… |
YOUR_ACCESS_TOKEN | End-user JWT from your auth provider |
1. Admin setup (once)
- Create application → note
YOUR_APP_CODE. - Add entitlements (example codes:
premium_feature,cloud_sync). - Create plans (including optional
free) and attach entitlements to paid plans. - Create paywall code
mainand attach plan prices. - Copy public key
YOUR_PUBLIC_KEY.
2. TypeScript
import { RaidBossPlatformClient } from "@raidboss/platform-sdk";
const platform = new RaidBossPlatformClient({
apiUrl: "YOUR_API_URL",
applicationCode: "YOUR_APP_CODE",
publicKey: "YOUR_PUBLIC_KEY",
getAccessToken: async () => YOUR_ACCESS_TOKEN,
});
await platform.registerUser({
platform: "web",
// optional — visible in admin Users
// display_name: "Ivan",
// avatar_url: "https://cdn.example.com/a.jpg",
// timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
});
// Required for admin “Devices active” / device list
await platform.registerDevice({
installation_id: "stable-uuid-on-device", // one UUID per install
platform: "web",
app_version: "1.0.0",
});
// After avatar change in your app:
// await platform.updateUserProfile({ avatar_url: "https://…" });
// Optional: trackEvent with the same installation_id + platform also heartbeats last_seen
await platform.trackEvent({
event: "app_opened",
platform: "web",
installation_id: "stable-uuid-on-device",
app_version: "1.0.0",
});
const { data: paywall } = await platform.getPaywall("main");
const canPremium = await platform.hasEntitlement("premium_feature");
3. Flutter
final platform = RaidBossPlatformClient(
apiUrl: 'YOUR_API_URL',
applicationCode: 'YOUR_APP_CODE',
publicKey: 'YOUR_PUBLIC_KEY',
getAccessToken: () async => YOUR_ACCESS_TOKEN,
);
await platform.registerUser(
platform: 'android',
// optional — shown in admin Users
// displayName: 'Ivan',
// avatarUrl: 'https://cdn.example.com/a.jpg',
// timezone: 'Europe/Moscow',
);
// Required for admin “Devices active” / device list
await platform.registerDevice(
installationId: installationId, // one UUID per install
platform: 'android',
appVersion: '1.0.0',
);
// After avatar change:
// await platform.updateUserProfile(avatarUrl: 'https://…');
// Optional: trackEvent with the same installationId + platform also heartbeats last_seen
await platform.trackEvent(
event: 'app_opened',
platform: 'android',
installationId: installationId,
appVersion: '1.0.0',
);
final paywall = await platform.getPaywall(paywallCode: 'main');
final canPremium = await platform.hasEntitlement('premium_feature');
4. Purchase (paid only)
const price = paywall.paywall_items?.[0]?.plan_prices;
if (price && !RaidBossPlatformClient.isFreePrice(price)) {
const { data } = await platform.createPayment({
plan_price_id: String(price.id),
return_url: "https://your.app/pay/return",
});
// open data.confirmation_url
}
Never call createPayment for free prices (is_free / works_offline / requires_purchase: false).
5. Feature gating rule
if feature is free-local → allow (even offline)
else if online → sync entitlements, update cache, check code
else → check cached entitlements + expires_at
Next: Entitlements · Users & profile · Payments · Offline