Search Unity

License agreement popup causes UserCancelled in Unity IAP iOS

Discussion in 'Unity IAP' started by simongjelly, Sep 20, 2018.

  1. simongjelly

    simongjelly

    Joined:
    Jun 1, 2015
    Posts:
    7
    We've recently stumbled upon an issue with Unity IAP in our production environment.
    On 17.9.18 a new license agreement was released by Apple, the issue we see is that when the popup is displayed for the player Unity IAP makes the purchase Fail with reason UserCancelled, and later when the player approves the agreement it sends us a success on this purchase.
    Our problem is that when we get the success callback, we've already cancelled said transaction, the result is that players pay money and do not receive anything in return.

    Has anyone else got this issue?
    Is there any way of bypassing this issue?
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    What version of IAP are you using? When you say "sends us a success callback", do you mean on the next app launch, you receive a ProcessPurchase callback when IAP initializes?
     
  3. simongjelly

    simongjelly

    Joined:
    Jun 1, 2015
    Posts:
    7
    The IAP version is 1.19.0.
    No, it's not on initialize, it all happens in the same session, it send cancel when the app focuses out and success when focuses in.
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Sorry, I'm not quite following the purchase flow. Can you list the exact steps to reproduce? Do you use an "Awake" method in your code when the app receives focus? Please provide your purchase script here as an attachment.
     
  5. simongjelly

    simongjelly

    Joined:
    Jun 1, 2015
    Posts:
    7
    It's quite a complex system we've implemented on top of the UnityIAP, so cannot provide scripts for this.

    Steps to reproduce are:
    1. Get a clean user, which did not approve the EULA agreement (which Apple updated on 17.9.2018)
    2. Go into the application and start a purchase
    3. You'll get an EULA popup
    4. Approve it
    5. The transaction is then approved by iOS and returns to the application
    But in the base of it: we've implemented
    IStoreListener
    , we see that in this particular instance, we receive
    OnPurchaseFailed
    when the EULA popup appears with reason
    UserCancelled
    .
    After the purchase is finalized we receive the correct
    ProcessPurchase
    callback.

    Since our logic already cancels the transaction in our logic in the
    OnPurchaseFailed
    , we disregard the correct approval afterwards, thus the flow fails.

    > Do you use an "Awake" method in your code when the app receives focus?
    No, we do not regard the focus events in our purchase flow
     
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Understood. We are improving the UserCancelled logic in the next IAP release due out in a few weeks which should hopefully address this issue.
     
  7. simongjelly

    simongjelly

    Joined:
    Jun 1, 2015
    Posts:
    7
    Can you confirm that the described scenario is buggy on UnityIAP 1.19.0?
     
  8. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    It applies to all currently released versions
     
  9. simongjelly

    simongjelly

    Joined:
    Jun 1, 2015
    Posts:
    7
    Do you have a more concrete release date for the new UnityIAP version release? so we can plan for it
     
  10. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Sorry we do not have a more specific date at this time. My best estimate at this time is 2 weeks, but that can change.
     
  11. unityjingyao

    unityjingyao

    Unity Technologies

    Joined:
    Feb 20, 2017
    Posts:
    220
    Hi @simongjelly ,
    I'm sorry that I couldn't get a clean user to reproduce this issue.
    The Objective-C source code of Unity IAP is 'Assets\Plugins\UnityPurchasing\iOS\UnityPurchasing.m'.
    The code of processing purchases is at around line 400.
    Please set up some breakpoints to debug the code to check if it's called by Apple.
    If both SKPaymentTransactionStateFailed and SKPaymentTransactionStatePurchased are reached for a clean user when buying a product, this should be an expected behavior on Apple side. Unity IAP has no control over this.
    Sorry for the inconvenience.
     
  12. Tommi-Kiviniemi

    Tommi-Kiviniemi

    Joined:
    Aug 21, 2014
    Posts:
    8
    @JeffDUnity3D @unityjingyao

    Has this been fixed?

    Unity IAP should be engineered so that it can't invoke two callbacks for one action, no app will be able to handle both a fail callback AND a success callback.

    Also, the repro steps have been provided and we have also seen this happen for our customers. It should come as no surprise that an EULA prompt can be part of the purchase flow and Unity IAP needs to handle that.
     
  13. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @Tommi-Kiviniemi Agreed! We are looking into this. It's been a bit difficult to reproduce and trigger the EULA prompt on demand.
     
  14. Tommi-Kiviniemi

    Tommi-Kiviniemi

    Joined:
    Aug 21, 2014
    Posts:
    8
    Thanks for looking into this.

    It is very probable that the first purchase a user makes after updated EULAs, and possibly on the first purchase ever for a user (IIRC the EULA is presented at that point also) will be from a Unity app. So there's quite a lot of support cases raised to the developers stemming from this issue I'd imagine.

    Thanks.