docs.unity3d.com
    Show / Hide Table of Contents

    Class SubscriptionInfo

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

    Inheritance
    Object
    SubscriptionInfo
    Inherited Members
    Object.ToString()
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    Object.MemberwiseClone()
    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 SkuDetail.getOriginalJson

    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 CrossPlatformValidator

    String intro_json

    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.

    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.

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

    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 .

    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.

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

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

    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
    UpdateSubscription(Product, Product, String, Action<Product, String>, Action<String, String>)

    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.

    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.

    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

    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.

    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.

    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.

    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

    See Also

    getSubscriptionInfo()
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023