Наследование: System.Web.UI.Page
Пример #1
0
 public void OnPurchaseCompleted(IBuyable buyable)
 {
     _scorreCounter.ReductionScorre(GetPrice(buyable.Price, buyable.ObjectType));
     ObjectOnScene.AddCount(buyable.ObjectType);
     GameDataStorage.SaveObjectsOnScene(ObjectOnScene);
     PurchaseCompleted?.Invoke();
 }
Пример #2
0
        private void InvokePurchaseCompleted(PurchaseResult purchaseResult)
        {
            Debug.Assert(purchaseResult != null);

            if (_observers != null)
            {
                lock (_observers)
                {
                    foreach (var item in _observers)
                    {
                        try
                        {
                            item.OnNext(new PurchaseInfo(_purchaseProductId, purchaseResult, null, null));
                        }
                        catch (Exception e)
                        {
                            _console.TraceData(TraceEventType.Error, _traceEventPurchase, e);
                        }
                    }
                }
            }

            try
            {
                PurchaseCompleted?.Invoke(this, new PurchaseCompletedEventArgs(purchaseResult));
            }
            catch (Exception e)
            {
                _console.TraceData(TraceEventType.Error, _traceEventPurchase, e);
            }
            finally
            {
                _console.TraceEvent(TraceEventType.Stop, _traceEventPurchase, GetEventName(_traceEventPurchase) + " completed: " + _purchaseProductId);
            }
        }
Пример #3
0
        public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
        {
            bool validPurchase = true; // Presume valid for platforms with no R.V.

            // Unity IAP's validation logic is only included on these platforms.
#if UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX
            // Prepare the validator with the secrets we prepared in the Editor
            // obfuscation window.
            var validator = new CrossPlatformValidator(GooglePlayTangle.Data(),
                                                       AppleTangle.Data(), Application.identifier);

            try
            {
                // On Google Play, result has a single product ID.
                // On Apple stores, receipts contain multiple products.
                var result = validator.Validate(args.purchasedProduct.receipt);
                // For informational purposes, we list the receipt(s)
                Debug.Log("Receipt is valid. Contents:");
                foreach (IPurchaseReceipt productReceipt in result)
                {
                    Debug.Log(productReceipt.productID);
                    Debug.Log(productReceipt.purchaseDate);
                    Debug.Log(productReceipt.transactionID);
                }
            }
            catch (IAPSecurityException)
            {
                Debug.Log($"Invalid receipt, not unlocking content ");
                validPurchase = false;
            }
#elif UNITY_EDITOR
            Debug.Log("Receipt is valid. EDITOR:");
            validPurchase = true;
#endif

            // A consumable product has been purchased by this user.
            if (String.Equals(args.purchasedProduct.definition.id, PurchasedItemID, StringComparison.Ordinal) && validPurchase)
            {
                PurchaseCompleted?.Invoke(args.purchasedProduct.definition.id);
                SceneActivationBehaviour <GameLogicActivator> .Instance.AnalyticsController.SendPurchaseEvent(AnalyticsScripts.QLPurchaseState.QLPurchaseStateSucceded,
                                                                                                              args.purchasedProduct.definition.id,
                                                                                                              (float)args.purchasedProduct.metadata.localizedPrice,
                                                                                                              args.purchasedProduct.metadata.isoCurrencyCode,
                                                                                                              SceneActivationBehaviour <StoreUIActivator> .Instance.CoinsForProduct(args.purchasedProduct.definition.id),
                                                                                                              SceneActivationBehaviour <StoreUIActivator> .Instance.StoreOpenSource);

                Debug.Log(string.Format("[IAP] ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id));
                // The consumable item has been successfully purchased, add 100 coins to the player's in-game score.
                //ScoreManager.score += 100;
            }
            // Or ... a non-consumable product has been purchased by this user.
            //else if (String.Equals(args.purchasedProduct.definition.id, kProductIDNonConsumable, StringComparison.Ordinal))
            //{
            //    Debug.Log(string.Format("[IAP] ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id));
            //    // TODO: The non-consumable item has been successfully purchased, grant this item to the player.
            //}
            // Or ... a subscription product has been purchased by this user.
            //else if (String.Equals(args.purchasedProduct.definition.id, kProductIDSubscription, StringComparison.Ordinal))
            //{
            //    Debug.Log(string.Format("[IAP] ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id));
            //    // TODO: The subscription item has been successfully purchased, grant this to the player.
            //}
            // Or ... an unknown product has been purchased by this user. Fill in additional products here....
            else
            {
                Debug.Log(string.Format("[IAP] ProcessPurchase: FAIL. Unrecognized product: '{0}'", args.purchasedProduct.definition.id));
            }

            // Return a flag indicating whether this product has completely been received, or if the application needs
            // to be reminded of this purchase at next app launch. Use PurchaseProcessingResult.Pending when still
            // saving purchased products to the cloud, and when that save is delayed.
            return(PurchaseProcessingResult.Complete);
        }