// Unity IAP framework will call this method after Initialize method regardless. public void RetrieveProducts(ReadOnlyCollection <ProductDefinition> products) { _billingClientStateListener = new BillingClientStateListener(); // Retry connection when Play Billing Service is disconnected. _billingClientStateListener.OnBillingServiceDisconnected += () => { _billingUtil.LogWarningFormat("Service disconnected, retrying connection..."); EndConnection(); InstantiateBillingClientAndMakeConnection(); }; _billingClientStateListener.OnBillingSetupFinished += (billingResult) => { MarkBillingClientStartConnectionCallComplete(billingResult); if (_billingClientReady) { _inventory.UpdateCatalog(products); // Kick off tasks to retrieve products information on the main thread. _billingUtil.RunOnMainThread(() => RetrieveProductsInternal(products)); } else { _billingUtil.LogWarningFormat("Google Play Store: play billing service unavailable!"); _billingUtil.RunOnMainThread(() => _callback.OnSetupFailed(InitializationFailureReason.PurchasingUnavailable)); } }; InstantiateBillingClientAndMakeConnection(); }
// Unity IAP framework will call this method after Initialize method regardless. public void RetrieveProducts(ReadOnlyCollection <ProductDefinition> products) { if (!_billingClientReady) { _billingUtil.LogWarningFormat("Google Play Store: play billing service unavailable!"); _billingUtil.RunOnMainThread(() => _callback.OnSetupFailed(InitializationFailureReason.PurchasingUnavailable)); return; } _inventory.UpdateCatalog(products); // Run tasks to retrieve products information and trigger callback when all of them finished. RetrieveProductsInternal(products); }
// This is now being used by the INativeStore implementation public void StoreRetrieveProducts(ReadOnlyCollection <ProductDefinition> productDefinitions) { var products = new List <ProductDescription>(); foreach (var product in productDefinitions) { if (unavailableProductId != product.id) { var metadata = new ProductMetadata("$0.01", "Fake title for " + product.id, "Fake description", "USD", 0.01m); ProductCatalog catalog = ProductCatalog.LoadDefaultCatalog(); if (catalog != null) { foreach (var item in catalog.allProducts) { if (item.id == product.id) { metadata = new ProductMetadata(item.googlePrice.value.ToString(), item.defaultDescription.Title, item.defaultDescription.Description, "USD", item.googlePrice.value); } } } products.Add(new ProductDescription(product.storeSpecificId, metadata)); } } Action <bool, InitializationFailureReason> handleAllowInitializeOrRetrieveProducts = (bool allow, InitializationFailureReason failureReason) => { if (allow) { m_Biller.OnProductsRetrieved(products); // Since iOS is already rigged to work this way might as well just use it... // *** if we want to use this change without Promo then we'll need to use reflection here Promo.ProvideProductsToAds(this, m_Biller); } else { m_Biller.OnSetupFailed(failureReason); } }; // To mimic typical store behavior, only display RetrieveProducts dialog for developers if (!(UIMode == FakeStoreUIMode.DeveloperUser && StartUI <InitializationFailureReason> (productDefinitions, DialogType.RetrieveProducts, handleAllowInitializeOrRetrieveProducts))) { // Default non-UI FakeStore RetrieveProducts behavior is to succeed handleAllowInitializeOrRetrieveProducts(true, InitializationFailureReason.AppNotKnown); } }
// When using an incorrect product id: // "Exception from HRESULT: 0x805A0194" public void OnProductListError(string message) { util.RunOnMainThread(() => { if (message.Contains("801900CC")) { callback.OnSetupFailed(InitializationFailureReason.AppNotKnown); } else { logError("Unable to retrieve product listings. UnityIAP will automatically retry..."); logError(message); init(3000); } }); }
public void RetrieveProducts(ReadOnlyCollection <ProductDefinition> products) { if (m_StoreCallback != null) { m_GooglePlayStoreService.RetrieveProducts(products, retrievedProducts => { m_GoogleFetchPurchases.FetchPurchases(purchaseProducts => { var mergedProducts = MakePurchasesIntoProducts(retrievedProducts, purchaseProducts); m_StoreCallback.OnProductsRetrieved(mergedProducts); }); }, () => { m_StoreCallback.OnSetupFailed(InitializationFailureReason.NoProductsAvailable); }); } }
public void OnSetupFailed(string error) { callback.OnSetupFailed(InitializationFailureReason.NoProductsAvailable); }
public void OnSetupFailed(InitializationFailureReason reason) { m_Util.RunOnMainThread(() => m_ForwardTo.OnSetupFailed(reason)); }
public void OnSetupFailed(string reason) { var r = (InitializationFailureReason)Enum.Parse(typeof(InitializationFailureReason), reason, true); unity.OnSetupFailed(r); }