Search Unity

Question IAP initialization

Discussion in 'Game Foundation' started by Sukender_OB, Dec 4, 2020.

  1. Sukender_OB

    Sukender_OB

    Joined:
    Nov 14, 2019
    Posts:
    18
    Hi there!

    I have a doubt about GameFoundation 0.8 initialization.
    Actually I call a GameFoundationSdk.transactions.IsIapProductOwned(someID) on GF initialization (GameFoundationSdk.initialized). But this returns false, whereas my product has already been bought (Android / Google Play). If I defer my call later (in a coroutine 5 sec later, or in Update()), it returns true, as expected.

    So here are my questions : Is this a normal behavior? How can I be sure that GF+IAP have been fully initialized (or how can I be called back)?

    Thanks.

    Cheers,
     
  2. richj_unity

    richj_unity

    Unity Technologies

    Joined:
    Sep 23, 2019
    Posts:
    40
    Hi Sukender_OB,

    Are you referring to just the first time the game loads? Or does this happen each subsequent time the game loads too?

    Normally in a Google Play app, the purchases are restored automatically at startup, but that can take time. Game Foundation initialization does wait for the IAP SDK controller to initialize, but it does not wait for purchases to be restored. So, purchases could finish being restored after initialization.
     
  3. Sukender_OB

    Sukender_OB

    Joined:
    Nov 14, 2019
    Posts:
    18
    Hi richj,

    Thanks for your answer. Yes this is the init of the game. How can I wait for purchases to be restored?

    Moreover, I have issues about refunded+revoked items (they still appear as in the game). Can this be related?

    Thanks again.
     
  4. richj_unity

    richj_unity

    Unity Technologies

    Joined:
    Sep 23, 2019
    Posts:
    40
    The restoration of purchases is separate from the initialization of both Game Foundation and the IAP SDK. For Google Play, it automatically starts when you run the game for the first time. There's no way to reliably predict when the purchases will finish being restored. But you can listen to the the GameFoundationSdk.transactions.purchaseSucceededInIAPSDK event. That event is invoked for each receipt that is successfully restored.

    After a purchase is successfully restored, GameFoundationSdk.transactions.IsIapProductOwned should return the correct result, even after you force quit and restart the game (it's cached to a local file). If that's not happening, then we might have a bug. Please let us know and provide any code or sample project you can.

    Refunds (returns) are not currently supported by Game Foundation, but we are investigating how we may support them.
     
  5. Sukender_OB

    Sukender_OB

    Joined:
    Nov 14, 2019
    Posts:
    18
    Thanks for the reply.
    So in a few words, there's no onIAPFullyRestoredSuccess / onIAPFullyRestoredFailure events (or such). I'll then change my way to handle my UI to take this into account. Thanks.

    FYI, I made an ugly patch, which changes some purchase-related UI buttons status in Update() (urgh!) so that they're grayed out when IAP is restored. And I must admit that it seems te be working with revoked Google Play items (after a delay [minutes; day]). It is also to be noticed that "refunded but non-revoked items" are to be handled carefully (so that GF items are coherent with their IAP counterpart).
     
  6. richj_unity

    richj_unity

    Unity Technologies

    Joined:
    Sep 23, 2019
    Posts:
    40
    This is correct.

    We will take this feedback into account as we continue working on these features. Thank you!
     
    Sukender_OB and erika_d like this.