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

[Solved] Unity IAP 2.2.2 Duplicate PurchaseEventArg

Discussion in 'Unity IAP' started by LuckyStarr, Nov 24, 2020.

Thread Status:
Not open for further replies.
  1. LuckyStarr

    LuckyStarr

    Joined:
    Feb 6, 2018
    Posts:
    17
    Hey everyone.
    I have a problem with new update sdk. 2.2.2 version fix some bug, but now after successful purchase, in methid PurchaseProcessingResult i recieve two PurchaseEventArg.
    I validate this product by PlayFab, but how fix it?
    Im use return valur PurchaseProcessingResult.Pending, and after Playfab Validation use ConfirmPendingPurchase.
    Some one can say how fix this duplacate events?
     
  2. amjaliks

    amjaliks

    Joined:
    Jul 11, 2015
    Posts:
    157
    Bumping up this one.

    I observed the issue with double callbacks on Android (Google Play) with the lastest package 2.2.1 and the latest plugin 2.2.2.
     
    Tankzo likes this.
  3. JustAnotherDude

    JustAnotherDude

    Joined:
    Oct 28, 2013
    Posts:
    279
    I just attempted to upgrade again yesterday and also noticed the same error.

    PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs e) is definitely getting called twice for a single purchase:

    Code (CSharp):
    1. 2020/11/27 11:39:01.103 25417 25475 Info Unity [IAPManager->ProcessPurchase] Transaction ID=jgaeijbllolnkidogcmellid....
    2.  
    3. 2020/11/27 11:39:02.056 25417 25475 Info Unity [IAPManager->ProcessPurchase] Transaction ID=jgaeijbllolnkidogcmellid....
    4.  
     
  4. JustAnotherDude

    JustAnotherDude

    Joined:
    Oct 28, 2013
    Posts:
    279
    Ok what's happening is that if you return PurchaseProcessingResult.Pending on PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs e) instead of waiting for the next app start as the documentation says it should : https://docs.unity3d.com/Manual/UnityIAPProcessingPurchases.html

    ProcessPurchase is getting immediately called again, probably because when we make a purchase the game loses focus to open the store popup, and then when it gets focus it is recognized as an app start?

    Is this behaviour intended now?
     
  5. max427857

    max427857

    Joined:
    Sep 9, 2020
    Posts:
    8
    probably bug.

    For unity devs:

    iap 2.1.1 (products consumable)-

    Duplicate call ProcessPurchase on Android
    :
    when you click-tap to buy in the system_window and close app immediately. Restart app and after OnInitialized it will call ProcessPurchase twice with same transaction and same product.

    No callbacks (ProcessPurchase, PurchaseFailed) on iOS:
    You should knock out the Internet after a successful purchase (when system_window appear about Successfull), click "ok" in the system_window and exit the game. Restart the game, click on the same product, confirm the purchase and after some timeout, system_window appear "this product has already been purchased", then no further callbacks (ProcessPurchase or PurchaseFailed) from Unity will not called (90% cases).
     
    Last edited: Nov 28, 2020
    JustAnotherDude likes this.
  6. Tankzo

    Tankzo

    Joined:
    Jul 16, 2019
    Posts:
    16
    It happened in 2.2.1 and is still happening in 2.2.2.

    It doesn't appear to be a critical issue because the second purchase fails:


    [2020/11/29 04:09:06.43082] (Log): Purchasing product asychronously: '<product_9>' <=Real purchase
    [2020/11/29 04:09:06.47693] (Log): purchase({0}): <product_9> <=Real purchase success
    [2020/11/29 04:09:31.89720] (Log): ProcessPurchase: PASS. Product: '<product_9>' <=Duplicate purchase
    [2020/11/29 04:09:32.04547] (Log): Already recorded transaction cdinbpefpelhpggoaejahppn.AO-J1OyJ_... <=Real purchase TransactionID
    [2020/11/29 04:09:33.32549] (Log): Already recorded transaction iedgfcfamflgbhcljcclhcnh.AO-J1Oz... <=Duplicate purchase TransactionID
    [2020/11/29 04:09:33.41354] (Log): onPurchaseFailedEvent({0}): <product_9> <=Duplicate purchase
    [2020/11/29 04:09:33.41892] (Log): OnPurchaseFailed: FAIL. Product: '<product_9>', PurchaseFailureReason: Unknown <=Duplicate purchase
     
  7. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Can everyone here confirm if they are returning Pending on the initial purchase? Duplicate ProcessPurchase calls for a single transaction is not expected.
     
  8. JustAnotherDude

    JustAnotherDude

    Joined:
    Oct 28, 2013
    Posts:
    279
    Yes I return pending on the first call, if I return Complete the duplicate call does not happen.

    As I said the issue seems to be:
    1-Purchase is made, API calls ProcessPurchase, we return Pending.
    2-We close the purchase popup from the store
    3-The game detects it as returning to the app and fires ProcessPurchase again (even if you don't quit the app).
     
    Tankzo likes this.
  9. IvanWeeskey

    IvanWeeskey

    Joined:
    Jan 8, 2017
    Posts:
    12
    I cant publish to ppl my app coz of this, wtF?
    Test in on android. Users money are withdrawn and even unity dashboard shows that purchase was sucessful, but no success callback from UNITY.
    On 2.2.1 there was no callback at all.
    On 2.2.2 there is message like "already recorded transaction". And I test it on LIVE CLIENT, got messages from unity logcat. And moreover if user cancels buy action there is AGAIN no failure callback from unity.

    SERIOUSLY GUYS InApps = money and it is what we are doing all of this gaming stuff for. It's END 2020 btw, we are talking about mars but still cant get working inapps LOL
     
    Tankzo likes this.
  10. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Are you seeing the duplicate callbacks when using Pending from ProcessPurchase? That is the issue being discussed here, and it being worked on and should be fixed in an upcoming release.
     
    JustAnotherDude likes this.
  11. amjaliks

    amjaliks

    Joined:
    Jul 11, 2015
    Posts:
    157
    Hi, @JeffDUnity3D!
    Yes, I return
    PurchaseProcessingResult.Pending
    from
    ProcessPurchase
    :
    Code (charp):
    1. public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs e) {
    2.    VerifyPurchase(e);
    3.    return PurchaseProcessingResult.Pending;
    4. }
    VerifyPurchase
    performs async purchase verification via our server. After verification I call
    IStoreController.ConfirmPendingPurchase(e.purchasedProduct)
    .

    Package: 2.2.1
    Plugin: 2.2.3
     
    JeffDUnity3D likes this.
  12. amjaliks

    amjaliks

    Joined:
    Jul 11, 2015
    Posts:
    157
    This affects only Google Play integration. (I didn't try other Android stores.)
    App Store integration works correctly.
     
  13. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Understood, we are working on this.
     
    JustAnotherDude, Tankzo and amjaliks like this.
  14. Buzzrick_Runaway

    Buzzrick_Runaway

    Joined:
    Jan 7, 2018
    Posts:
    15
    We have had to roll back to v2.0.0 because of this issue.

    We are receiving duplicate "ProcessPurchase" calls during a purchase, and an "OnPurchaseFailed" event with a PurchaseFailureReason.Unknown reason. This means that when we make a purchase the user is show both the purchase success and purchase failure notifications in our game.

    On a side note, we also are getting an Unknown reason when legitimately failing a purchase.
     
    Tankzo likes this.
  15. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Yes, please see my previous reply.
     
  16. amjaliks

    amjaliks

    Joined:
    Jul 11, 2015
    Posts:
    157
    This issue is fixed in the latest plugin 2.2.4.
     
Thread Status:
Not open for further replies.