Search Unity

  1. Calling all beginners! Join the FPS Beginners Mods Challenge until December 13.
    Dismiss Notice
  2. It's Cyber Week at the Asset Store!
    Dismiss Notice

Unity IAP 1.23.1 "DuplicateTransaction for Consumables"

Discussion in 'Unity IAP' started by VoxelMatt, Nov 27, 2019.

  1. VoxelMatt

    VoxelMatt

    Joined:
    Apr 22, 2015
    Posts:
    7
    Hi Unity - The Unity IAP update 1.23.1 states:

    "developers may choose to handle the `PurchaseFailureReason.DuplicateTransaction` for a ProductType.Consumable by rewarding the user with the product, and presuming that Unity IAP will automatically complete the transaction"
    I was hoping someone could help explain this further to me? Should we reward the user in this situation or not?

    Many thanks :)

    - Matt
     
    justtime likes this.
  2. VoxelMatt

    VoxelMatt

    Joined:
    Apr 22, 2015
    Posts:
    7
  3. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    6,094
  4. sssssspirit

    sssssspirit

    Joined:
    Monday
    Posts:
    7
    @JeffDUnity3D
    Please help me.
    we should reward user when `PurchaseFailureReason.DuplicateTransaction` for a ProductType.Consumable.
    Is this mean the
    Product info from OnPurchaseFailed would be with a valid receipt?

    or how do i reproduce the issue about "GooglePlay - Fix offline purchases inconsistently generating OnPurchaseFailed callbacks".
    Thank you.
     
  5. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    6,094
    Have you checked the receipt? What issue are you trying to solve? You can attempt to reproduce by attempting to make purchases without the internet.
     
  6. sssssspirit

    sssssspirit

    Joined:
    Monday
    Posts:
    7
    Thanks for your reply.
    What i want to know is how to modify my code base on the update about "`PurchaseFailureReason.DuplicateTransaction` for a ProductType.Consumable"
    my code is following this flow: (from IAP document)
    upload_2019-12-3_9-56-6.png
     
  7. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    6,094
    You would want to catch this in OnPurchaseFailed. This is for an offline error condition. You can also reproduce by returning Pending from ProcessPurchase for a Consumable, and then attempt to purchase it again with the previous purchase still in Pending. The Sample IAP here allows you to test this https://forum.unity.com/threads/sample-iap-project.529555/
     
  8. sssssspirit

    sssssspirit

    Joined:
    Monday
    Posts:
    7
    thanks a lot.
    FYI, i have reproduced the DuplicateTransaction.
    and i got the receipt in OnPurchaseFailed. but here is some questions base on the flow:
    we reward user after step 7, and the step 9 not finish.
    then user attempt to purchase again. then we got a DuplicateTransaction error with last receipt. we did't need reward user. because we already reward user before.
    so we need check the receipt is duplicate or not in OnPurchaseFailed, is this right?

    or, am i misunderstand the "offline" ?
    is this error only appear when use "Completing purchases immediately"?
     
    Last edited: Dec 3, 2019 at 5:41 AM
  9. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    6,094
    How did you reproduce? Why did you "reward the user before" if the transaction didn't finish?
     
  10. sssssspirit

    sssssspirit

    Joined:
    Monday
    Posts:
    7
    Thanks for your patients.

    1. i have reproduced by : return Pending from ProcessPurchase for a Consumable, then before ConfirmPending, purchase the product again.
    2. actually, "reward user" happend in the server. after step 6.

    what make me confused is the content in release note:
    "developers may choose to handle the `PurchaseFailureReason.DuplicateTransaction` for a ProductType.Consumable by rewarding the user with the product, and presuming that Unity IAP will automatically complete the transaction"
    if i follow the release note. i need reward user when get the DuplicateTransaction error, this is what i thought incorrect.
    so i am confused.
     
  11. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    6,094
    It's a rare occurrence and not something we have direct control over. So if you get DuplicateTransaction, you might consider awarding the user the product, to be safe.
     
  12. sssssspirit

    sssssspirit

    Joined:
    Monday
    Posts:
    7
    Thanks for you information.
    we will make more tests on this.