docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class SubscriptionInfo

    A container for a Product's subscription-related information.

    Inheritance
    object
    SubscriptionInfo
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.Purchasing
    Assembly: Unity.Purchasing.dll
    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

    See Also
    GetSubscriptionInfo()

    SubscriptionInfo(string, bool, DateTime, bool, bool, bool, 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 SkuDetail.getOriginalJson

    bool isAutoRenewing

    Whether this subscription is expected to auto-renew

    DateTime purchaseDate

    A date this subscription was billed

    bool isFreeTrial

    Indicates whether this Product is a free trial

    bool hasIntroductoryPriceTrial

    Indicates whether this Product may be owned with an introductory price period.

    bool purchaseHistorySupported

    Unsupported

    string updateMetadata

    Unsupported. Mechanism previously propagated subscription upgrade information to new subscription.

    Exceptions
    Type Condition
    InvalidProductTypeException

    For non-subscription product types.

    See Also
    GetSubscriptionInfo()

    SubscriptionInfo(AppleInAppPurchaseReceipt, string)

    Unpack Apple receipt subscription data.

    Declaration
    public SubscriptionInfo(AppleInAppPurchaseReceipt r, string introJson)
    Parameters
    Type Name Description
    AppleInAppPurchaseReceipt r

    The Apple receipt from CrossPlatformValidator

    string introJson

    From IAppleExtensions.GetIntroductoryPriceDictionary.GetIntroductoryPriceDictionary. Keys: introductoryPriceLocale, introductoryPrice, introductoryPriceNumberOfPeriods, numberOfUnits, unit, which can be fetched from Apple's remote service.

    Exceptions
    Type Condition
    InvalidProductTypeException

    Error found involving an invalid product type.

    See Also
    CrossPlatformValidator

    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 null.

    See Also
    GetSubscriptionInfo()

    GetExpireDate()

    When this auto-renewable receipt expires.

    Declaration
    public DateTime GetExpireDate()
    Returns
    Type Description
    DateTime

    An absolute date when this receipt will expire.

    See Also
    GetSubscriptionInfo()

    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 null .

    See Also
    GetSubscriptionInfo()

    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 null .

    See Also
    GetSubscriptionInfo()

    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 ProductMetadata.isoCurrencyCode.isoCurrencyCode. For all other product configurations, the string "not available".

    See Also
    isoCurrencyCode

    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 TimeSpan.Zero.Zero. Products in the Apple store return TimeSpan.Zero.Zero if the application does not support iOS version 11.2+, macOS 10.13.2+, or tvOS 11.2+. TimeSpan.Zero.Zero returned also for products which do not have an introductory period configured.

    See Also
    GetSubscriptionInfo()

    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
    long

    Products in the Apple store return 0 if the application does not support iOS version 11.2+, macOS 10.13.2+, or tvOS 11.2+. 0 returned also for products which do not have an introductory period configured.

    See Also
    GetSubscriptionInfo()

    GetProductId()

    Store specific product identifier.

    Declaration
    public string GetProductId()
    Returns
    Type Description
    string

    The product identifier from the store receipt.

    See Also
    GetSubscriptionInfo()

    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.

    See Also
    GetSubscriptionInfo()

    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 TimeSpan.MaxValue.MaxValue.

    See Also
    UtcNow

    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 SkuDetails#getOriginalJson results. For Apple this returns null.

    See Also
    GetSubscriptionInfo()

    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: productId, is_free_trial, is_introductory_price_period, remaining_time_in_seconds.

    See Also
    GetSubscriptionInfo()

    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. TimeSpan.Zero.Zero returned for Apple products.

    See Also
    GetSubscriptionInfo()

    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

    Result.True.True The store receipt's indicates this subscription is auto-renewing. Result.False.False The store receipt's indicates this subscription is not auto-renewing. Non-renewable subscriptions in the Apple store return a Result.Unsupported.Unsupported value.

    See Also
    GetSubscriptionInfo()

    IsCancelled()

    Indicates whether this Product has been cancelled by Apple customer support or by upgrading an auto-renewable subscription plan.

    Declaration
    public Result IsCancelled()
    Returns
    Type Description
    Result

    Result.True.True Cancellation status if the store receipt's indicates this subscription is cancelled. Result.False.False otherwise. Non-renewable subscriptions in the Apple store return a Result.Unsupported.Unsupported value.

    See Also
    GetSubscriptionInfo()

    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

    Result.True.True Subscription status if the store receipt's expiration date is before the device's current time. Result.False.False otherwise. Non-renewable subscriptions in the Apple store return a Result.Unsupported.Unsupported value.

    See Also
    IsSubscribed()
    UtcNow

    IsFreeTrial()

    Indicates whether this Product is a free trial. Note the store-specific behavior.

    Declaration
    public Result IsFreeTrial()
    Returns
    Type Description
    Result

    Result.True.True This subscription is a free trial according to the store receipt. Result.False.False This subscription is not a free trial according to the store receipt. Non-renewable subscriptions in the Apple store and Google subscriptions queried on devices with version lower than 6 of the Android in-app billing API return a Result.Unsupported.Unsupported value.

    See Also
    GetSubscriptionInfo()

    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

    Result.True.True The store receipt's indicates this subscription is within its introductory price period. Result.False.False The store receipt's indicates this subscription is not within its introductory price period. Result.False.False If the product is not configured to have an introductory period. Non-renewable subscriptions in the Apple store return a Result.Unsupported.Unsupported value. Google subscriptions queried on devices with version lower than 6 of the Android in-app billing API return a Result.Unsupported.Unsupported value.

    See Also
    GetSubscriptionInfo()

    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

    Result.True.True Subscription status if the store receipt's expiration date is after the device's current time. Result.False.False otherwise. Non-renewable subscriptions in the Apple store return a Result.Unsupported.Unsupported value.

    See Also
    IsExpired()
    UtcNow

    getCancelDate()

    When this auto-renewable receipt was canceled. Note the store-specific behavior.

    Declaration
    [Obsolete("getCancelDate is deprecated. Please use GetCancelDate instead.", false)]
    public DateTime getCancelDate()
    Returns
    Type Description
    DateTime

    For Apple store, the date when this receipt was canceled. For other stores this will be null.

    See Also
    GetSubscriptionInfo()

    getExpireDate()

    When this auto-renewable receipt expires.

    Declaration
    [Obsolete("getExpireDate is deprecated. Please use GetExpireDate instead.", false)]
    public DateTime getExpireDate()
    Returns
    Type Description
    DateTime

    An absolute date when this receipt will expire.

    See Also
    GetSubscriptionInfo()

    getFreeTrialPeriod()

    The period duration of the free trial for this subscription, if enabled. Note the store-specific behavior.

    Declaration
    [Obsolete("getFreeTrialPeriod is deprecated. Please use GetFreeTrialPeriod instead.", false)]
    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 null .

    See Also
    GetSubscriptionInfo()

    getFreeTrialPeriodString()

    The string representation of the period in ISO8601 format this subscription is free for. Note the store-specific behavior.

    Declaration
    [Obsolete("getFreeTrialPeriodString is deprecated. Please use GetFreeTrialPeriodString instead.", false)]
    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 null .

    See Also
    GetSubscriptionInfo()

    getIntroductoryPrice()

    For subscriptions with an introductory price, get this price. Note the store-specific behavior.

    Declaration
    [Obsolete("getIntroductoryPrice is deprecated. Please use GetIntroductoryPrice instead.", false)]
    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 ProductMetadata.isoCurrencyCode.isoCurrencyCode. For all other product configurations, the string "not available".

    See Also
    isoCurrencyCode

    getIntroductoryPricePeriod()

    Indicates how much time remains for the introductory price period. Note the store-specific behavior.

    Declaration
    [Obsolete("getIntroductoryPricePeriod is deprecated. Please use GetIntroductoryPricePeriod instead.", false)]
    public TimeSpan getIntroductoryPricePeriod()
    Returns
    Type Description
    TimeSpan

    Duration remaining in this product's introductory price period. Subscription products with no introductory price period return TimeSpan.Zero.Zero. Products in the Apple store return TimeSpan.Zero.Zero if the application does not support iOS version 11.2+, macOS 10.13.2+, or tvOS 11.2+. TimeSpan.Zero.Zero returned also for products which do not have an introductory period configured.

    See Also
    GetSubscriptionInfo()

    getIntroductoryPricePeriodCycles()

    Indicates the number of introductory price billing periods that can be applied to this subscription Product. Note the store-specific behavior.

    Declaration
    [Obsolete("getIntroductoryPricePeriodCycles is deprecated. Please use GetIntroductoryPricePeriodCycles instead.", false)]
    public long getIntroductoryPricePeriodCycles()
    Returns
    Type Description
    long

    Products in the Apple store return 0 if the application does not support iOS version 11.2+, macOS 10.13.2+, or tvOS 11.2+. 0 returned also for products which do not have an introductory period configured.

    See Also
    GetSubscriptionInfo()

    getProductId()

    Store specific product identifier.

    Declaration
    [Obsolete("getProductId is deprecated. Please use GetProductId instead.", false)]
    public string getProductId()
    Returns
    Type Description
    string

    The product identifier from the store receipt.

    See Also
    GetSubscriptionInfo()

    getPurchaseDate()

    A date this subscription was billed. Note the store-specific behavior.

    Declaration
    [Obsolete("getPurchaseDate is deprecated. Please use GetPurchaseDate instead.", false)]
    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.

    See Also
    GetSubscriptionInfo()

    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
    [Obsolete("getRemainingTime is deprecated. Please use GetRemainingTime instead.", false)]
    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 TimeSpan.MaxValue.MaxValue.

    See Also
    UtcNow

    getSkuDetails()

    The raw JSON SkuDetails from the underlying Google API. Note the store-specific behavior. Note this is not supported.

    Declaration
    [Obsolete("getSkuDetails is deprecated. Please use GetSkuDetails instead.", false)]
    public string getSkuDetails()
    Returns
    Type Description
    string

    For Google store the SkuDetails#getOriginalJson results. For Apple this returns null.

    See Also
    GetSubscriptionInfo()

    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
    [Obsolete("getSubscriptionInfoJsonString is deprecated. Please use GetSubscriptionInfoJsonString instead.", false)]
    public string getSubscriptionInfoJsonString()
    Returns
    Type Description
    string

    A JSON with keys: productId, is_free_trial, is_introductory_price_period, remaining_time_in_seconds.

    See Also
    GetSubscriptionInfo()

    getSubscriptionPeriod()

    The duration of this subscription. Note the store-specific behavior.

    Declaration
    [Obsolete("getSubscriptionPeriod is deprecated. Please use GetSubscriptionPeriod instead.", false)]
    public TimeSpan getSubscriptionPeriod()
    Returns
    Type Description
    TimeSpan

    A duration this subscription is valid for. TimeSpan.Zero.Zero returned for Apple products.

    See Also
    GetSubscriptionInfo()

    isAutoRenewing()

    Indicates whether this Product is expected to auto-renew. The product must be auto-renewable, not canceled, and not expired.

    Declaration
    [Obsolete("isAutoRenewing is deprecated. Please use IsAutoRenewing instead.", false)]
    public Result isAutoRenewing()
    Returns
    Type Description
    Result

    Result.True.True The store receipt's indicates this subscription is auto-renewing. Result.False.False The store receipt's indicates this subscription is not auto-renewing. Non-renewable subscriptions in the Apple store return a Result.Unsupported.Unsupported value.

    See Also
    GetSubscriptionInfo()

    isCancelled()

    Indicates whether this Product has been cancelled by Apple customer support or by upgrading an auto-renewable subscription plan.

    Declaration
    [Obsolete("isCancelled is deprecated. Please use IsCancelled instead.", false)]
    public Result isCancelled()
    Returns
    Type Description
    Result

    Result.True.True Cancellation status if the store receipt's indicates this subscription is cancelled. Result.False.False otherwise. Non-renewable subscriptions in the Apple store return a Result.Unsupported.Unsupported value.

    See Also
    GetSubscriptionInfo()

    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
    [Obsolete("isExpired is deprecated. Please use IsExpired instead.", false)]
    public Result isExpired()
    Returns
    Type Description
    Result

    Result.True.True Subscription status if the store receipt's expiration date is before the device's current time. Result.False.False otherwise. Non-renewable subscriptions in the Apple store return a Result.Unsupported.Unsupported value.

    See Also
    IsSubscribed()
    UtcNow

    isFreeTrial()

    Indicates whether this Product is a free trial. Note the store-specific behavior.

    Declaration
    [Obsolete("isFreeTrial is deprecated. Please use IsFreeTrial instead.", false)]
    public Result isFreeTrial()
    Returns
    Type Description
    Result

    Result.True.True This subscription is a free trial according to the store receipt. Result.False.False This subscription is not a free trial according to the store receipt. Non-renewable subscriptions in the Apple store and Google subscriptions queried on devices with version lower than 6 of the Android in-app billing API return a Result.Unsupported.Unsupported value.

    See Also
    GetSubscriptionInfo()

    isIntroductoryPricePeriod()

    Indicates whether this Product is currently owned within an introductory price period. Note the store-specific behavior.

    Declaration
    [Obsolete("isIntroductoryPricePeriod is deprecated. Please use IsIntroductoryPricePeriod instead.", false)]
    public Result isIntroductoryPricePeriod()
    Returns
    Type Description
    Result

    Result.True.True The store receipt's indicates this subscription is within its introductory price period. Result.False.False The store receipt's indicates this subscription is not within its introductory price period. Result.False.False If the product is not configured to have an introductory period. Non-renewable subscriptions in the Apple store return a Result.Unsupported.Unsupported value. Google subscriptions queried on devices with version lower than 6 of the Android in-app billing API return a Result.Unsupported.Unsupported value.

    See Also
    GetSubscriptionInfo()

    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
    [Obsolete("isSubscribed is deprecated. Please use IsSubscribed instead.", false)]
    public Result isSubscribed()
    Returns
    Type Description
    Result

    Result.True.True Subscription status if the store receipt's expiration date is after the device's current time. Result.False.False otherwise. Non-renewable subscriptions in the Apple store return a Result.Unsupported.Unsupported value.

    See Also
    IsExpired()
    UtcNow

    See Also

    GetSubscriptionInfo()
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)