Exemplo n.º 1
0
    public void BuyProduct(string productID)
    {
        iapManager.OnBuyProductSuccess = (purchaseResultInfo) =>
        {
            // Verify signature with purchaseResultInfo.InAppDataSignature

            // If signature ok, deliver product

            // Consume product purchaseResultInfo.InAppDataSignature
            //iapManager.ConsumePurchase(purchaseResultInfo);

            monedas = PlayerPrefs.GetInt("Monedas") + 10;
            PlayerPrefs.SetInt("Monedas", monedas);
            SceneManager.LoadScene("Home");
        };

        iapManager.OnBuyProductFailure = (errorCode) =>
        {
            switch (errorCode)
            {
            case OrderStatusCode.ORDER_STATE_CANCEL:
                // User cancel payment.
                Debug.Log("[HMS]: User cancel payment");
                break;

            case OrderStatusCode.ORDER_STATE_FAILED:
                Debug.Log("[HMS]: order payment failed");
                break;

            case OrderStatusCode.ORDER_PRODUCT_OWNED:
                Debug.Log("[HMS]: Product owned");
                break;

            default:
                Debug.Log("[HMS:] BuyProduct ERROR" + errorCode);
                break;
            }
        };

        ProductInfo productInfo = GetProductInfo(productID);

        var payload = "test";



        iapManager.BuyProduct(productInfo, payload);
    }
    public void BuyProduct(string productID)
    {
        iapManager.OnBuyProductSuccess = (purchaseResultInfo) =>
        {
            // Verify signature with purchaseResultInfo.InAppDataSignature

            // If signature ok, deliver product

            // Consume product purchaseResultInfo.InAppDataSignature
            iapManager.ConsumePurchase(purchaseResultInfo);
        };

        iapManager.OnBuyProductFailure = (errorCode) =>
        {
            switch (errorCode)
            {
            case OrderStatusCode.ORDER_STATE_CANCEL:
                // User cancel payment.
                Debug.Log("[HMS]: User cancel payment");
                break;

            case OrderStatusCode.ORDER_STATE_FAILED:
                Debug.Log("[HMS]: order payment failed");
                break;

            case OrderStatusCode.ORDER_PRODUCT_OWNED:
                Debug.Log("[HMS]: Product owned");
                break;

            default:
                Debug.Log("[HMS:] BuyProduct ERROR" + errorCode);
                break;
            }
        };

        var productInfo = productInfoList.Find(info => info.ProductId == productID);
        var payload     = "test";

        iapManager.BuyProduct(productInfo, payload);
    }
Exemplo n.º 3
0
 public void Buy()
 {
     iapManager.BuyProduct(productID);
 }