Search Unity

IAP is called again when application starts again.

Discussion in 'Unity IAP' started by MaxUijlings, Mar 5, 2018.

  1. MaxUijlings

    MaxUijlings

    Joined:
    Mar 5, 2018
    Posts:
    2
    I have integrated the codeless IAP in my project. But when the user purchases the product and then comes back the next time. The On Puchase Complete is called again. I noticed this because when The user makes a purchase we show a dialog saying thanks. Adn when you close the app and open it again that dialog pops back up. This only happens the next time after the purchase. The second and third time when you open the app it doesn't occur. Can anybody tell me if there might be something that I am doing wrong? Should I somehow complete the purchase myself?

    Kind Regards,

    Max
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @MaxUijlings This would be unexpected behavior. What version of Unity and IAP are you using? What type of product, and is this on iOS or Android?
     
  3. MaxUijlings

    MaxUijlings

    Joined:
    Mar 5, 2018
    Posts:
    2
    I am using Unity 5.6.4f1 and IAP version 1.17.0 And we are building to iOS And the type of product is a non-consumable
     
  4. Benvictus

    Benvictus

    Joined:
    Sep 12, 2013
    Posts:
    87
    Hi @MaxUijlings

    I'm looking into this for you now, I'm going to attempt to recreate the issue and see if this has a nice workaround or easy fix. I'll get back the moment I know more.
     
  5. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  6. vectormonk

    vectormonk

    Joined:
    Jan 26, 2017
    Posts:
    2
    Did you manage how to fix that?

    Same issue, Unity 2017.4.1f1, IAP 1.18.0, iOS 11.3
    It reproduces in TestFlight and Cloud build also.
    Also, reproduced on other iOS device with same Apple ID account

    It happens for 1 of our 3 consumable purchases.
    Steps for reproduce - I installed the game, open shop, once prices are fetched up and shown - I see animation of coins added to my coin counter (same behavior as I've completed in-app)
     
  7. gtzpower

    gtzpower

    Joined:
    Jan 23, 2011
    Posts:
    318
    I was having an issue as well where the purchase was being fulfilled every time the IAP was initialized (so its a little different, but maybe something similar is going on). Make sure you "Consume" the purchase, even though it is not a "consumable" purchase. This does not consume the purchase in the sense that it is available again (as Google Play uses the term "Consume"), instead, this finishes the transaction and it should stop appearing on initialization.

    In my case, I needed to check the "Consume" box on the IAP button.
    https://forum.unity.com/threads/closed-how-should-codeless-iap-restore-work.522234/#post-3435487

    Hope it helps
     
  8. unityjingyao

    unityjingyao

    Unity Technologies

    Joined:
    Feb 20, 2017
    Posts:
    220
    Hi @gtzpower , thank you for your suggestion!

    Hi @MaxUijlings ,@vectormonk ,
    Please use a try-catch to wrap everything in ProcessPurhcase()/OnPuchaseComplete() and make sure PurchaseProcessingResult.Complete will be returned after the produce is unlocked successfully.
    Otherwise, the transaction wouldn't be finished. Then ProcessPurhcase()/OnPuchaseComplete() would be called again.
     
  9. soranhanmul

    soranhanmul

    Joined:
    Aug 21, 2017
    Posts:
    6
    I got same problem ( customer purchased only once, but ProcessPurchase() works 1~3 times more. so customer got item again and again ) on 5.6.3p4?. and for several reasons, now I change to 5.6.5f1..
    I add try- catch , and check db before I give customer items... But I'm afraid that happens again.
    I couldn't get same problem on my test..
     
  10. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,519
    @soranhanmul

    Did you make sure to check the "Consume Purchase" checkbox on the IAP Button:
    https://forum.unity.com/threads/closed-how-should-codeless-iap-restore-work.522234/#post-3435487

    You will need to do this for all types of purchases (consumable, non-consumable, and subscription) if you are not using server-side validation. This will mark the transaction as Complete and the Purchasing system will no longer keep track of it.

    If you are using server-side validation, then you can leave the box unchecked and you can call ConfirmPendingPurchase when the transaction has been validated.
     
    jadynut likes this.