Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more..
    Dismiss Notice
  3. Dismiss Notice

IAP triggering OnPurchaseFailed even after a successful purchase on Android

Discussion in 'Unity IAP' started by MyAtom, Nov 19, 2020.

  1. MyAtom

    MyAtom

    Joined:
    Oct 30, 2016
    Posts:
    6
    I am using In App Purchasing package 2.1.1. I updated Unity IAP yesterday.

    On my Android device (Moto G8) I now find that OnPurchaseFailed is triggered with reason ProductUnavailable, immediately after a successful purchase which triggered ProcessPurchase for the same product ID.

    I am currently working around this by storing the ID of successfully purchased products, so that no action is taken in OnPurchaseFailed in the event of a ProductUnavailable error on the same ID. However, there is clearly an issue here.

    I do not get the same issue on IOS. I was also not getting this error on Android before updating Unity IAP.

    Any idea why this is happening?
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
  3. MyAtom

    MyAtom

    Joined:
    Oct 30, 2016
    Posts:
    6
    Yes it worked fine before the upgrade (I was already using 2.1.1 for App Purchasing, but was prompted to upgrade Unity IAP yesterday and that is when the error started. It still works fine on IOS). The code I am using is essentially that provided in the Unity Learn tutorial https://learn.unity.com/tutorial/unity-iap#5c7f8528edbc2a002053b46e modified for receipt validation (similar to this https://docs.unity3d.com/Manual/UnityIAPValidatingReceipts.html) and modified to call my own code on purchase or failure. Unfortunately I don't have time at the moment to set up a new Google Play project with the Sample IAP as I am just about to launch my game.
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
  5. MyAtom

    MyAtom

    Joined:
    Oct 30, 2016
    Posts:
    6
    Thank you. I am testing both locally and on Google Play, and both give the same response (succeed followed by fail)
     
  6. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Can you share the code you mentioned that you modified to call your own code on purchase or failure? Also, please place Debug.Log statements in all your purchase methods and callbacks, and provide the device logs. The Debug.Log statements will show in the logs, and this will help me to troubleshoot, thx
     
  7. densy07

    densy07

    Joined:
    Nov 27, 2013
    Posts:
    34
    I have the bug too. I have to roll back now.
     
  8. parkdr

    parkdr

    Joined:
    Jul 12, 2018
    Posts:
    3
    same problem
     
  9. John_Corbett

    John_Corbett

    Unity Technologies

    Joined:
    May 17, 2019
    Posts:
    151
    Have you tried this with Asset Store Version 2.2.2 with Package Manager version 2.2.1?
     
  10. MyAtom

    MyAtom

    Joined:
    Oct 30, 2016
    Posts:
    6
    I just upgraded to version 2.2.2 and the bug is gone. Successful purchase is no longer followed by OnPurchaseFailed.

    It looks like another bug has also been fixed in this version, whereby cancelling a transaction by clicking outside the box now properly triggers OnPurchaseFailed with reason UserCancelled. Previously that was not being triggered on Android.

    Thank you for fixing
     
    MatthieuSmith_Unity3D likes this.