Ejemplo n.º 1
0
    public void PlayModeTestConsumePurchaseFails()
    {
        AppInfo appInfo = new AppInfo();

        StoreService.Initialize(new InitListener(), appInfo);
        StoreService.ConsumePurchase(new PurchaseInfo(), new PurchaseListener());
    }
        public void OnQueryInventory(Inventory inventory)
        {
            Debug.Log("OnQueryInventory");
            Debug.Log("[Game] Product List: ");
            var message = "Product List: \n";

            _productIds = new List <string>();
            foreach (var productInfo in inventory.GetProductDictionary())
            {
                Debug.Log("[Game] Returned product: " + productInfo.Key + " " + productInfo.Value.ProductId);
                message += string.Format("{0}:\n" +
                                         "\tTitle: {1}\n" +
                                         "\tDescription: {2}\n" +
                                         "\tConsumable: {3}\n" +
                                         "\tPrice: {4}\n" +
                                         "\tCurrency: {5}\n" +
                                         "\tPriceAmountMicros: {6}\n" +
                                         "\tItemType: {7}\n",
                                         productInfo.Key,
                                         productInfo.Value.Title,
                                         productInfo.Value.Description,
                                         productInfo.Value.Consumable,
                                         productInfo.Value.Price,
                                         productInfo.Value.Currency,
                                         productInfo.Value.PriceAmountMicros,
                                         productInfo.Value.ItemType
                                         );

                _productIds.Add(productInfo.Value.ProductId);
            }

            message += "\nPurchase List: \n";

            foreach (var purchaseInfo in inventory.GetPurchaseDictionary())
            {
                Debug.Log("[Game] Returned purchase: " + purchaseInfo.Key + " orderQueryToken: " +
                          purchaseInfo.Value.OrderQueryToken + " gameOrderId: " + purchaseInfo.Value.GameOrderId);
                message += string.Format("{0}\n", purchaseInfo.Value.ProductId);
            }

            Show(message);

            // update dropdown list
            _mDropdown = _dropObj.GetComponent <Dropdown>();
            _mDropdown.ClearOptions();
            foreach (var id in _productIds)
            {
                _mDropdown.options.Add(new Dropdown.OptionData(id));
            }

            _mDropdown.RefreshShownValue();

            if (_mConsumeOnQuery)
            {
                StoreService.ConsumePurchase(inventory.GetPurchaseList(), this);
            }
        }
Ejemplo n.º 3
0
        public void OnPurchase(PurchaseInfo purchaseInfo)
        {
            string message = string.Format(
                "[Game] Purchase Succeeded, productId: {0}, cpOrderId: {1}, developerPayload: {2}, storeJson: {3}",
                purchaseInfo.ProductId, purchaseInfo.GameOrderId, purchaseInfo.DeveloperPayload,
                purchaseInfo.StorePurchaseJsonString);

            Debug.Log(message);
            Show(message);

            if (m_consumeOnPurchase)
            {
                Debug.Log("Consuming");
                StoreService.ConsumePurchase(purchaseInfo, this);
            }
        }
Ejemplo n.º 4
0
        public void OnQueryInventory(Inventory inventory)
        {
            Debug.Log("OnQueryInventory");
            Debug.Log("[Game] Product List: ");
            string message = "Product List: \n";


            foreach (KeyValuePair <string, ProductInfo> productInfo in inventory.GetProductDictionary())
            {
                Debug.Log("[Game] Returned product: " + productInfo.Key + " " + productInfo.Value.ProductId);
                message += string.Format("{0}:\n" +
                                         "\tTitle: {1}\n" +
                                         "\tDescription: {2}\n" +
                                         "\tConsumable: {3}\n" +
                                         "\tPrice: {4}\n" +
                                         "\tCurrency: {5}\n" +
                                         "\tPriceAmountMicros: {6}\n" +
                                         "\tItemType: {7}\n",
                                         productInfo.Key,
                                         productInfo.Value.Title,
                                         productInfo.Value.Description,
                                         productInfo.Value.Consumable,
                                         productInfo.Value.Price,
                                         productInfo.Value.Currency,
                                         productInfo.Value.PriceAmountMicros,
                                         productInfo.Value.ItemType
                                         );
            }

            message += "\nPurchase List: \n";

            foreach (KeyValuePair <string, PurchaseInfo> purchaseInfo in inventory.GetPurchaseDictionary())
            {
                Debug.Log("[Game] Returned purchase: " + purchaseInfo.Key);
                message += string.Format("{0}\n", purchaseInfo.Value.ProductId);
            }

            Show(message);

            if (_consumeOnQuery)
            {
                StoreService.ConsumePurchase(inventory.GetPurchaseList(), this);
            }
        }
Ejemplo n.º 5
0
        public void OnPurchase(PurchaseInfo purchaseInfo)
        {
            string message = string.Format(
                "[Game] Purchase Succeeded, productId: {0}, cpOrderId: {1}, developerPayload: {2}, storeJson: {3}",
                purchaseInfo.ProductId, purchaseInfo.GameOrderId, purchaseInfo.DeveloperPayload,
                purchaseInfo.StorePurchaseJsonString);

            Debug.Log(message);
            Show(message);

            /*
             * If the product is consumable, consume it and deliver the product in OnPurchaseConsume().
             * Otherwise, deliver the product here.
             */

            if (m_ConsumeOnPurchase)
            {
                Debug.Log("Consuming");
                StoreService.ConsumePurchase(purchaseInfo, this);
            }
        }
Ejemplo n.º 6
0
 public void PlayModeTestConsumePurchaseFails()
 {
     Assert.That(() => { StoreService.ConsumePurchase(new PurchaseInfo(), new PurchaseListener()); },
                 Throws.TypeOf <NullReferenceException>());
 }