Пример #1
0
    private void BuyProductID(string productId)
    {
        onShopCanvas.ShowThatItsPurchasing();

        // If Purchasing has been initialized ...
        if (IsInitialized())
        {
            // ... look up the Product reference with the general product identifier and the Purchasing 
            // system's products collection.
            Product product = m_StoreController.products.WithID(productId);

            // If the look up found a product for this device's store and that product is ready to be sold ... 
            if (product != null && product.availableToPurchase)
            {
                //Debug.Log(string.Format("Purchasing product asychronously: '{0}'", product.definition.id));
                // ... buy the product. Expect a response either through ProcessPurchase or OnPurchaseFailed 
                // asynchronously.
                m_StoreController.InitiatePurchase(product);
            }
            // Otherwise ...
            else
            {
                // ... report the product look-up failure situation  
                //Debug.Log("BuyProductID: FAIL. Not purchasing product, either is not found or is not available for purchase");
                onShopCanvas.PriceToNormal();
            }
        }
        // Otherwise ...
        else
        {
            // ... report the fact Purchasing has not succeeded initializing yet. Consider waiting longer or 
            // retrying initiailization.
            //Debug.Log("BuyProductID FAIL. Not initialized.");
        }

        onShopCanvas.PriceToNormal();
    }