Example #1
0
    public void BuyProduct(string productId)
    {
        if (storeController == null)
        {
            Debug.Log("Cannot perform buying product. Manager is not initialized");
            return;
        }

        Product product = storeController.products.WithID(productId);

        sorryForThatHack = purchaseStatusDialog;
        if (product != null && product.availableToPurchase)
        {
            Debug.Log(string.Format("Purchasing product asychronously: '{0}'", product.definition.id));
            storeController.InitiatePurchase(product);
        }
        else
        {
            Debug.Log("PurchaseManager: buying product FAIL. Not purchasing product, either is not found or is not available for purchase");
            sorryForThatHack.Show("Failed to purchase: wrong productID", false);
        }
    }