Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Purchase failure due transaction

Discussion in 'Unity IAP' started by xcelciorapps, Feb 11, 2020.

  1. xcelciorapps

    xcelciorapps

    Joined:
    Feb 3, 2020
    Posts:
    3
    Hello..
    I'm using codeless IAP.. I've added IAP buttons to purchase consumable products. But after the first purchase (which is successful) onPurchaseComplete fires and all be is well.. but when I try to make another purchase I get an error. DUPLICATE TRANSACTION.
    I'm confused. It's marked as consumable and the consume purchase checkbox is ticked.
    Please help. Thanks
    Using unity 2019.2
    IAP version 1.23.1
     

    Attached Files:

  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  3. xcelciorapps

    xcelciorapps

    Joined:
    Feb 3, 2020
    Posts:
    3
    Thanks for the reply.

    Yes I'm testing on Android.
    Screenshots are attached below

    here's a code being called on purchase of 200 Tokens. all other purchases are similar.
    This fires correctly on first purchase. but fails on subsequent purchases.

    Code (CSharp):
    1. public void buy200TokenComplete()
    2.     {
    3.        
    4.         int oldToken = PlayerPrefs.GetInt("GameCoin");
    5.         int newToken = oldToken + 200;
    6.         PlayerPrefs.SetInt("GameCoin", newToken);
    7.         tokenscoreText.text = newToken.ToString();
    8.         cartScreen.SetActive(false);
    9.         CreateSuccessModal();
    10.     }
     

    Attached Files:

  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    You'll see in the logs "Purchase not correctly processed for product "com.xcelcior.rockpaperscissors.200tokens". Add an active IAPButton to process this purchase, or add an IAPListener to receive any unhandled purchase events." is the IAP button active? It seems that it would have to be, since you clicked on it. At any rate, you might consider adding a Listener. However, I would strongly suggest that you used Scripted IAP and not Codeless, it's much more flexible. There are examples of both here: https://forum.unity.com/threads/sample-iap-project.529555/
     
  5. xcelciorapps

    xcelciorapps

    Joined:
    Feb 3, 2020
    Posts:
    3
    well in all honesty i tried the scripted first but wasn't successful in implementing even after following the documentation and various tutorials. so i decided to try the Codeless and in one shot it worked..... sort of.

    I'll take a look at the script in the sample project and implement.
    Thanks for your swift response.
     
  6. GetLitGames

    GetLitGames

    Joined:
    Sep 24, 2014
    Posts:
    11
    I'm using scripted IAP and I am receiving the same Duplicate Transaction error and I will post a new topic about it.
    We need IAP to return more detailed information about Why it thinks it is a duplicate and why a transaction failed in general.
     
  7. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    No need for a new thread, your issue is still on topic. Are you receiving a ProcessPurchase at IAP Initialization? Please provide the device logs, they will tell. The Sample IAP Project will also let you know in the UI. This is likely the reason for the DuplicateTransaction, the last purchase attempt is left in Pending state. You would want to return Complete from ProcessPurchase. Again, the Sample IAP project has a Toggle button to perform this very test. You can also call ConfirmPendingPurchase with the Product passed to ProcessPurchase . Also, create a new consumable product and confirm that multiple purchases work as expected https://docs.unity3d.com/2017.2/Doc....IStoreController.ConfirmPendingPurchase.html and https://forum.unity.com/threads/how-to-capturing-device-logs-on-android.528680/ and https://docs.unity3d.com/Manual/UnityIAPGoogleConfiguration.html
     
    Last edited: Apr 7, 2020
  8. twice7713

    twice7713

    Joined:
    Apr 24, 2018
    Posts:
    24
    I am receiving the same Duplicate Transaction issue ,Product Type is Consumable.
    Using codeless IAP.
    IAP Version1.23.1
    In App Purchasing Version: 2.0.6
    Unity Version :2019.3.3f1
     
    Last edited: Aug 20, 2020
  9. twice7713

    twice7713

    Joined:
    Apr 24, 2018
    Posts:
    24
    Step1.Remove In App Purchasing and IAP
    Step2.Unity Editor>Window>Generl>Service>IN-APP PURCHASING
    Step3.Simplify cross-platform IAP to close and Open
    Step4.Click Reimport
    Step5.Unity Editor>Window>Unity IAP>IAP Update
    solve it!
     
  10. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    What do you mean by Step 3? What do you mean by cross-platform in this context, and the term simplify?
     
  11. twice7713

    twice7713

    Joined:
    Apr 24, 2018
    Posts:
    24
     

    Attached Files:

  12. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Got it, you meant "Enable IAP"
     
    i4mtheone and twice7713 like this.