/// <summary> /// This will be called when Unity IAP has finished initialising. /// </summary> public void OnInitialized(IStoreController controller, IExtensionProvider extensions) { m_Controller = controller; m_AppleExtensions = extensions.GetExtension<IAppleExtensions> (); m_SamsungExtensions = extensions.GetExtension<ISamsungAppsExtensions> (); m_MoolahExtensions = extensions.GetExtension<IMoolahExtension> (); InitUI(controller.products.all); // On Apple platforms we need to handle deferred purchases caused by Apple's Ask to Buy feature. // On non-Apple platforms this will have no effect; OnDeferred will never be called. m_AppleExtensions.RegisterPurchaseDeferredListener(OnDeferred); Debug.Log("Available items:"); foreach (var item in controller.products.all) { if (item.availableToPurchase) { Debug.Log(string.Join(" - ", new[] { item.metadata.localizedTitle, item.metadata.localizedDescription, item.metadata.isoCurrencyCode, item.metadata.localizedPrice.ToString(), item.metadata.localizedPriceString, item.transactionID, item.receipt })); } } // Prepare model for purchasing if (m_Controller.products.all.Length > 0) { m_SelectedItemIndex = 0; } // Populate the product menu now that we have Products for (int t = 0; t < m_Controller.products.all.Length; t++) { var item = m_Controller.products.all[t]; var description = string.Format("{0} - {1}", item.metadata.localizedTitle, item.metadata.localizedPriceString); // NOTE: my options list is created in InitUI GetDropdown().options[t] = new Dropdown.OptionData(description); } // Ensure I render the selected list element GetDropdown().RefreshShownValue(); // Now that I have real products, begin showing product purchase history UpdateHistoryUI(); }
private Selectable m_InteractableSelectable; // Optimization used for UI state management /// <summary> /// This will be called when Unity IAP has finished initialising. /// </summary> public void OnInitialized(IStoreController controller, IExtensionProvider extensions) { m_Controller = controller; m_AppleExtensions = extensions.GetExtension<IAppleExtensions> (); InitUI(controller.products.all); Debug.Log("Available items:"); foreach (var item in controller.products.all) { if (item.availableToPurchase) { Debug.Log(string.Join(" - ", new[] { item.metadata.localizedTitle, item.metadata.localizedDescription, item.metadata.isoCurrencyCode, item.metadata.localizedPrice.ToString(), item.metadata.localizedPriceString })); } } // Prepare model for purchasing if (m_Controller.products.all.Length > 0) { m_SelectedItemIndex = 0; } // Populate the product menu now that we have Products for (int t = 0; t < m_Controller.products.all.Length; t++) { var item = m_Controller.products.all[t]; var description = string.Format("{0} - {1}", item.metadata.localizedTitle, item.metadata.localizedPriceString); // NOTE: my options list is created in InitUI GetDropdown().options[t] = new Dropdown.OptionData(description); } // Ensure I render the selected list element GetDropdown().RefreshShownValue(); // Now that I have real products, begin showing product purchase history UpdateHistoryUI(); }
public void OnInitialized(IStoreController controller, IExtensionProvider extensions) { m_Controller = controller; m_AppleExtensions = extensions.GetExtension<IAppleExtensions>(); m_AppleExtensions.RegisterPurchaseDeferredListener(OnDeferred); foreach (var product in controller.products.all) { if (product.availableToPurchase) { Log(string.Join(" - ", new string[]{ product.metadata.localizedTitle, product.metadata.localizedDescription, product.metadata.isoCurrencyCode, product.metadata.localizedPrice.ToString(), product.metadata.localizedPriceString, product.transactionID, product.receipt, })); } } _OnInitFinished(true, ""); }
/// <summary> /// 恢复购买 /// </summary> public void RestoringTransctions() { Debug.Log(Name + "恢复购买开始执行"); if (!IsInitialized()) { Debug.Log(Name + "初始化未完成不能执行恢复购买"); return; } appleExtensions = extensions.GetExtension <IAppleExtensions>(); appleExtensions.RestoreTransactions(result => { //用于UI显示 if (result) { Debug.Log(Name + "恢复购买result:" + result + "成功"); } else { Debug.Log(Name + "恢复购买result:" + result + "失败"); } }); }
/// <summary> /// This will be called when Unity IAP has finished initialising. /// </summary> public void OnInitialized(IStoreController controller, IExtensionProvider extensions) { m_Controller = controller; m_AppleExtensions = extensions.GetExtension <IAppleExtensions>(); m_SamsungExtensions = extensions.GetExtension <ISamsungAppsExtensions>(); m_MoolahExtensions = extensions.GetExtension <IMoolahExtension>(); m_MicrosoftExtensions = extensions.GetExtension <IMicrosoftExtensions>(); m_UnityChannelExtensions = extensions.GetExtension <IUnityChannelExtensions>(); InitUI(controller.products.all); // On Apple platforms we need to handle deferred purchases caused by Apple's Ask to Buy feature. // On non-Apple platforms this will have no effect; OnDeferred will never be called. m_AppleExtensions.RegisterPurchaseDeferredListener(OnDeferred); Debug.Log("Available items:"); foreach (var item in controller.products.all) { if (item.availableToPurchase) { Debug.Log(string.Join(" - ", new[] { item.metadata.localizedTitle, item.metadata.localizedDescription, item.metadata.isoCurrencyCode, item.metadata.localizedPrice.ToString(), item.metadata.localizedPriceString, item.transactionID, item.receipt })); } } // Populate the product menu now that we have Products AddProductUIs(m_Controller.products.all); LogProductDefinitions(); }
/// <summary>Force restore previous purchases.</summary> /// <remarks>Only allow this in iOS platforms. Android doesn't require this.</remarks> public static void RestorePurchases() { if (!AppCentralStoreListener.IsInitialized()) { // TODO: Retry authorisation? Debug.Log("RestorePurchases FAIL. Not initialized."); return; } #if UNITY_IOS IAppleExtensions apple = AppCentralStoreListener.storeExtensionProvider.GetExtension <IAppleExtensions>(); // get apple specific extension // Begin the asynchronous process of restoring purchases. Expect a confirmation response in // the Action<bool> below, and ProcessPurchase if there are previously purchased products to restore. apple.RestoreTransactions(result => { // The first phase of restoration. If no more responses are received on ProcessPurchase then // no purchases are available to be restored. Debug.Log("RestorePurchases continuing: " + result + ". If no further messages, no purchases available to restore."); }); #endif }
//初始化成功回调 public void OnInitialized(IStoreController controller, IExtensionProvider extensions) { m_Controller = controller; // On Apple platforms we need to handle deferred purchases caused by Apple's Ask to Buy feature. // On non-Apple platforms this will have no effect; OnDeferred will never be called. IAppleExtensions m_AppleExtensions = extensions.GetExtension <IAppleExtensions>(); m_AppleExtensions.RegisterPurchaseDeferredListener(OnDeferred); //Product product = m_Controller.products.WithID("GameCityDiamondT1"); Debug.Log("OnInitialized: Success"); bInitUnityPurchaseSuceess = true; if (WaitingBuyProductId != string.Empty) { BuyItem(WaitingBuyProductId); } //测试购买一个东西 //BuyItem("GameCityTestItem1"); }
public void OnInitialized(IStoreController controller, IExtensionProvider extensions) { storeController = controller; appleExtension = extensions.GetExtension <IAppleExtensions>(); Debug.Log("Available items:"); foreach (var item in controller.products.all) { if (item.availableToPurchase) { Debug.Log(string.Join(" - ", new[] { item.metadata.localizedTitle, item.metadata.localizedDescription, item.metadata.isoCurrencyCode, item.metadata.localizedPrice.ToString(), item.metadata.localizedPriceString })); } } DispatchOnStoreInitializedEvent(); }
// Restore purchases previously made by this customer. Some platforms automatically restore purchases, like Google. // Apple currently requires explicit purchase restoration for IAP, conditionally displaying a password prompt. public void RestorePurchases() { // If Purchasing has not yet been set up ... if (!this.IsInitialized()) { // ... report the situation and stop restoring. Consider either waiting longer, or retrying initialization. Debug.Log("RestorePurchases FAIL. Not initialized."); return; } // If we are running on an Apple device ... if (Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.OSXPlayer) { // ... begin restoring purchases Debug.Log("RestorePurchases started ..."); // Fetch the Apple store-specific subsystem. IAppleExtensions apple = m_StoreExtensionProvider.GetExtension <IAppleExtensions>(); // Begin the asynchronous process of restoring purchases. Expect a confirmation response in // the Action<bool> below, and ProcessPurchase if there are previously purchased products to restore. apple.RestoreTransactions(result => { // The first phase of restoration. If no more responses are received on ProcessPurchase then // no purchases are available to be restored. Debug.Log("RestorePurchases continuing: " + result + ". If no further messages, no purchases available to restore."); }); } // Otherwise ... else { // We are not running on an Apple device. No work is necessary to restore purchases. Debug.Log("RestorePurchases FAIL. Not supported on this platform. Current = " + Application.platform); } }
// Restore purchases previously made by this customer. Some platforms automatically restore purchases, like Google. // Apple currently requires explicit purchase restoration for IAP, conditionally displaying a password prompt. public void RestorePurchases() { if (!IsInitialized()) { Debug.Log("[IAPManager] RestorePurchases FAIL. Not initialized."); return; } if (Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.OSXPlayer) { Debug.Log("[IAPManager] RestorePurchases started ..."); IAppleExtensions apple = m_StoreExtensionProvider.GetExtension <IAppleExtensions>(); // Begin the asynchronous process of restoring purchases. Expect a confirmation response in // the Action<bool> below, and ProcessPurchase if there are previously purchased products to restore. apple.RestoreTransactions((result) => { // The first phase of restoration. If no more responses are received on ProcessPurchase then // no purchases are available to be restored. Debug.Log("[IAPManager] RestorePurchases result = " + result); }); } }
public void OnInitialized(IStoreController controller, IExtensionProvider extensions) { Debug.Log("OnInitialized: PASS"); m_StoreController = controller; m_StoreExtensionProvider = extensions; m_AppleExtensions = extensions.GetExtension <IAppleExtensions>(); m_GoogleExtensions = extensions.GetExtension <IGooglePlayStoreExtensions>(); m_GoogleExtensions?.SetDeferredPurchaseListener(OnPurchaseDeferred); Dictionary <string, string> dict = m_AppleExtensions.GetIntroductoryPriceDictionary(); foreach (Product item in controller.products.all) { if (item.receipt != null) { string intro_json = (dict == null || !dict.ContainsKey(item.definition.storeSpecificId)) ? null : dict[item.definition.storeSpecificId]; if (item.definition.type == ProductType.Subscription) { SubscriptionManager p = new SubscriptionManager(item, intro_json); SubscriptionInfo info = p.getSubscriptionInfo(); //check subscription at startup if (info.isSubscribed() == Result.True || info.isFreeTrial() == Result.True) { //code } else { //code } } } } }
public void OnInitialized(IStoreController controller, IExtensionProvider extensions) { this.controller = controller; this.appleExtensions = extensions.GetExtension <IAppleExtensions>(); // Populate available items list AvailableItems = new List <IAPItem>(); for (int i = 0; i < definitions.Length; ++i) { IAPItemDefinition definition = definitions[i]; Product storeProduct = controller.products.WithID(definition.baseID); if (storeProduct != null && storeProduct.availableToPurchase) { AvailableItems.Add(new IAPItem { definition = definition, internalProduct = storeProduct }); } } Initialized = true; }
public InitializedEventArgs(IStoreController controller, IExtensionProvider provider) { AppleExtensions = provider.GetExtension <IAppleExtensions>(); StoreController = controller; }
public virtual void OnStoreListenerInitialized(IStoreController controller, IExtensionProvider storeExtensionProvider) { appleExtensions = storeExtensionProvider.GetExtension <IAppleExtensions>(); }
/// <summary> /// This will be called when Unity IAP has finished initialising. /// </summary> public void OnInitialized(IStoreController controller, IExtensionProvider extensions) { storeController = controller; appleExtentions = extensions.GetExtension <IAppleExtensions> (); // InitUI(controller.products.all); // On Apple platforms we need to handle deferred purchases caused by Apple's Ask to Buy feature. // On non-Apple platforms this will have no effect; OnDeferred will never be called. appleExtentions.RegisterPurchaseDeferredListener(OnDeferred); Debug.Log("Available items:"); int index = 0; foreach (var item in controller.products.all) { if (item.availableToPurchase) { Debug.Log(string.Join(" - ", new[] { item.metadata.localizedTitle, item.metadata.localizedDescription, item.metadata.isoCurrencyCode, item.metadata.localizedPrice.ToString(), item.metadata.localizedPriceString })); #if UNITY_ANDROID androidItems[index].itemName = item.metadata.localizedTitle; androidItems[index].description = item.metadata.localizedDescription; androidItems[index].currencyCode = item.metadata.isoCurrencyCode; androidItems[index].price = (float)item.metadata.localizedPrice; androidItems[index].priceString = item.metadata.localizedPriceString; #elif UNITY_IOS iosItems[index].itemName = item.metadata.localizedTitle; iosItems[index].description = item.metadata.localizedDescription; iosItems[index].currencyCode = item.metadata.isoCurrencyCode; iosItems[index].price = (float)item.metadata.localizedPrice; iosItems[index].priceString = item.metadata.localizedPriceString; #endif } index++; } // Prepare model for purchasing if (storeController.products.all.Length > 0) { selectedItemIndex = -0; } // 初期化完了通知 if (OnInitializedEvent != null) { Debug.Log("初期化完了"); #if UNITY_ANDROID OnInitializedEvent(androidItems); #elif UNITY_IOS OnInitializedEvent(iosItems); #endif } }
/// <summary> /// This will be called when Unity IAP has finished initialising. /// </summary> public void OnInitialized(IStoreController controller, IExtensionProvider extensions) { // Purchasing has succeeded initializing. Collect our Purchasing references. Debug.Log("OnInitialized: PASS"); // Overall Purchasing system, configured with products for this application. m_StoreController = controller; // Store specific subsystem, for accessing device-specific store features. m_StoreExtensionProvider = extensions; m_GooglePlayStoreExtensions = extensions.GetExtension <IGooglePlayStoreExtensions>(); m_AppleExtensions = extensions.GetExtension <IAppleExtensions>(); Dictionary <string, string> introductory_info_dict = m_AppleExtensions.GetIntroductoryPriceDictionary(); // This extension function returns a dictionary of the products' skuDetails from GooglePlay Store // Key is product Id (Sku), value is the skuDetails json string //Dictionary<string, string> google_play_store_product_SKUDetails_json = m_GooglePlayStoreExtensions.GetProductJSONDictionary(); int vip = 0; Debug.Log("Available items:"); foreach (var item in controller.products.all) { if (item.availableToPurchase) { Debug.Log(string.Join(" - ", new[] { item.metadata.localizedTitle, item.metadata.localizedDescription, item.metadata.isoCurrencyCode, item.metadata.localizedPrice.ToString(), item.metadata.localizedPriceString, item.transactionID, item.receipt })); // this is the usage of SubscriptionManager class if (item.receipt != null) { if (item.definition.type == ProductType.Subscription) { if (checkIfProductIsAvailableForSubscriptionManager(item.receipt)) { string intro_json = (introductory_info_dict == null || !introductory_info_dict.ContainsKey(item.definition.storeSpecificId)) ? null : introductory_info_dict[item.definition.storeSpecificId]; SubscriptionManager p = new SubscriptionManager(item, intro_json); SubscriptionInfo info = p.getSubscriptionInfo(); Debug.Log("product id is: " + info.getProductId()); Debug.Log("purchase date is: " + info.getPurchaseDate()); Debug.Log("subscription next billing date is: " + info.getExpireDate()); Debug.Log("is subscribed? " + info.isSubscribed().ToString()); if (info.isSubscribed().ToString() == "True") { vip = 1; } Debug.Log("is expired? " + info.isExpired().ToString()); Debug.Log("is cancelled? " + info.isCancelled()); Debug.Log("product is in free trial peroid? " + info.isFreeTrial()); Debug.Log("product is auto renewing? " + info.isAutoRenewing()); Debug.Log("subscription remaining valid time until next billing date is: " + info.getRemainingTime()); Debug.Log("is this product in introductory price period? " + info.isIntroductoryPricePeriod()); Debug.Log("the product introductory localized price is: " + info.getIntroductoryPrice()); Debug.Log("the product introductory price period is: " + info.getIntroductoryPricePeriod()); Debug.Log("the number of product introductory price period cycles is: " + info.getIntroductoryPricePeriodCycles()); } else { Debug.Log("This product is not available for SubscriptionManager class, only products that are purchase by 1.19+ SDK can use this class."); } } else { Debug.Log("the product is not a subscription product"); } } else { Debug.Log("the product should have a valid receipt"); } } } //point - comment for test Editor if (vip == 0) { IAPManager.setVip(vip); } }
// // --- IStoreListener // public void OnInitialized(IStoreController controller, IExtensionProvider extensions) { // Purchasing has succeeded initializing. Collect our Purchasing references. Debug.Log("market OnInitialized: PASS"); // Overall Purchasing system, configured with products for this application. m_StoreController = controller; // Store specific subsystem, for accessing device-specific store features. m_StoreExtensionProvider = extensions; m_GooglePlayStoreExtensions = extensions.GetExtension <IGooglePlayStoreExtensions>(); m_AppleExtensions = extensions.GetExtension <IAppleExtensions>(); int vip = 0; Dictionary <string, string> introductory_info_dict = m_AppleExtensions.GetIntroductoryPriceDictionary(); //controller.products.all.First().metadata.localizedPrice foreach (var item in controller.products.all) { //Debug.Log(product.metadata.localizedPrice); //Debug.Log(product.metadata.isoCurrencyCode); //Debug.Log(product.metadata.localizedDescription); //Debug.Log(product.metadata.localizedPriceString); //Debug.Log(product.metadata.localizedTitle); // Fetch the currency Product reference from Unity Purchasing //Debug.Log(product.definition.id); //#if UNITY_ANDROID if (item.definition.id.Length > 28) { if (staticClass.prices.ContainsKey(item.definition.id.Substring(27))) { staticClass.prices[item.definition.id.Substring(27)] = item.metadata.localizedPriceString; } } //#elif UNITY_IOS // if (product.definition.id.Length > 23) // { // if (staticClass.prices.ContainsKey(product.definition.id.Substring(22))) staticClass.prices[product.definition.id.Substring(22)] = product.metadata.localizedPriceString; // } //#endif if (item.availableToPurchase) { Debug.Log(string.Join(" - ", new[] { item.metadata.localizedTitle, item.metadata.localizedDescription, item.metadata.isoCurrencyCode, item.metadata.localizedPrice.ToString(), item.metadata.localizedPriceString, item.transactionID, item.receipt })); // this is the usage of SubscriptionManager class if (item.receipt != null) { if (item.definition.type == ProductType.Subscription) { if (checkIfProductIsAvailableForSubscriptionManager(item.receipt)) { string intro_json = (introductory_info_dict == null || !introductory_info_dict.ContainsKey(item.definition.storeSpecificId)) ? null : introductory_info_dict[item.definition.storeSpecificId]; SubscriptionManager p = new SubscriptionManager(item, intro_json); SubscriptionInfo info = p.getSubscriptionInfo(); Debug.Log("product id is: " + info.getProductId()); Debug.Log("purchase date is: " + info.getPurchaseDate()); Debug.Log("subscription next billing date is: " + info.getExpireDate()); Debug.Log("is subscribed? " + info.isSubscribed().ToString()); if (info.isSubscribed().ToString() == "True") { vip = 1; } Debug.Log("is expired? " + info.isExpired().ToString()); Debug.Log("is cancelled? " + info.isCancelled()); Debug.Log("product is in free trial peroid? " + info.isFreeTrial()); Debug.Log("product is auto renewing? " + info.isAutoRenewing()); Debug.Log("subscription remaining valid time until next billing date is: " + info.getRemainingTime()); Debug.Log("is this product in introductory price period? " + info.isIntroductoryPricePeriod()); Debug.Log("the product introductory localized price is: " + info.getIntroductoryPrice()); Debug.Log("the product introductory price period is: " + info.getIntroductoryPricePeriod()); Debug.Log("the number of product introductory price period cycles is: " + info.getIntroductoryPricePeriodCycles()); } else { Debug.Log("This product is not available for SubscriptionManager class, only products that are purchase by 1.19+ SDK can use this class."); } } else { Debug.Log("the product is not a subscription product"); } } else { Debug.Log("the product should have a valid receipt"); } } } //extensions.GetExtension<googl>() if (vip == 0) { ctrProgressClass.progress["vip"] = 0; ctrProgressClass.saveProgress(); } }
/// <summary> /// This will be called when Unity IAP has finished initialising. /// </summary> public void OnInitialized(IStoreController controller, IExtensionProvider extensions) { m_Controller = controller; m_AppleExtensions = extensions.GetExtension <IAppleExtensions>(); m_SamsungExtensions = extensions.GetExtension <ISamsungAppsExtensions>(); m_MicrosoftExtensions = extensions.GetExtension <IMicrosoftExtensions>(); m_TransactionHistoryExtensions = extensions.GetExtension <ITransactionHistoryExtensions>(); m_GooglePlayStoreExtensions = extensions.GetExtension <IGooglePlayStoreExtensions>(); // Sample code for expose product sku details for google play store // Key is product Id (Sku), value is the skuDetails json string //Dictionary<string, string> google_play_store_product_SKUDetails_json = m_GooglePlayStoreExtensions.GetProductJSONDictionary(); // Sample code for manually finish a transaction (consume a product on GooglePlay store) //m_GooglePlayStoreExtensions.FinishAdditionalTransaction(productId, transactionId); m_GooglePlayStoreExtensions.SetLogLevel(0); // 0 == debug, info, warning, error. 1 == warning, error only. InitUI(controller.products.all); // On Apple platforms we need to handle deferred purchases caused by Apple's Ask to Buy feature. // On non-Apple platforms this will have no effect; OnDeferred will never be called. m_AppleExtensions.RegisterPurchaseDeferredListener(OnDeferred); #if SUBSCRIPTION_MANAGER Dictionary <string, string> introductory_info_dict = m_AppleExtensions.GetIntroductoryPriceDictionary(); #endif // Sample code for expose product sku details for apple store //Dictionary<string, string> product_details = m_AppleExtensions.GetProductDetails(); Debug.Log("Available items:"); foreach (Product item in controller.products.all) { if (item.availableToPurchase) { Debug.Log(string.Join(" - ", item.metadata.localizedTitle, item.metadata.localizedDescription, item.metadata.isoCurrencyCode, item.metadata.localizedPrice.ToString(), item.metadata.localizedPriceString, item.transactionID, item.receipt)); #if INTERCEPT_PROMOTIONAL_PURCHASES // Set all these products to be visible in the user's App Store according to Apple's Promotional IAP feature // https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/StoreKitGuide/PromotingIn-AppPurchases/PromotingIn-AppPurchases.html m_AppleExtensions.SetStorePromotionVisibility(item, AppleStorePromotionVisibility.Show); #endif #if SUBSCRIPTION_MANAGER // this is the usage of SubscriptionManager class if (item.receipt != null) { if (item.definition.type == ProductType.Subscription) { if (checkIfProductIsAvailableForSubscriptionManager(item.receipt)) { string intro_json = (introductory_info_dict == null || !introductory_info_dict.ContainsKey(item.definition.storeSpecificId)) ? null : introductory_info_dict[item.definition.storeSpecificId]; SubscriptionManager p = new SubscriptionManager(item, intro_json); SubscriptionInfo info = p.getSubscriptionInfo(); Debug.Log("product id is: " + info.getProductId()); Debug.Log("purchase date is: " + info.getPurchaseDate()); Debug.Log("subscription next billing date is: " + info.getExpireDate()); Debug.Log("is subscribed? " + info.isSubscribed().ToString()); Debug.Log("is expired? " + info.isExpired().ToString()); Debug.Log("is cancelled? " + info.isCancelled()); Debug.Log("product is in free trial peroid? " + info.isFreeTrial()); Debug.Log("product is auto renewing? " + info.isAutoRenewing()); Debug.Log("subscription remaining valid time until next billing date is: " + info.getRemainingTime()); Debug.Log("is this product in introductory price period? " + info.isIntroductoryPricePeriod()); Debug.Log("the product introductory localized price is: " + info.getIntroductoryPrice()); Debug.Log("the product introductory price period is: " + info.getIntroductoryPricePeriod()); Debug.Log("the number of product introductory price period cycles is: " + info.getIntroductoryPricePeriodCycles()); } else { Debug.Log("This product is not available for SubscriptionManager class, only products that are purchase by 1.19+ SDK can use this class."); } } else { Debug.Log("the product is not a subscription product"); } } else { Debug.Log("the product should have a valid receipt"); } #endif } } // Populate the product menu now that we have Products AddProductUIs(m_Controller.products.all); LogProductDefinitions(); }
// // --- IStoreListener // public void OnInitialized(IStoreController controller, IExtensionProvider extensions) { // Purchasing has succeeded initializing. Collect our Purchasing references. Debug.Log("[IAPManager] OnInitialized."); // Overall Purchasing system, configured with products for this application. _StoreController = controller; // Store specific subsystem, for accessing device-specific store features. _StoreExtensionProvider = extensions; _AppleExtensions = extensions.GetExtension <IAppleExtensions>(); _SamsungExtensions = extensions.GetExtension <ISamsungAppsExtensions>(); _MoolahExtensions = extensions.GetExtension <IMoolahExtension>(); // On Apple platforms we need to handle deferred purchases caused by Apple's Ask to Buy feature. // On non-Apple platforms this will have no effect; OnDeferred will never be called. #if UNITY_IOS _AppleExtensions.RegisterPurchaseDeferredListener(OnDeferred); #endif #if UNITY_ANDROID _GooglePlayStoreExtensions = extensions.GetExtension <IGooglePlayStoreExtensions>(); #endif #if RECEIPT_VALIDATION #if UNITY_EDITOR #else #if UNITY_IOS Dictionary <string, string> introductory_info_dict = _AppleExtensions.GetIntroductoryPriceDictionary(); #endif #if UNITY_ANDROID Dictionary <string, string> introductory_info_dict = _GooglePlayStoreExtensions.GetProductJSONDictionary(); #endif #endif #endif // Store products for (int i = 0; i < controller.products.all.Length; i++) { Product pp = controller.products.all[i]; IAPProduct p = null; if (products.ContainsKey(pp.definition.id)) { p = products[pp.definition.id]; p.priceString = pp.metadata.localizedPriceString; p.price = pp.metadata.localizedPrice; p.title = pp.metadata.localizedTitle; p.description = pp.metadata.localizedDescription; p.isoCurrencyCode = pp.metadata.isoCurrencyCode; p.hasReceipt = pp.hasReceipt; p.availableToPurchase = pp.availableToPurchase; p.receipt = pp.receipt; p.transactionID = pp.transactionID; p.rawProduct = pp; p.hasReceipt = pp.hasReceipt; #if RECEIPT_VALIDATION #if UNITY_EDITOR #else _UpdateReceipt(pp, ref p, introductory_info_dict); #endif #endif } } // callback if (OnIAPInitialized != null) { OnIAPInitialized(products); } }