Example #1
0
        public void NotifyDeferredProrationUpgradeDowngradeSubscription(IStoreCallback storeCallback, string productId)
        {
            Product product = storeCallback.FindProductById(productId);

            if (product != null)
            {
                m_DeferredProrationUpgradeDowngradeSubscriptionAction?.Invoke(product);
            }
        }
Example #2
0
        public void UpgradeDowngradeSubscription(string oldSku, string newSku, int desiredProrationMode)
        {
            Product product    = m_StoreCallback.FindProductById(newSku);
            Product oldProduct = m_StoreCallback.FindProductById(oldSku);

            if (product != null && product.definition.type == ProductType.Subscription &&
                oldProduct != null && oldProduct.definition.type == ProductType.Subscription)
            {
                m_GooglePlayStoreService.Purchase(product.definition, oldProduct, desiredProrationMode);
            }
            else
            {
                m_StoreCallback?.OnPurchaseFailed(
                    new PurchaseFailureDescription(
                        newSku ?? "",
                        PurchaseFailureReason.ProductUnavailable,
                        "Please verify that the products are subscriptions and are not null."));
            }
        }
Example #3
0
        public void NotifyDeferredPurchase(IStoreCallback storeCallback, string productId, string receipt, string transactionId)
        {
            Product product = storeCallback.FindProductById(productId);

            if (product != null)
            {
                ProductPurchaseUpdater.UpdateProductReceiptAndTransactionID(product, receipt, transactionId, GooglePlay.Name);
                m_DeferredPurchaseAction?.Invoke(product);
            }
        }
        void FinishTransaction(GooglePurchase purchase)
        {
            Product product = m_StoreCallback.FindProductById(purchase.sku);

            if (product != null)
            {
                m_TransactionService.FinishTransaction(product.definition, purchase.purchaseToken);
            }
            else
            {
                m_StoreCallback.OnPurchaseFailed(new PurchaseFailureDescription(purchase.sku, PurchaseFailureReason.ProductUnavailable, "Product was not found but was purchased"));
            }
        }
        List <Product> FillProductsWithPurchases(IEnumerable <GooglePurchase> purchases)
        {
            var purchasedProducts = new List <Product>();

            foreach (var purchase in purchases.Where(purchase => purchase != null).ToList())
            {
                var product = m_StoreCallback?.FindProductById(purchase.sku);
                if (product != null)
                {
                    var updatedProduct = new Product(product.definition, product.metadata, purchase.receipt)
                    {
                        transactionID = purchase.purchaseToken
                    };
                    purchasedProducts.Add(updatedProduct);
                }
            }

            return(purchasedProducts);
        }