SDKs

Official clients for Flutter, Swift and Kotlin — thin wrappers around the REST API. Flutter is the most complete (one-line setup, native paywall, account screen); Swift ships a SwiftUI paywall view; Kotlin ships the client and models (bring your own UI). Current release: v0.9.0.

Building a web app? There's no SDK to install — you call the REST API and redirect the browser to the hosted checkout. See the Web apps guide.
Since v0.4.0 the SDK sends your API key on public endpoints too, so each app build is pinned to its key's environment: a pk_live_ app keeps serving live plans and paywalls even while the dashboard is switched to test mode. Older SDK versions follow the dashboard toggle instead.

Before you start#

FieldTypeDescription
1. Publishable keySettingsCopy your pk_test_… key from Dashboard → Settings → API keys. It's the only key that goes in an app — never ship the sk_ secret key.
2. Redirect URLsSettingsSet a default Success and Cancel URL (a web page or your app's deep link, e.g. myapp://paylo/success). Required: the SDKs don't pass their own, so checkouts fail with "success_url and cancel_url are required" until these are set.
3. PlansPaymentsCreate your plans (Dashboard → Payments) in test mode. Note the slugs — pro_monthly, pro_yearly… — and the entitlements each one grants.
4. A paywallPaywallsDesign one and Publish it — with no targeting rule, non-subscribers get the published paywall.
5. Test cardcheckout4242 4242 4242 4242, any future date, any CVC. Test mode never moves real money.

The checkout opens in the device browser. When the customer comes back, read their access again (Paylo.hasEntitlement / customerStatus) — the subscription becomes active as soon as Stripe confirms the payment, usually within a few seconds.

Flutter#

pubspec.yaml
dependencies:
  paylo:
    git:
      url: https://github.com/ssid131133-star/paylo-flutter.git
      ref: v0.9.0   # pin a release

# Already installed? flutter pub upgrade paylo
The whole integration
import 'package:paylo/paylo.dart';
import 'package:paylo/paylo_paywall.dart';

// 1 — main(): one line. Anonymous customer id, plans and
//     paywall are handled automatically from the API key.
await Paylo.configure('pk_test_...');

// 2 — show the paywall wherever you want (targeting, A/B,
//     trials, offers: all decided server-side)
await PayloPaywall.showIfNeeded(context, placement: 'onboarding');

// 3 — gate your features
if (await Paylo.hasEntitlement('pro')) { /* unlock */ }
// or: if (await Paylo.isSubscribed()) { ... }

// That's it. Optionally:

// At login — merges the anonymous history into the user id
// (the app's pk_ key can only merge the SDK's own anon_ id):
await Paylo.identify(user.id);
// At logout:
await Paylo.logOut();

// The complete "my subscription" page — ONE widget.
// Active sub → plan, price, renewal/trial date, Manage button
// (Stripe portal) + one-tap plan switching (upgrade/downgrade,
// proration and confirmation handled for you).
// Lifetime purchase → no manage button. Not subscribed → your paywall.
Scaffold(body: PayloAccountView())

// Plans preloaded at startup (for your own pricing UI):
final plans = Paylo.plans;
The explicit API (Paylo(apiKey), customerId: everywhere) still works — the static layer is sugar on top, nothing was removed.

Swift (iOS / macOS)#

Usage
import Paylo

let paylo = Paylo(apiKey: "pk_test_...")

// Remotely configured paywall — server-side targeting
let resolved = try await paylo.resolvePaywall(
    developerId: devId, customerId: user.id,
    placement: "onboarding")

if let paywall = resolved.paywall {
    PayloPaywallView(paywall: paywall) { plan in
        // Report the funnel yourself (feeds analytics + frequency caps)
        await paylo.logPaywallEvent(developerId: devId,
            paywallId: paywall.id, customerId: user.id,
            type: "checkout_opened", ruleId: resolved.ruleId)
        try await paylo.subscribe(
            planId: plan.slug, customerId: user.id,
            offerToken: resolved.offer?.token) // win-back discount, if any
    } onClose: { dismiss() }
    .task {
        await paylo.logPaywallEvent(developerId: devId,
            paywallId: paywall.id, customerId: user.id,
            type: "impression", ruleId: resolved.ruleId)
    }
}

// Subscriptions & gating
let sub = try await paylo.subscribe(
    planId: "pro_monthly", customerId: user.id)
let status = try await paylo.customerStatus(user.id)
if status.hasActiveSubscription { /* unlock */ }

// Portal
if let active = status.activeSubscription {
    try await paylo.openPortal(active.id,
        returnUrl: "https://yourapp.com/account")
}

The Swift package isn't publicly distributed yet (no Swift Package Manager release): get it from the Paylo team and add it as a local package — Flutter is the only SDK installable from a public repo today. devId is your Developer ID, shown in Dashboard → Settings → API keys. Unlike Flutter, the SwiftUI view doesn't report events on its own: log impression, dismiss and checkout_opened as above, and pass resolved.offer?.token to subscribe.

Kotlin (Android)#

Not publicly distributed yet (no Maven release) — get the module from the Paylo team and include it as a source module. devId is your Developer ID (Dashboard → Settings → API keys). The Kotlin SDK is the client and models only: render the paywall config yourself (e.g. in Compose), open checkout URLs in a Custom Tab, log the paywall events, and pass resolved.offer?.token as offerToken when subscribing. Building with Flutter instead gets you all of that out of the box.

Usage
import dev.paylo.Paylo

val paylo = Paylo("pk_test_...")

// Remotely configured paywall — server-side targeting
val resolved = paylo.resolvePaywall(
    developerId = devId, customerId = user.id,
    placement = "onboarding",
    locale = Locale.getDefault().toLanguageTag())

resolved.paywall?.let { paywall ->
    val config = paywall.config.localized(
        Locale.getDefault().toLanguageTag())
    // Render config + paywall.plans in Compose, then:
    paylo.logPaywallEvent(devId, paywall.id, user.id,
        "impression", resolved.ruleId)
}

// Subscriptions & gating
val sub = paylo.subscribe(
    planId = "pro_monthly", customerId = user.id)
// open sub.url in a Chrome Custom Tab
val status = paylo.customerStatus(user.id)
if (status.hasActiveSubscription) { /* unlock */ }

// Portal
status.activeSubscription?.let {
    val url = paylo.openPortal(it.id,
        returnUrl = "https://yourapp.com/account")
}

Any other language#

The SDKs are thin — everything is plain REST with bearer auth. See the API reference.

Pin your installs to a release tag and check the changelog before upgrading — git dependencies without a ref freeze whatever commit resolved first.