Minimal path from SDK install to paywall, entitlements, and payment.

Quickstart

Placeholders used everywhere in these docs:

PlaceholderMeaning
YOUR_API_URLPlatform API base URL
YOUR_APP_CODEApplication code from admin
YOUR_PUBLIC_KEYPublic SDK key rb_pub_…
YOUR_ACCESS_TOKENEnd-user JWT from your auth provider

1. Admin setup (once)

  1. Create application → note YOUR_APP_CODE.
  2. Add entitlements (example codes: premium_feature, cloud_sync).
  3. Create plans (including optional free) and attach entitlements to paid plans.
  4. Create paywall code main and attach plan prices.
  5. 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" });
await platform.registerDevice({
  installation_id: "stable-uuid-on-device",
  platform: "web",
  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');
await platform.registerDevice(
  installationId: installationId,
  platform: 'android',
  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 · Payments · Offline