Search code examples
in-app-billingunityscriptunity-game-engine

Unity Cross Platform InApp Purchase Service


I am having hard time working with Unity's cross platform GooglePlay InApp purchase service. I am pasting the link below from which what I have been following for my implementation.

https://docs.unity3d.com/Manual/UnityIAPProcessingPurchases.html

The problem is:

public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args) {}

This method is called every time. Every time what I mean is, Even if there is no internet connection, this function is called and returning PurchaseProcessingResult.Complete. I am wondering and no clue where I should unlock the locked items after successfull purchase. If this function is called even if there is no internect connection, I don't know what to say.... In demo, I saw unlock logic in this particular method after checking product id.

Could someone guide me the proper implementation with receipt validation for google play. I tested the same logic in Apple, and it seems to be working fine.

The problem is with the Google store. Please someone guide me for the right implementation.

I am following the same implementation what suggested in this link: https://unity3d.com/learn/tutorials/topics/analytics/integrating-unity-iap-your-game Have a look at the attached screenshot. You can see google native inapp popping out and at the same time, onPurchaseFailed function is called. That's how I am showing the Purchase Error dialog. You can see that in action behind google native inapp dialog. And at the same time, ProcessPurchase is also called.

BTW, this behaviour is random. 70% of the time, I am getting google inapp native popup and transaction is successful most of the time. Its working as expected most of the time. But both ProcessPurchase and OnPurchaseFailed is also called occasionally. This random behaviour suggests that there must be something wrong in Unity IAP module or its behaviour is not consistent in all android devices..... Don't get confused by google account verification error in native dialog. Its the same case with my other valid accounts too....

enter image description here


Solution

  • Finally I found answer for my own question...

    I was triggering inapp purchase call twice concurrently.

    In unity, I accidently placed one button below the other. It was the one triggering IAP call twice... After removing that, everything started working fine....

    I am having another issue, Out of 8 NON CONSUMABLES and 4 CONSUMABLES, two consumables are acting as non consumables.... Any Idea ???

    Update: Those 2 items were declared as non consumables and made a purchase too before changing them to consumables. This was the reason for that unsual behaviour. Now everything is working fine.