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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

IAP prompts DuplicateTransaction

Discussion in 'Unity IAP' started by liwenchao4413, Apr 22, 2021.

  1. liwenchao4413

    liwenchao4413

    Joined:
    Apr 15, 2021
    Posts:
    11
    Unity 2019.4.12f1
    IAP 2.1.1
    iOS phone

    The ios account is in the subscription period, but the user has cancelled the subscription. Try to purchase the subscription again, iOS prompts that the purchase is successful, but IAP prompts DuplicateTransaction

    After that, I restarted the application. After IAP initialization was completed, I received a prompt that IAP resumed the purchase and was successful. Because I am using a sandbox test environment, I am not sure if the previous subscription period has expired.

    I now want to know how the client should operate when IAP prompts DuplicateTransaction, or how to avoid this situation?

    Thank very much
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    @liwenchao4413 Please provide specific steps to reproduce, and I would suggest that you use IAP 3.1.0. Can you confirm that it is truly cancelled? A good test is to perform the iOS Restore. If it is cancelled, it won't show up in the ProcessPurchase call during restore. Also, please compare to the code from the Sample IAP Project (which does not experience this issue) https://forum.unity.com/threads/sample-iap-project.529555/#post-6950270
     
  3. liwenchao4413

    liwenchao4413

    Joined:
    Apr 15, 2021
    Posts:
    11
    First,The user purchased a continuous renewal product for appB on the iOS account userA

    Second,The user canceled the continuous renewal before the renewal time was reached

    Then,The user purchases a continuous renewal again (via the subscription button in the app)

    iOS prompts that the purchase is successful, but IAP prompts DuplicateTransaction
     
  4. liwenchao4413

    liwenchao4413

    Joined:
    Apr 15, 2021
    Posts:
    11
    I still get the same error after updating
     
  5. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please do the restore test as mentioned, and provide the logs
     
  6. liwenchao4413

    liwenchao4413

    Joined:
    Apr 15, 2021
    Posts:
    11
    @JeffDUnity3D
    Sorry, I can only see error log 'DuplicateTransaction' form function
    Code (CSharp):
    1. public void OnPurchaseFailed(Product product, PurchaseFailureReason reason)
    in my class
    Code (CSharp):
    1. public class MyStoreListener : IStoreListener
    I use iOS14.5, I can cancel the subscription in the Setting->App Store->SANDBOX ACCOUNT->Manage, and then use another game account in the app to purchase subscription products. You can see this error message. I hope you can reproduce it and help explain the problem.

    Thank you very much
     
    Last edited: Apr 26, 2021
  7. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    @liwenchao4413 Sorry I don't follow your steps to reproduce, I don't see the error. You mention you use another game account to purchase, does that work? Please provide the specific list of steps to reproduce. Does it work if you don't cancel the subscription? Let's get the basics working first.
     
  8. liwenchao4413

    liwenchao4413

    Joined:
    Apr 15, 2021
    Posts:
    11
    use another game account means have to use IAP function 'InitiatePurchase' to purchase product.Not resume purchase.

    If I do not cancel the subscription, iOS will not call up the payment process.
    iOS will prompt me that I have already purchased this subscription

    If you still have not reproduced it, please provide the specific steps of your operation and explain the results of each step.

    Thank you very much
     
  9. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Sorry I haven't reproduced so I don't have steps. So you're not using another game account (email address)? Using another game account does not relate to InitiatePurchase. How can you cancel a subscription if the user was not able to purchase in the first place? You mention "iOS will not call up the payment process". With this in mind, please update your steps to reproduce, thanks.
     
  10. liwenchao4413

    liwenchao4413

    Joined:
    Apr 15, 2021
    Posts:
    11
    @JeffDUnity3D
    Sorry for not responding in time in recent days
    But, I think the steps I provided before are already very clear. I checked my steps again and I think there is nothing to add.

    The following steps use the same sandbox account and the same app.All payments are for continuously renewing products purchased.
    First,The user purchased a continuous renewal subscription product for an app use sandbox count.
    Second,The user canceled the continuous renewal subscription( in the Setting->App Store->SANDBOX ACCOUNT->Manage on iOS14.5) before the renewal time was reached
    Then,The user purchases a continuous renewal subscription again(via the subscription button in the app), At this time the app is still within the subscription period

    iOS will evoke the payment interface,then iOS prompts that the purchase is successful, but IAP prompts DuplicateTransaction

    For me, There will be problems with my steps.
    Do you mean that did not operate my steps or did not pass my steps to reach a conclusion?

    If you use the made with Unity app installed on your iOS phone through my steps or through the steps you understand, then there must be steps for you to operate. For example, use Unity2019.4.12f1, IAP3.1.0 to build an iOS application, and then purchase continuous subscription products through the purchase button in the application, and then cancel the subscription in the iOS settings, and then...
    I just want to use the steps you have implemented to confirm what deviations have occurred in the steps I described

    For me, I have to use another game account to see the purchase button in my app, because I used the first game account to purchase a subscription, and the subscription has not expired, so there will be no purchase button in the app.
    As long as you can purchase subscription products again through the app, you can ignore using another game account.

    I hope you must follow my steps to reproduce the problem I encountered.
    This question is very critical for us, it determines whether we can get revenue through subscription. Also determines the robustness of Unity payment.

    Thank you very much
     
  11. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    @liwenchao4413 Can you please do the Restore test after you cancel the subscription? If the suggestion is not clear, please ask. If you see a ProcessPurchase during Restore, they still have a subscription. If a user cancels a subscription, it seems that they would have access to the subscription until the end of their current period, since they have already paid for it. The Restore test would confirm.
     
    Last edited: Apr 29, 2021
  12. liwenchao4413

    liwenchao4413

    Joined:
    Apr 15, 2021
    Posts:
    11
    @JeffDUnity3D
    For developers, I can clearly see the Restore purchase recommendations on the iOS and IAP documents.
    But our designer does not consider adding a Restore purchase button on our app.
    Even if we add the button to Restore purchase, if the user cancels the subscription and switches the game account, there is no subscription information on the game account, but the user forgets that he has subscribed to this application or operated by the user’s family, and the user tries to purchase the subscription product again. Because IAP’s error callbacks have caused us to give users a very bad experience.
    For our testers, they try all possible payment methods as much as possible, but we do not consider the possible operations of this kind of users. As developers, we are extremely irresponsible to the testers and users.

    Therefore, it is not recommended for this, but the user can trigger the operation. Is the DuplicateTransaction returned by IAP correct? Or you are still struggling to restore purchase?

    Fear that you will forget the steps to reproduce again

    The following steps use the same sandbox account and the same app.All payments are for continuously renewing products purchased.
    First,The user purchased a continuous renewal subscription product for an app use sandbox count.
    Second,The user canceled the continuous renewal subscription( in the Setting->App Store->SANDBOX ACCOUNT->Manage on iOS14.5) before the renewal time was reached
    Then,The user purchases a continuous renewal subscription again(via the subscription button in the app), At this time the app is still within the subscription period

    iOS will evoke the payment interface,then iOS prompts that the purchase is successful, but IAP prompts DuplicateTransaction

    Thank you very much
     
  13. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    It's a TEST ONLY. Restore on Google happens automatically, Apple requires a Restore button. My descriptions are accurate. If I cancel an online subscription, I still have access to it through the end of the month (or billing cycle). A restore test will confirm.