Search Unity

IsPurchasedProductDeferred issues / questions

Discussion in 'Unity IAP' started by sticksports_bittman, Jun 10, 2021.

  1. sticksports_bittman

    sticksports_bittman

    Joined:
    Apr 4, 2017
    Posts:
    3
    I've been doing some development and testing with Unity IAP lately specifically around deferred/pending payments on Google Play due to it accounting for a decent amount of our active audience.

    In particular, a new function caught my eye in the 3.2.0 update which was the IsPurchasedProductDeferred (changelog) (documentation).

    In testing this appears to not be as robust as I would have liked and was seeking some clarification on how it works.

    Some issues I've noticed:
    1. It appears that it will return true if a purchase is pending no matter what the product passed in is (i.e. if I have 2 consumables, and one is pending, then this function will return true even if I pass in the second consumable).
    2. Perhaps more a google issue (since I've noted a number of mentions of google billing issues with slow purchases in the forums) - but I noticed that if I close and restart the application then the pending check doesn't seem to remain true even if the payment is yet to be returned.
    3. And (what is most likely a google issue according to other threads), the slow purchase decline test card (or slow pending purchases as a whole) appear to never clear a pending result using this function.

    Any information on this function or something I'm missing about how it should work would be great. If any of these are news as far as bugs go, happy to submit a bug report =)
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    I would recommend that you take a look at the Sample IAP Project v2 which uses a deferred listener. If you continue to have issues, please provide detailed steps to reproduce. You can't have two identical consumables in Pending at the same time, I suspect you meant two separate consumable products. Otherwise, please show the code you are using. Also, what is your goal here, what are you trying to accomplish? https://forum.unity.com/threads/sample-iap-project.529555/#post-6950270 . You mention "doesn't seem", can you confirm with consistent steps to reproduce? If a product is in Pending, it should always trigger ProcessPurchase during IAP initialization. Your observations with regard to the method you mention may be true. Once you provide the requested info, I will test here also.
     
  3. StickSports4

    StickSports4

    Joined:
    Jun 15, 2021
    Posts:
    1
    Hey Jeff, thanks for your reply (wasn't able to see your response until today so sorry for leaving this stale for a few days).

    I was building my code on the Sample IAP Project v2 that you mentioned and linked with some minor adjustments in this test. But pointing to some of our own IAP products for testing.

    1. Regarding the consumables - yes I meant two separate consumables. In the sample project I made a quick test where I made two "Gold" buttons let's call them GOLD_1 and GOLD_2 which pointed to different consumable purchases. If you purchase one consumable with a "Slow Test Purchase" to put it into the "pending" state, IsProductPurchaseDeferred will return true regardless of which product you pass in.

    So for example, making a purchase of GOLD_1 results in:
    Code (CSharp):
    1. if(m_GoogleExtensions?.IsProductPurchaseDeferred(GOLD_1))
    will return true, and
    Code (CSharp):
    1. if(m_GoogleExtensions?.IsProductPurchaseDeferred(GOLD_2))
    will return true.

    When I would expect:
    Code (CSharp):
    1. if(m_GoogleExtensions?.IsProductPurchaseDeferred(GOLD_1))
    to return true, and
    Code (CSharp):
    1. if(m_GoogleExtensions?.IsProductPurchaseDeferred(GOLD_2))
    to return false.

    2. On the measure of the goal, I guess this largely relates to our issues with slow purchase cancellations / declines. I have noted that currently many threads have pointed to this being an issue with google but was wondering whether you could at least see if a purchase was currently pending or not. I'm supposing I'm using this wrong in that case, in which case I wonder what a suitable use case for IsProductPurchaseDeferred is? Any examples of how someone might want to use it?

    3. In my tests with the above mentioned code (i.e. the ISProductPurchaseDeferred check), closing and reopening the app appears to never return true even if the product remains pending. However, you did say that Initializing IAP will always trigger ProcessPurchase? What occurs in this event if the product is still pending? Or am I misunderstanding you here?

    Let me know if you want any more information. Thanks again for your time =)
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Sorry I don't follow. During a purchase, there is only one product passed via the arguments in ProcessPurchase. Don't just grab a random product in your controller, use the product passed into ProcessPurchase or the DeferredListener. You can't "test another product". You can't have GOLD_1 and GOLD_2 in the same transaction. The method is only valid the first time at original purchase, subsequently only ProcessPurchase would be expected to trigger. The product would be still in Pending, can you confirm you see ProcessPurchase if the product is in the deferred state? Also, Slow Card with Fail is not expected to work, only the successful flow. How are you testing? You have to be quick, the Slow Card with Success approves it in just a couple of minutes in my experience.