Requirements
- Playtolia SDK (with Authentication and Billing enabled)
Subscriptions API
Playtolia Subscriptions API allows you to manage recurring subscriptions, premium memberships, and time-based services. The API handles subscription lifecycle events, renewal tracking, and provides real-time subscription status updates. Use PlaytoliaSubscriptions to check subscription validity and manage premium features based on subscription state.Getting player subscriptions
Import the PlaytoliaSDK.Runtime to your script by adding the using directiveSubscriptionsController.cs
SubscriptionsController.cs
Subscriptions are automatically refreshed when players make purchases or when subscription status changes. If you need to refresh subscriptions manually, use PlaytoliaSubscriptions.Refresh() function.
Getting specific subscriptions
You can retrieve specific subscriptions using different identifiersSubscriptionsController.cs
Understanding PlayerSubscription structure
Each PlayerSubscription contains the following information:- Id: Unique identifier for the subscription
- AutoRenew: Whether the subscription will automatically renew
- CreatedAt: When the subscription was created
- ExpiresAt: When the subscription expires
- StartsAt: When the subscription becomes active
- Status: Current subscription status (subscribed, active, expired, cancelled)
- StoreItem: The store item associated with this subscription
- IsActive: Property indicating if subscription is “active”
- IsExpired: Property indicating if subscription has expired
SubscriptionInfo.cs
Checking for premium subscriptions
Here’s how to check if a player has an active premium subscription:PremiumManager.cs
Listen to subscription changes
Subscriptions can change during runtime due to:- Purchases: New subscriptions from successful purchases
- Expiration: Subscriptions expiring
- Renewals: Automatic subscription renewals
- Cancellations: Players cancelling subscriptions
- Manual refresh via PlaytoliaSubscriptions.Refresh()
SubscriptionTracker.cs
Subscriptions vs Entitlements
Important: PlaytoliaSubscriptions is used specifically for managing recurring subscription services. For non-consumable purchases (permanent unlocks, one-time premium features), use PlaytoliaEntitlements instead. Entitlements handle permanent or time-limited access granted through purchases, while subscriptions handle recurring payment services.Need to implement purchases?
Use the Store API to handle subscription purchases that automatically create subscription records for your players.In-game Stores
Learn how to setup subscription purchases using PlaytoliaStore