public virtual void OnProductsRetrieved(string json) { // NB: AppleStoreImpl overrides this completely and does not call the base. unity.OnProductsRetrieved(JSONSerializer.DeserializeProductDescriptions(json)); Promo.ProvideProductsToAds(this, unity); }
public virtual void OnPurchaseSucceeded(string id, string receipt, string transactionID) { if (!eventsDisabled) { SendPurchaseSucceededEvent(id, receipt, transactionID); } unity.OnPurchaseSucceeded(id, receipt, transactionID); Promo.ProvideProductsToAds(this, unity); }
public virtual void OnProductsRetrieved(string json) { // NB: AppleStoreImpl overrides this completely and does not call the base. unity.OnProductsRetrieved(JSONSerializer.DeserializeProductDescriptions(json)); // The shouldLogPromoInitialization flag determines if we should log a message from ProvideProductsToAds // We would like to log this message only once when we successfully retrieved products, so we reset // shouldLogPromoInitialization to false once we call ProvideProductsToAds. Promo.ProvideProductsToAds(this, unity, shouldLogPromoInitialization); shouldLogPromoInitialization = false; }
// 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); } }
internal StandardPurchasingModule(IUtil util, IAsyncWebUtil webUtil, ILogger logger, INativeStoreProvider nativeStoreProvider, RuntimePlatform platform, AppStore android, bool useCloudCatalog, string persistentDataPath) { this.util = util; this.webUtil = webUtil; this.logger = logger; m_NativeStoreProvider = nativeStoreProvider; m_RuntimePlatform = platform; useFakeStoreUIMode = FakeStoreUIMode.Default; useFakeStoreAlways = false; m_AppStorePlatform = android; m_UseCloudCatalog = useCloudCatalog; m_persistentDataPath = persistentDataPath; Promo.InitPromo(platform, logger, Version, util, webUtil); }
// These are modified copy from engine ConnectSessionInfo.cpp // const string kConnectSessionInfoDebugDevice = "debug_device"; // const string kConnectSessionInfoCloudUserId = "clouduserid"; // const string kConnectSessionInfoCloudProjectId = "cloudprojectid"; // const string kConnectSessionInfoOrganizationId = "organizationid"; // const string kConnectSessionInfoLocalProjectId = "localprojectid"; // const string kConnectSessionInfoMachineId = "machineid"; // const string kConnectSessionInfoLicenseHash = "license_hash"; private ProfileData(IUtil util) { m_Util = util; // Get what we can from internal sources AppId = util.cloudProjectId; if (AppId.Length == 0) { AppId = "Unknown"; } Platform = util.platform.ToString(); PlatformId = (int)util.platform; SdkVer = util.unityVersion; OsVer = util.operatingSystem; #if HIGH_PERMISSION_DATA DeviceId = util.deviceUniqueIdentifier; #else DeviceId = SystemInfo.unsupportedIdentifier; #endif GameVersion = util.gameVersion; IapVer = Promo.Version(); // These are available in PlayerPrefs for 5.4+ UserId = util.userId; SessionId = util.sessionId; // Adding limited device info to IAP events (because Ads) ScreenWidth = util.screenWidth; ScreenHeight = util.screenHeight; ScreenDpi = util.screenDpi; ScreenOrientation = util.screenOrientation; // update on send // this is 5.6+ so we should flip to reflection or drop // BuildGUID = Application.buildGUID; // BuildGUID = String.Empty; }
public override void OnProductsRetrieved(string json) { // base.OnProductsRetrieved (json); // Don't call this, because we want to enrich the products first // get product list var productDescriptions = JSONSerializer.DeserializeProductDescriptions(json); List <ProductDescription> finalProductDescriptions = null; this.products_json = json; // parse app receipt if (m_Native != null) { var base64AppReceipt = m_Native.appReceipt; if (!string.IsNullOrEmpty(base64AppReceipt)) { AppleReceipt appleReceipt = getAppleReceiptFromBase64String(base64AppReceipt); if (appleReceipt != null && appleReceipt.inAppPurchaseReceipts != null && appleReceipt.inAppPurchaseReceipts.Length > 0) { // Enrich the product descriptions with parsed receipt data finalProductDescriptions = new List <ProductDescription> (); foreach (var productDescription in productDescriptions) { // JDRjr this Find may not be sufficient for subsciptions (or even multiple non-consumables?) var foundReceipts = Array.FindAll(appleReceipt.inAppPurchaseReceipts, (r) => r.productID == productDescription.storeSpecificId); if (foundReceipts == null || foundReceipts.Length == 0) { finalProductDescriptions.Add(productDescription); } else { Array.Sort(foundReceipts, (b, a) => (a.purchaseDate.CompareTo(b.purchaseDate))); var mostRecentReceipt = foundReceipts[0]; var productType = (AppleStoreProductType)Enum.Parse(typeof(AppleStoreProductType), mostRecentReceipt.productType.ToString()); if (productType == AppleStoreProductType.AutoRenewingSubscription) { // if the product is auto-renewing subscription, filter the expired products if (new SubscriptionInfo(mostRecentReceipt, null).isExpired() == Result.True) { finalProductDescriptions.Add(productDescription); } else { finalProductDescriptions.Add( new ProductDescription( productDescription.storeSpecificId, productDescription.metadata, base64AppReceipt, mostRecentReceipt.transactionID)); } } else if (productType == AppleStoreProductType.Consumable) { finalProductDescriptions.Add(productDescription); } else { finalProductDescriptions.Add( new ProductDescription( productDescription.storeSpecificId, productDescription.metadata, base64AppReceipt, mostRecentReceipt.transactionID)); } } } } } } // Pass along the enriched product descriptions unity.OnProductsRetrieved(finalProductDescriptions ?? productDescriptions); // Set up IAP promo product list (since we bypassed the JSON store here) Promo.ProvideProductsToAds(this, unity, shouldLogPromoInitialization); shouldLogPromoInitialization = false; // If there is a promotional purchase callback, tell the store to intercept those purchases. if (m_PromotionalPurchaseCallback != null) { m_Native.InterceptPromotionalPurchases(); } // Indicate we are ready to start receiving payments. m_Native.AddTransactionObserver(); }