Search Unity

Unity IAP IOS 14 Returns DuplicateTransaction error on ConfirmPendingTransaction call

Discussion in 'Unity IAP' started by unity_O932UG816LUlgw, Sep 27, 2020.

  1. unity_O932UG816LUlgw

    unity_O932UG816LUlgw

    Joined:
    Sep 27, 2020
    Posts:
    1
    Hi,
    After ios 14 was released we started see increase in errors DuplicateTransaction.
    Out Current flow is
    1. InitiatePurchase

    2. On ProcessPurchase return Pending and send call to our server

    3. On server response call ConfirmPendingTransaction

    After last step we’re getting OnPurchaseFailed callback with reason DuplicateTransaction.

    We spent time to research and found that if on second step return Completed for ProcessPurchase all works fine.

    Bug happened only on ios14. Sometimes on first purchase, sometimes on 2d,3d etc. After this error user cant buy this item anymore and gets always this error. Easily reproduced if to buy the same item several times

    Unity 2019.2.20f1
    Iap 2.0.6
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    IAP 2.0.6 is the Package Manager version, IAP requires both an Asset and Package Manager component. Can you update to IAP 2.0 from the Services window? Does this only affect iOS 14?
     
  3. dima_nikishyn

    dima_nikishyn

    Joined:
    May 2, 2019
    Posts:
    8
    Both are updated, the issue happens only on IOS 14 when we go by
    Saving purchases to the cloud flow
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please confirm which version you are using, please provide a screenshot when browsing to menu Window/Unity IAP/IAP Updates. Can you provide specific steps to reproduce? I'm not clear why you would receive DuplicateTransaction if this was the first purchase for a user.
     
  5. dima_nikishyn

    dima_nikishyn

    Joined:
    May 2, 2019
    Posts:
    8
    As you can see on screenshot all is updated.
    Unity version is 2019.2.20f1

    Steps:
    Purchase several times (3-6)t he same product using Saving purchases to the cloud flow on ios 14 in one app launch. After calling ClosePendingTransaction you should get onPurchaseFailed callback with reason DuplicateTransaction.
    We tried Completing purchases immediately flow - all work fine.
     

    Attached Files:

  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please show the screenshot of the menu as requested. You are showing the Package Manager version information. I don't have a "Saving purchases to the cloud" flow here to use, sorry. Please use the Sample IAP Project and provide details for someone else to reproduce
     
    Last edited: Sep 28, 2020
  7. dima_nikishyn

    dima_nikishyn

    Joined:
    May 2, 2019
    Posts:
    8
     

    Attached Files:

    unity_4hZxgxER093wpg likes this.
  8. BOLDCAT

    BOLDCAT

    Joined:
    May 28, 2015
    Posts:
    10
    Hello Jeff!
    Same problem with Sample IAP Project.
    I inserted my ID. I can only buy once, but when I buy it again, I get an error.
    iPad (iOS 14). IAP 2.0.0
     

    Attached Files:

  9. winny_lee

    winny_lee

    Joined:
    Aug 28, 2020
    Posts:
    1
    I had the same problem. It only occurs in iOS 14, but it works the same for IAP 2.0.6 as well as higher versions. In my case, from what I've confirmed, it's not because of the ConfirmPendingTransaction() call, but because of the FetchAdditioinalProduct() that is called to update the product's metadata immediately after that.
    1. Duplcate Transaction Issue occurs only when FetchAdditioinalProduct() is called immediately after ConfirmPendingPurchase()
    2. If you only call FetchAdditioinalProduct() without calling `ConfirmPendingPurchase()`, no error occurs.
    3. If you call FetchAdditioinalProduct() after giving a delay of 2 seconds or more immediately after ConfirmPendingPurchase(), no error occurs.
    4. When OnPurchaseFailed() with Duplicate Transaction is called, logging the product's transaction ID confirms that it is empty.
     
    Last edited: Sep 29, 2020
  10. dima_nikishyn

    dima_nikishyn

    Joined:
    May 2, 2019
    Posts:
    8
    Agree with you. We have the same issue
     
  11. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    You can only purchase a non-consumable once, the error is expected.
     
  12. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Why are you calling FetchAdditionalProducts? Some users are calling it not actually fetch more products, but in an effort to refresh the receipts.
     
  13. dima_nikishyn

    dima_nikishyn

    Joined:
    May 2, 2019
    Posts:
    8
    After user purchase we're refreshing store, to show new products, and we need to call FetchAdditionalProducts
     
  14. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    So you're not actually fetching additional products? What do you mean, "refreshing the store". If there is a bug in other areas, you should not need to make this call just to update receipts. I'm trying to determine where the issue is.
     
  15. dima_nikishyn

    dima_nikishyn

    Joined:
    May 2, 2019
    Posts:
    8
    The flow is
    The Flow is
    1. User buy product
    2. We're getting new list of products for user. To give him ability to buy them we need to call FetchAdditionalProducts in order to get metadata of new products.
    3. Why we're doing it with together with ConfirmPendingPurchase ? Once User finish his purchase we do two things close prev purchase and get metadata for new products as winny_lee if to put delay 2-3 sec on ConfirmPendingPurchase and only after it call FetchAdditionalProducts - all work fine. And again we're facing it only on ios 14
     
  16. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Why are you doing 2 above? Why not just load them up during IAP Initialization to save time and bandwidth? What new products? There should be no need to wait 2-3 seconds, I'm trying to determine the underlying issue here. You are covering it up.
     
  17. dima_nikishyn

    dima_nikishyn

    Joined:
    May 2, 2019
    Posts:
    8
    List of items we're selilng is generic, we can't init them all on app start. The question is why it works on all ios versions and on ios 14 doesn't work.
     
  18. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Got it, makes sense. And good question, seems to be an Apple issue that we will need to test, confirm and account for.
     
  19. dima_nikishyn

    dima_nikishyn

    Joined:
    May 2, 2019
    Posts:
    8
    Hi, Do you have any updates regarding this issue?
     
  20. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    The next IAP release should be available this week, please test with the latest version.