[Solved] Second and more Purchase is free in Consumable items

Hi,
First purchse going correct, but when I buy second and more times purchase is for free
It is on ios and samsung stores.

Into stores i use “Consumable” product.

void Start()
    {
        Init();
    }

    public void Init()
    {
        CurrentStoreInitState = StoreInitState.InitInProgress;

        var module = StandardPurchasingModule.Instance();
        var builder = ConfigurationBuilder.Instance(module);
        builder.Configure<IGooglePlayConfiguration>().SetPublicKey(GooglePublicKey);

        if (CheatEngineManager.IsCheatsEnabled)
        {
            builder.Configure<ISamsungAppsConfiguration>().SetMode(SamsungAppsMode.AlwaysSucceed); // TESTING: auto-approves all transactions by Samsung
        }

        //регистрирую товары
        builder.AddProduct(Goods.BuyCoins00.ToString(), ProductType.Consumable, new IDs
        {
            {Goods.BuyCoins00.ToString() + "IOS", AppleAppStore.Name},
            {Goods.BuyCoins00.ToString().ToLower() + "googleplay", GooglePlay.Name},
            {Goods.BuyCoins00.ToString().ToLower() + "samsung", SamsungApps.Name}
        });

        UnityPurchasing.Initialize(this, builder);
    }

public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
    {
        this.controller = controller;
        StoreInited(controller);
        //this.extensions = extensions;
        CurrentStoreInitState = StoreInitState.InitSuccess;
    }

    public void OnInitializeFailed(InitializationFailureReason error)
    {
        CurrentStoreInitState = StoreInitState.InitFailed;
        Debug.LogWarning("Не могу инициализировать магазин " + error);
    }

public void BuyCoinTier(Goods coinTier)
    {
        if (IsCheats)
        {
            ActivateTier(coinTier);
            Debug.LogError("Использован чит на покупку монет");

            //сохраняю покупку для панели читов
            int value = 1 + ObscuredPrefs.GetInt("Cheat_" + coinTier);
            ObscuredPrefs.SetInt("Cheat_" + coinTier, value);
        }
        else
        {
            Purchase(coinTier.ToString());
        }
    }

public void Purchase(string product)
    {
        if (_isPurchaseInProgress)
        {
            Debug.LogWarning("Совершается покупка");
            return;
        }

        if (controller != null)
        {
            //совершаю покупку
            _isPurchaseInProgress = true;
            controller.InitiatePurchase(product);
        }
        else
        {
            Debug.LogWarning("Покупки не инициализированы");
            Init();
        }

//вызывается когда покупка успешно выполнена
    public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs e)
    {
        _isPurchaseInProgress = false;

        bool validPurchase = true; // Presume valid for platforms with no R.V.

        // Unity IAP's validation logic is only included on these platforms.
#if (UNITY_ANDROID || UNITY_IOS || UNITY_STANDALONE_OSX)
        // Prepare the validator with the secrets we prepared in the Editor
        // obfuscation window.
        var validator = new CrossPlatformValidator(GooglePlayTangle.Data(),
            AppleTangle.Data(), Application.bundleIdentifier);

        try
        {
            // On Google Play, result has a single product ID.
            // On Apple stores, receipts contain multiple products.
            validator.Validate(e.purchasedProduct.receipt);
            // For informational purposes, we list the receipt(s)
            Debug.Log("Receipt is valid");
            //foreach (IPurchaseReceipt productReceipt in result)
            //{
            //    Debug.Log(productReceipt.productID);
            //    Debug.Log(productReceipt.purchaseDate);
            //    Debug.Log(productReceipt.transactionID);
            //}
        }
        catch (IAPSecurityException)
        {
            Debug.LogWarning("Invalid receipt, быть может читер!");
            validPurchase = false;
            FailValidate();
        }
#endif

        if (validPurchase)
        {
            // Unlock the appropriate content here.
            ProcessPurchaseComplete(e.purchasedProduct.definition.id, e.purchasedProduct.transactionID, e.purchasedProduct.receipt);
        }
       
        Debug.Log("return purchase complete");
        return PurchaseProcessingResult.Complete;
    }

    public void OnPurchaseFailed(Product i, PurchaseFailureReason p)
    {
        _isPurchaseInProgress = false;
        Debug.LogWarning("Не могу купить " + i.receipt + ", потому что " + p);
    }

2849298--208144--imgpsh_fullsize.jpg

Hi @StanislavMaksheev ,

Would you be able to provide some more details about this issue?

If you could provide a link to your app or a copy of your project, that would help us identify this issue.
In addition, if you could, please provide a list of steps needed to reproduce this issue.

If you would like to send the link in private, you can create a support ticket here:

I was update IAP sdk to latest version and it all now works…

1 Like