Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Google Play UserCancelled returned although purchase was successful

Discussion in 'Unity IAP' started by ahal, Aug 4, 2021.

  1. ahal

    ahal

    Joined:
    Jun 6, 2014
    Posts:
    18
    • Description of your issue
      • Initiate a consumable purchase on Google Play
      • Press the X button or tap off of the native payment dialog window and rapidly press the "1-tap buy" button at the same time.
      • Notice that OnPurchaseFailed was called with the UserCancelled status
      • Attempt to purchase the same consumable product
      • Notice that you receive the native payment dialog error window that states "You already own this item."
      • Notice that OnPurchaseFailed was called with the DuplicateTransaction status and continues to do so until restarting the app.
    • Unity Version
      • 2019.4.28f1
    • Unity IAP version
      • 3.2.3
    Notes:
    - Restarting the app does trigger ProcessPurchase as expected
    - We've seen this similar behaviour in production and this was an attempt to reproduce the problem

    We would be interested to hear if there are any workarounds for these situations where DuplicateTransaction occurs aside from restarting the app. In our logs, we often are able to see that the product in the failure callback does have a transaction id and receipt available.
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    We would need to check this scenario, you may be correct. In the meantime, since you can see the receipt and transactionID in the failure callback, can you disable the purchase button and/or award the product? Granted far from ideal. Can you try with IAP 4.0.0? I would not necessarily expect any difference, but something to check. And are you sure in Production that you aren't seeing deferred purchases? They behave a bit like you are describing.
     
  3. ahal

    ahal

    Joined:
    Jun 6, 2014
    Posts:
    18
    Thanks for the reply and suggestions.

    I was considering attempting to manually validate the purchase in the failure callback since we do sometimes have access to the transaction id/receipt. It seemed a bit unorthodox of course if there was some underlying problem causing the issue but I will explore that as a workaround!

    We are confident that these are not deferred purchases. We have logging in place for the deferred purchase callback and it is not occurring in these cases. We do see other deferred purchases happening as expected.

    I will definitely attempt to reproduce with Unity IAP 4.0.0 and update the thread.
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Got it, thanks for the update and keep us updated.
     
  5. ahal

    ahal

    Joined:
    Jun 6, 2014
    Posts:
    18
    I have just tested with Unity IAP 4.0.0 and I was able to reproduce using the same steps that were outlined in the original post.
     
    JeffDUnity3D likes this.
  6. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    We will check. If we are able to identify the issue and are able to address it, you might expect an update in an upcoming release. If we find a work around in the meantime, I will post it here.
     
  7. ahal

    ahal

    Joined:
    Jun 6, 2014
    Posts:
    18
    Thanks for looking into it!
     
  8. Venzel

    Venzel

    Joined:
    May 7, 2018
    Posts:
    19
    @JeffDUnity3D, hello! Have a quite similar problem on Android with IAP plugin 3.2.3.

    1) Start purchase process on Android device
    2) On native "purchase processing..." popup hide application (switch to background mode) but not close
    3) Successful debiting money from the user's account
    4) Expand application from background
    5) IAP plugin get callback from native code without purchases list and with code result "USER_CANCELED"
    (UnityEngine.Purchasing.GooglePurchaseUpdatedListener.onPurchasesUpdated())
    6) After that plugin goes through failed purchase scenario

    The result: user spends money, but does not receive anything
    Case's ticket: 1356675_l4603cknhev49f5g
     
  9. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    How are you "expanding the application from background". For example, clicking on the icon again will do it, and that scenario should be working. Please show the purchasing code you are using (if different from the Sample IAP Project v2)