Success / Failure Handling

After checkout, your app learns the outcome through SDK events. Use them to unlock content, refresh navigation, and show errors.

Successful checkout

When a subscription checkout completes successfully, userChange fires with event: 'checkout'. The payload includes an updated user object; productAccess reflects the new subscription.

Update your UI from this event — for example show premium sections, adjust CTAs, or sync server-side state if you also verify tokens.

circle-info

userChange is for subscription and authentication flows only. For time-based billing, access is driven by paywall events (paywallShow / paywallHide) — see Time-based billing.

Errors

The error event is a global handler that fires for failures across all product types — subscriptions and time-based billing alike. If something goes wrong (payment declined, validation, network, or other failures), tiun emits error with code, message, and optionally details. Present a clear message to the user and avoid assuming checkout succeeded until you receive a success signal.

Example

tiun.on('userChange', (data) => {
  if (data.event === 'checkout' && data.user) {
    applyEntitlements(data.user.productAccess);
  }
});

tiun.on('error', (err) => {
  showCheckoutError(err.message);
});

For every event name, payload shape, and related notes, see the Eventsarrow-up-right page in the SDK documentation.

Last updated

Was this helpful?