public bool processPurchase(PurchasableItem item_purchased, AwardedPurchaseCallback purchase_callback, AwardedPurchaseCallback awarded_callback)
    {
        //this handles all backend aspects of the purchase, including the awarding of bonuses, application of global discounts
        //returns true if purchase is successful, otherwise false
        if (!canAffordPurchase(item_purchased))
        {
            Debug.LogError("Not enough currency to buy this");
            return(false);
        }

        //charge the user for the purchase
        m_currency_owned -= Mathf.RoundToInt(item_purchased.currency_cost * GlobalDiscountManager.GetDiscountFactor());
        pushCurrencyToBackend();

        //invoke the callback for this purchase, if any
        if (purchase_callback != null)
        {
            purchase_callback(item_purchased);
        }

        //call any on_purchase methods specified
        if (item_purchased.on_purchase_methods != null)
        {
            MethodCallUtility.CallOnPurchaseMethods(item_purchased.on_purchase_methods);
        }

        return(true);
    }
    public bool canAffordPurchase(PurchasableItem item_data)
    {
        int cost = Mathf.RoundToInt(item_data.currency_cost * GlobalDiscountManager.GetDiscountFactor());

        if (m_currency_owned >= cost)
        {
            return(true);
        }
        return(false);
    }
    private void setCostText()
    {
        getPurchaseSystemManager();

        bool can_afford = m_purchase_system.canAffordPurchase(m_item_data);

        if (can_afford)
        {
            int discounted_cost = Mathf.RoundToInt(m_item_data.currency_cost * GlobalDiscountManager.GetDiscountFactor());
            m_cost_text.text = string.Format(m_cost_string, discounted_cost.ToString());
        }
        else
        {
            m_cost_text.text = m_insufficient_funds_string;
        }
    }