Class InAppPurchasing
Inheritance
Namespace: EasyMobile
Assembly: cs.temp.dll.dll
Syntax
public class InAppPurchasing : MonoBehaviour
Properties
AmazonStoreExtensions
Gets the Amazon store extensions.
Declaration
public static IAmazonExtensions AmazonStoreExtensions { get; }
Property Value
Type | Description |
---|---|
IAmazonExtensions | The amazon store extensions. |
AppleStoreExtensions
Gets the Apple store extensions.
Declaration
public static IAppleExtensions AppleStoreExtensions { get; }
Property Value
Type | Description |
---|---|
IAppleExtensions | The apple store extensions. |
Builder
The underlying UnityIAP's ConfigurationBuilder used in this module.
Declaration
public static ConfigurationBuilder Builder { get; }
Property Value
Type | Description |
---|---|
ConfigurationBuilder | The builder. |
GooglePlayStoreExtensions
Gets the Google Play store extensions.
Declaration
public static IGooglePlayStoreExtensions GooglePlayStoreExtensions { get; }
Property Value
Type | Description |
---|---|
IGooglePlayStoreExtensions | The google play store extensions. |
Instance
Declaration
public static InAppPurchasing Instance { get; }
Property Value
Type | Description |
---|---|
InAppPurchasing |
SamsungAppsStoreExtensions
Gets the Samsung Apps store extensions.
Declaration
public static ISamsungAppsExtensions SamsungAppsStoreExtensions { get; }
Property Value
Type | Description |
---|---|
ISamsungAppsExtensions | The samsung apps store extensions. |
StoreController
The underlying UnityIAP's IStoreController used in this module.
Declaration
public static IStoreController StoreController { get; }
Property Value
Type | Description |
---|---|
IStoreController | The store controller. |
StoreExtensionProvider
The underlying UnityIAP's IExtensionProvider used in this module. Use it to access store-specific extended functionalities.
Declaration
public static IExtensionProvider StoreExtensionProvider { get; }
Property Value
Type | Description |
---|---|
IExtensionProvider | The store extension provider. |
Methods
ContinueApplePromotionalPurchases()
Continues the Apple promotional purchases. Call this inside the handler of the PromotionalPurchaseIntercepted event to continue the intercepted purchase.
Declaration
public static void ContinueApplePromotionalPurchases()
GetAllIAPProducts()
Gets all IAP products declared in module settings.
Declaration
public static IAPProduct[] GetAllIAPProducts()
Returns
Type | Description |
---|---|
IAPProduct[] | The all IAP products. |
GetAmazonUserId()
Gets the current Amazon user ID (for other Amazon services).
Only call this method after initialization has been done.
Returns null
if the current store is not Amazon store.
Declaration
public static string GetAmazonUserId()
Returns
Type | Description |
---|---|
System.String | The amazon user identifier. |
GetAndroidStore(IAPAndroidStore)
Converts to UnityIAP AndroidStore.
Declaration
public static AndroidStore GetAndroidStore(IAPAndroidStore store)
Parameters
Type | Name | Description |
---|---|---|
IAPAndroidStore | store | Store. |
Returns
Type | Description |
---|---|
AndroidStore | The android store. |
GetAppleAppReceipt()
Gets the Apple App receipt. This method only works if receipt validation is enabled.
Declaration
public static AppleReceipt GetAppleAppReceipt()
Returns
Type | Description |
---|---|
AppleReceipt | The Apple App receipt. |
GetAppleIAPReceipt(String)
Gets the parsed Apple InAppPurchase receipt for the specified product. This method only works if receipt validation is enabled.
Declaration
public static AppleInAppPurchaseReceipt GetAppleIAPReceipt(string productName)
Parameters
Type | Name | Description |
---|---|---|
System.String | productName | Product name. |
Returns
Type | Description |
---|---|
AppleInAppPurchaseReceipt | The Apple In App Purchase receipt. |
GetAppStore(IAPAndroidStore)
Converts to UnityIAP AppStore.
Declaration
public static AppStore GetAppStore(IAPAndroidStore store)
Parameters
Type | Name | Description |
---|---|---|
IAPAndroidStore | store | Store. |
Returns
Type | Description |
---|---|
AppStore | The app store. |
GetGooglePlayReceipt(String)
Gets the parsed Google Play receipt for the specified product. This method only works if receipt validation is enabled.
Declaration
public static GooglePlayReceipt GetGooglePlayReceipt(string productName)
Parameters
Type | Name | Description |
---|---|---|
System.String | productName | Product name. |
Returns
Type | Description |
---|---|
GooglePlayReceipt | The Google Play receipt. |
GetIAPProductById(String)
Gets the IAP product declared in module settings with the specified identifier.
Declaration
public static IAPProduct GetIAPProductById(string productId)
Parameters
Type | Name | Description |
---|---|---|
System.String | productId |
Returns
Type | Description |
---|---|
IAPProduct | The IAP product. |
GetIAPProductByName(String)
Gets the IAP product declared in module settings with the specified name.
Declaration
public static IAPProduct GetIAPProductByName(string productName)
Parameters
Type | Name | Description |
---|---|---|
System.String | productName | Product name. |
Returns
Type | Description |
---|---|
IAPProduct | The IAP product. |
GetProduct(String)
Gets the product registered with UnityIAP stores by its name. This method returns a Product object, which contains more information than an IAPProduct object, whose main purpose is for displaying.
Declaration
public static Product GetProduct(string productName)
Parameters
Type | Name | Description |
---|---|---|
System.String | productName | Product name. |
Returns
Type | Description |
---|---|
Product | The product. |
GetProductLocalizedData(String)
Gets the product localized data provided by the stores.
Declaration
public static ProductMetadata GetProductLocalizedData(string productName)
Parameters
Type | Name | Description |
---|---|---|
System.String | productName |
Returns
Type | Description |
---|---|
ProductMetadata | The product localized data. |
GetProductType(IAPProductType)
Gets the type of the product.
Declaration
public static ProductType GetProductType(IAPProductType pType)
Parameters
Type | Name | Description |
---|---|---|
IAPProductType | pType | P type. |
Returns
Type | Description |
---|---|
ProductType | The product type. |
GetPurchaseReceipt(String)
Gets the parsed purchase receipt for the product. This method only works if receipt validation is enabled.
Declaration
public static IPurchaseReceipt GetPurchaseReceipt(string productName)
Parameters
Type | Name | Description |
---|---|---|
System.String | productName | Product name. |
Returns
Type | Description |
---|---|
IPurchaseReceipt | The purchase receipt. |
GetStoreName(IAPStore)
Gets the name of the store.
Declaration
public static string GetStoreName(IAPStore store)
Parameters
Type | Name | Description |
---|---|---|
IAPStore | store | Store. |
Returns
Type | Description |
---|---|
System.String | The store name. |
GetSubscriptionInfo(String)
Gets the subscription info of the product using the SubscriptionManager class, which currently supports the Apple store and Google Play store.
Declaration
public static SubscriptionInfo GetSubscriptionInfo(string productName)
Parameters
Type | Name | Description |
---|---|---|
System.String | productName | Product name. |
Returns
Type | Description |
---|---|
SubscriptionInfo | The subscription info. |
InitializePurchasing()
Initializes the in-app purchasing service.
Declaration
public static void InitializePurchasing()
IsInitialized()
Determines whether UnityIAP is initialized. All further actions like purchasing or restoring can only be done if UnityIAP is initialized.
Declaration
public static bool IsInitialized()
Returns
Type | Description |
---|---|
System.Boolean |
|
IsProductOwned(String)
Determines whether the product with the specified name is owned. A product is consider owned if it has a receipt. If receipt validation is enabled, it is also required that this receipt passes the validation check. Note that this method is mostly useful with non-consumable products. Consumable products' receipts are not persisted between app restarts, therefore their ownership only pertains in the session they're purchased. In the case of subscription products, this method only checks if a product has been purchased before, it doesn't check if the subscription has been expired or canceled.
Declaration
public static bool IsProductOwned(string productName)
Parameters
Type | Name | Description |
---|---|---|
System.String | productName |
Returns
Type | Description |
---|---|
System.Boolean |
|
Purchase(IAPProduct)
Purchases the specified product.
Declaration
public static void Purchase(IAPProduct product)
Parameters
Type | Name | Description |
---|---|---|
IAPProduct | product | Product. |
Purchase(String)
Purchases the product with specified name.
Declaration
public static void Purchase(string productName)
Parameters
Type | Name | Description |
---|---|---|
System.String | productName | Product name. |
PurchaseWithId(String)
Purchases the product with specified ID.
Declaration
public static void PurchaseWithId(string productId)
Parameters
Type | Name | Description |
---|---|---|
System.String | productId | Product identifier. |
RefreshAppleAppReceipt(Action<String>, Action)
Fetches a new Apple App receipt from their servers. Note that this will prompt the user for their password.
Declaration
public static void RefreshAppleAppReceipt(Action<string> successCallback, Action errorCallback)
Parameters
Type | Name | Description |
---|---|---|
System.Action<System.String> | successCallback | Success callback. |
System.Action | errorCallback | Error callback. |
RestorePurchases()
Restore purchases previously made by this customer. Some platforms automatically restore purchases, like Google Play. Apple currently requires explicit purchase restoration for IAP, conditionally displaying a password prompt. This method only has effect on iOS and MacOSX apps.
Declaration
public static void RestorePurchases()
SetAppleStorePromotionOrder(List<IAPProduct>)
Sets the Apple store promotion order on the current device. Call this inside the handler of the InitializeSucceeded event to set the order for your promotional products on Apple App Store. On non-Apple platforms this method is a no-op.
Declaration
public static void SetAppleStorePromotionOrder(List<IAPProduct> products)
Parameters
Type | Name | Description |
---|---|---|
List<IAPProduct> | products | Products. |
SetAppleStorePromotionVisibility(String, Boolean)
Sets the Apple store promotion visibility for the specified product on the current device. Call this inside the handler of the InitializeSucceeded event to set the visibility for a promotional product on Apple App Store. On non-Apple platforms this method is a no-op.
Declaration
public static void SetAppleStorePromotionVisibility(string productName, bool visible)
Parameters
Type | Name | Description |
---|---|---|
System.String | productName | Product name. |
System.Boolean | visible | If set to |
SetSimulateAppleAskToBuy(Boolean)
Enables or disables the Apple's Ask-To-Buy simulation in the sandbox app store. Call this after the module has been initialized to toggle the simulation, regardless of the SimulateAppleAskToBuy setting.
Declaration
public static void SetSimulateAppleAskToBuy(bool shouldSimulate)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | shouldSimulate | If set to |
Events
InitializeFailed
Occurs when the module failed to initialize.
Declaration
public static event Action InitializeFailed
Event Type
Type | Description |
---|---|
System.Action |
InitializeSucceeded
Occurs when the module is initialized successfully and ready to work.
Declaration
public static event Action InitializeSucceeded
Event Type
Type | Description |
---|---|
System.Action |
PromotionalPurchaseIntercepted
[Apple store only] Occurs when a promotional purchase that comes directly
from the App Store is intercepted. This event only fires if the
InterceptApplePromotionalPurchases setting is true
.
On non-Apple platforms this event will never fire.
Declaration
public static event Action<IAPProduct> PromotionalPurchaseIntercepted
Event Type
Type | Description |
---|---|
System.Action<IAPProduct> |
PurchaseCompleted
Occurs when a purchase is completed.
Declaration
public static event Action<IAPProduct> PurchaseCompleted
Event Type
Type | Description |
---|---|
System.Action<IAPProduct> |
PurchaseDeferred
[Apple store only] Occurs as part of Apple's 'Ask to buy' functionality, when a purchase is requested by a minor and referred to a parent for approval. When the purchase is approved or rejected, the normal purchase events, PurchaseCompleted or PurchaseFailed, will fire. On non-Apple platforms this event will never fire.
Declaration
public static event Action<IAPProduct> PurchaseDeferred
Event Type
Type | Description |
---|---|
System.Action<IAPProduct> |
PurchaseFailed
Occurs when a purchase failed.
Declaration
public static event Action<IAPProduct> PurchaseFailed
Event Type
Type | Description |
---|---|
System.Action<IAPProduct> |
RestoreCompleted
[Apple store only] Occurs when the (non-consumable and subscription) purchases were restored successfully. On non-Apple platforms this event will never fire.
Declaration
public static event Action RestoreCompleted
Event Type
Type | Description |
---|---|
System.Action |
RestoreFailed
[Apple store only] Occurs when the purchase restoration failed. On non-Apple platforms this event will never fire.
Declaration
public static event Action RestoreFailed
Event Type
Type | Description |
---|---|
System.Action |