Search Unity

  1. Unity 2020.2 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

[Solved] [2.2.2] Non-consumables don't have a receipt anymore in OnInitialized

Discussion in 'Unity IAP' started by MardukCorp, Nov 24, 2020.

Thread Status:
Not open for further replies.
  1. MardukCorp

    MardukCorp

    Joined:
    May 21, 2016
    Posts:
    90
    I did a test purchase for one of my non-consumables and hasReceipt() returns false in the OnInitialized callback when checking the purchased item on app start (the products "receipt" parameter is also empty).

    When I then try to purchase that item again, the Google Play Store returns "You already own this item", so it is definitely purchased.

    It seems that the new IAP package/plugin is quite broken, and it would be great to know to which stable version to roll-back to until the unifed package comes out next year.
     
    xLeo and Tankzo like this.
  2. John_Corbett

    John_Corbett

    Unity Technologies

    Joined:
    May 17, 2019
    Posts:
    42
    Tankzo likes this.
  3. Tankzo

    Tankzo

    Joined:
    Jul 16, 2019
    Posts:
    11
    +1 on this.

    Have this issue as well.

    It looks like the OnInitialized listener is run and returns the "All good" before whatever code that gives the "Already recorded transaction <transactionID>" returns its response.

    The timing I have is below

    [2020/11/27 06:24:56.50971] (Log): MenuController - IAP Button Enabled <= runs when OnInitialised returns
    [2020/11/27 06:24:56.53990] (Log): Already recorded transaction kajejaopenek.... (<transactionID>) <= comes in a few milliseconds later.

    To work around this, I've installed a coroutine for 0.5 seconds in testing to allow for the "Already recorded transaction..." to complete (varies from 0.02ms to 0.34ms) but it would be super nice to not have to hardcode a coroutine especially since we do not know how long it will take the Google Play store to respond when I roll out into production.

    (@MardukCorp do NOT use 2.2.1, it has some other big issues. 2.1.1 does seem like it should work.
    I'm looking to use Google Play Billing Library v3.0.1 so I'm kind of stuck, but I'm not ready to roll into production so I can wait until 2.2.3 comes out...)
     
    Last edited: Dec 6, 2020
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    9,000
    I'm not seeing this behavior with the Sample IAP project when testing on my Samsung Galaxy S7 phone. All my non-consumables have receipts, including those purchases made with a previous IAP version, and the current release. I'm using this project, upgraded to the latest IAP https://forum.unity.com/threads/sample-iap-project.529555/

    Code (CSharp):
    1. public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
    2.     {
    3.         MyDebug("OnInitialized: PASS");
    4.  
    5.         foreach (UnityEngine.Purchasing.Product item in controller.products.all)
    6.         {
    7.  
    8.             if (item.receipt != null)
    9.             {
    10.                 MyDebug("INIT Product=" + item.definition.id.ToString() + ", Receipt=" + item.receipt.ToString());
    11.             }
    12.         }
    13.     }
     
    Tankzo likes this.
  5. Tankzo

    Tankzo

    Joined:
    Jul 16, 2019
    Posts:
    11
    Jeff et al,
    This issue has been resolved with 2.2.3.

    Existing receipts for non-consumables are received on the end device by the time / when OnInitialized() returns.

    Thank you for the fix! <3
     
  6. Tankzo

    Tankzo

    Joined:
    Jul 16, 2019
    Posts:
    11
    Jeff,
    After further testing on api 19, 21, & 27 devices, it looks like it is a timing issue, on older hardware, taking longer to get and process the 'fetch' from the google play store.

    The api 19 & 21 devices (Galaxy s3 & s4) devices were NOT getting the fetch done fast enough (always getting the .HasReceipt being False when run from OnInitialized(). (but after 0.05 seconds to 0.15 seconds, the receipt was there)

    Borrowed an API 27 device (Buddies Pixel) and it got the receipt (.HasReceipt was True) from OnInitialized() using v2.2.2.

    Thank you so much for getting the team working on this as fast as they did. V2.2.3 fixed this issue!
    Greatly appreciate the fix!!
     
Thread Status:
Not open for further replies.
unityunity