Class SubscriptionInfo
A container for a Product’s subscription-related information.
Namespace: UnityEngine.Purchasing
Syntax
public class SubscriptionInfo
Constructors
SubscriptionInfo(String)
Especially crucial values relating to subscription products. Note this is intended to be called internally.
Declaration
public SubscriptionInfo(string productId)
Parameters
Type | Name | Description |
---|---|---|
String | productId | This subscription's product identifier |
SubscriptionInfo(String, Boolean, DateTime, Boolean, Boolean, Boolean, String)
Especially crucial values relating to Google subscription products. Note this is intended to be called internally.
Declaration
public SubscriptionInfo(string skuDetails, bool isAutoRenewing, DateTime purchaseDate, bool isFreeTrial, bool hasIntroductoryPriceTrial, bool purchaseHistorySupported, string updateMetadata)
Parameters
Type | Name | Description |
---|---|---|
String | skuDetails | The raw JSON from |
Boolean | isAutoRenewing | Whether this subscription is expected to auto-renew |
DateTime | purchaseDate | A date this subscription was billed |
Boolean | isFreeTrial | Indicates whether this Product is a free trial |
Boolean | hasIntroductoryPriceTrial | Indicates whether this Product may be owned with an introductory price period. |
Boolean | purchaseHistorySupported | Unsupported |
String | updateMetadata | Unsupported. Mechanism previously propagated subscription upgrade information to new subscription. |
Exceptions
Type | Condition |
---|---|
InvalidProductTypeException | For non-subscription product types. |
SubscriptionInfo(AppleInAppPurchaseReceipt, String)
Unpack Apple receipt subscription data.
Declaration
public SubscriptionInfo(AppleInAppPurchaseReceipt r, string intro_json)
Parameters
Type | Name | Description |
---|---|---|
AppleInAppPurchaseReceipt | r | The Apple receipt from |
String | intro_json | From |
Exceptions
Type | Condition |
---|---|
InvalidProductTypeException | Error found involving an invalid product type. |
Methods
getCancelDate()
When this auto-renewable receipt was canceled. Note the store-specific behavior.
Declaration
public DateTime getCancelDate()
Returns
Type | Description |
---|---|
DateTime | For Apple store, the date when this receipt was canceled.
For other stores this will be |
getExpireDate()
When this auto-renewable receipt expires.
Declaration
public DateTime getExpireDate()
Returns
Type | Description |
---|---|
DateTime | An absolute date when this receipt will expire. |
getFreeTrialPeriod()
The period duration of the free trial for this subscription, if enabled. Note the store-specific behavior.
Declaration
public TimeSpan getFreeTrialPeriod()
Returns
Type | Description |
---|---|
TimeSpan | For Google Play store if the product is configured with a free trial, this will be the period duration.
For Apple store this will be |
getFreeTrialPeriodString()
The string representation of the period in ISO8601 format this subscription is free for. Note the store-specific behavior.
Declaration
public string getFreeTrialPeriodString()
Returns
Type | Description |
---|---|
String | For Google Play store on configured subscription this will be the period which the can own this product for free, unless
the user is ineligible for this free trial.
For Apple store this will be |
getIntroductoryPrice()
For subscriptions with an introductory price, get this price. Note the store-specific behavior.
Declaration
public string getIntroductoryPrice()
Returns
Type | Description |
---|---|
String | For subscriptions with a introductory price, a localized price string.
For Google store the price may not include the currency symbol (e.g. $) and the currency code is available in |
See Also
getIntroductoryPricePeriod()
Indicates how much time remains for the introductory price period. Note the store-specific behavior.
Declaration
public TimeSpan getIntroductoryPricePeriod()
Returns
Type | Description |
---|---|
TimeSpan | Duration remaining in this product's introductory price period.
Subscription products with no introductory price period return |
getIntroductoryPricePeriodCycles()
Indicates the number of introductory price billing periods that can be applied to this subscription Product. Note the store-specific behavior.
Declaration
public long getIntroductoryPricePeriodCycles()
Returns
Type | Description |
---|---|
Int64 | Products in the Apple store return |
getProductId()
Store specific product identifier.
Declaration
public string getProductId()
Returns
Type | Description |
---|---|
String | The product identifier from the store receipt. |
getPurchaseDate()
A date this subscription was billed. Note the store-specific behavior.
Declaration
public DateTime getPurchaseDate()
Returns
Type | Description |
---|---|
DateTime | For Apple, the purchase date is the date when the subscription was either purchased or renewed. For Google, the purchase date is the date when the subscription was originally purchased. |
getRemainingTime()
Indicates how much time remains until the next billing date. Note the store-specific behavior. Note also that the receipt may update and change this subscription expiration status if the user sends their iOS app to the background and then returns it to the foreground.
Declaration
public TimeSpan getRemainingTime()
Returns
Type | Description |
---|---|
TimeSpan | A time duration from now until subscription billing occurs.
Google subscriptions queried on devices with version lower than 6 of the Android in-app billing API return |
See Also
getSkuDetails()
The raw JSON SkuDetails from the underlying Google API. Note the store-specific behavior. Note this is not supported.
Declaration
public string getSkuDetails()
Returns
Type | Description |
---|---|
String | For Google store the |
getSubscriptionInfoJsonString()
A JSON including a collection of data involving free-trial and introductory prices. Note the store-specific behavior. Used internally for subscription updating on Google store.
Declaration
public string getSubscriptionInfoJsonString()
Returns
Type | Description |
---|---|
String | A JSON with keys: |
See Also
getSubscriptionPeriod()
The duration of this subscription. Note the store-specific behavior.
Declaration
public TimeSpan getSubscriptionPeriod()
Returns
Type | Description |
---|---|
TimeSpan | A duration this subscription is valid for.
|
isAutoRenewing()
Indicates whether this Product is expected to auto-renew. The product must be auto-renewable, not canceled, and not expired.
Declaration
public Result isAutoRenewing()
Returns
Type | Description |
---|---|
Result |
|
isCancelled()
Indicates whether this Product has been cancelled. A cancelled subscription means the Product is currently subscribed, and will not renew on the next billing date.
Declaration
public Result isCancelled()
Returns
Type | Description |
---|---|
Result |
|
isExpired()
Indicates whether this auto-renewable subscription Product is currently unsubscribed or not. Note the store-specific behavior. Note also that the receipt may update and change this subscription expiration status if the user sends their iOS app to the background and then returns it to the foreground. It is therefore recommended to remember subscription expiration state at app-launch, and ignore the fact that a subscription may expire later during this app launch runtime session.
Declaration
public Result isExpired()
Returns
Type | Description |
---|---|
Result |
|
See Also
isFreeTrial()
Indicates whether this Product is a free trial. Note the store-specific behavior.
Declaration
public Result isFreeTrial()
Returns
Type | Description |
---|---|
Result |
|
isIntroductoryPricePeriod()
Indicates whether this Product is currently owned within an introductory price period. Note the store-specific behavior.
Declaration
public Result isIntroductoryPricePeriod()
Returns
Type | Description |
---|---|
Result |
|
isSubscribed()
Indicates whether this auto-renewable subscription Product is currently subscribed or not. Note the store-specific behavior. Note also that the receipt may update and change this subscription expiration status if the user sends their iOS app to the background and then returns it to the foreground. It is therefore recommended to remember subscription expiration state at app-launch, and ignore the fact that a subscription may expire later during this app launch runtime session.
Declaration
public Result isSubscribed()
Returns
Type | Description |
---|---|
Result |
|