Search Unity

Unity IAP trying to validate purchases that have been correctly closed

Discussion in 'Unity IAP' started by ncortesp, Sep 16, 2020.

  1. ncortesp

    ncortesp

    Joined:
    Oct 28, 2016
    Posts:
    42
    Hi community,

    I'm a bit worried about something that is happening in our applications, maybe It's not something that may not occur with end users but...

    First of all, we have faced the following issues with an Android Developer test account, that we think that is corrupted.

    What we are experiencing is that some in-app purchases from that developer account are trying to be closed in another product.

    I will explain that with an example;

    We have 2 applications, let's call them

    App A
    App B


    I try to purchase a product in App A, something wrong happens, both GooglePlay and our Backend have marked that purchase as successfully, the test user "has been charged" and rewarded for that purchase, but by the other hand, that purchase looks like it's still opened for the IAP.

    The problem does not end here, because now we move to App B, and we try to purchase one product there. Note: The product from App B has a different SKU from the product we purchased from App A
    When we try to purchase this new product, the IAP tries to close the purchase we did on App A.

    Note: We have faced the following issue with a test user, but I would like to know if this situation could happen with end users.

    As I said, I don't know if this is something that could happen to us with end users. We could just reproduce it with one test user, which I think that is corrupted, but I just wanted to know if this situation has been noticed before, if so, is there any way to unlock this situation?

    May we create another test account and forget this one?

    PD: Every input related to this issue will be welcome.

    Greetings,
    Nacho.
     
  2. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    626
    "I try to purchase a product in App A, something wrong happens, both GooglePlay and our Backend have marked that purchase as successfully, the test user "has been charged" and rewarded for that purchase, but by the other hand, that purchase looks like it's still opened for the IAP."

    What do you mean by "still opened for the IAP"? Do you mean that after the purchase is successful, users can still buy it again?
     
  3. ncortesp

    ncortesp

    Joined:
    Oct 28, 2016
    Posts:
    42
    Nope, It looks like that purchase appears as a Pending purchase for the IAP plugin, but both our Backend and GooglePlay (in this case) show it as Validated.
     
  4. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    626
    For pending purchase, if the purchase is completed, developer should return "PurchaseProcessingResult.Complete" in the "ProcessPurchase" method. Could you confirm you have already done this? Thanks.
     
  5. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Can you elaborate what you mean "tries to close". An app can only process transactions if it's running. If an app has purchases left in Pending, then ProcessPurchase would be expected to trigger on next app launch. Please provide specific steps to reproduce along with the filtered device logs
     
  6. JustAnotherDude

    JustAnotherDude

    Joined:
    Oct 28, 2013
    Posts:
    279
    Yeah I'm also getting this behaviour...

    Not exactly the same as OP though, but closing the app when a purchase is made now gives me some errors which might be related to how unity now attempts to recover from errors.

    I had version 1.23.1 of the Unity IAP, after I updated I started getting unexpected behaviour, I believe related to this:


    Code (CSharp):
    1. ## [1.23.2] - 2020-06-17
    2. ### Added
    3. - GooglePlay - Improves the chance of successfully purchasing a Consumable or NonConsumable when the _purchase flow_ is interrupted. Also addresses the dialog, "Your order is still being processed".
    4.    - Unity IAP will now detect this _purchasing_ failure. It will call the `IStoreListener.OnPurchaseFailed` API, initially. Then it will query Google Play for purchase success during the current app session until network is restored, and it will continue querying in the next app session, after a restart. It will finally call the `IStoreListener.ProcessPurchase` API if it finds a successful, unaccounted purchase.
    5.    - Addresses the case where (1) a consumable or nonconsumable purchase flow is started and (2) a network disruption occurs, or the app is sent to the background and the purchasing Activity is canceled, or the app is terminated.
    6. - GooglePlay - Improves the chance of successfully repurchasing a Consumable whose successful transaction failed however to be _completed_ during the current app session.
    7.    - Unity IAP will now detect this _consumption_ failure. It will automatically retry completing the purchase until it succeeds. Note that `DuplicateTransaction` may still be reported while the retry is ongoing, until the user's product is repurchasable again. See below for new APIs to monitor the consumption flow.
    Any way to disable this? From what I understand the app attempts a purchase automatically later? That's not something I think I want to happen...
     
  7. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please be specific. What behavior are you seeing? I believe you will want this behavior. Without it, users are charged on their credit card but don't receive the product (ProcessPurchase isn't fired)
     
  8. JustAnotherDude

    JustAnotherDude

    Joined:
    Oct 28, 2013
    Posts:
    279
    I see, I will need to test further.

    Is the IAP now firing 2 callbacks? It first fails the purchase and then at any point we have a success?

    (Sorry for derailing the thread, I guess it might not be 100% related with op, should I create a new one later? I will need more time to test this change.)
     
  9. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @JustAnotherDude No, a single purchase should never fire two callbacks. If it is, it would be high priority bug. You'll also want to test cancelling the purchase when you have the purchase dialog up and ensure that only PurchaseFailed is called. Then restart the app, and ensure that ProcessPurchase isn't fired. So you'll want to put Debug.Log statements in your callbacks to confirm, they will show in the device logs. If you see any of these behaviors, please speak up right away! And provide the device logs to confirm.
     
    Last edited: Sep 24, 2020
  10. JustAnotherDude

    JustAnotherDude

    Joined:
    Oct 28, 2013
    Posts:
    279
    Sorry for the massive delay, I'm finally trying to update this again, and I found some logs which appears to be the issue:

    This was from a single execution of the game, you can see by the timing that these callbacks were called twice:

    It printed this:
    2020/10/16 10:49:15.767 8946 9365 Info UnityIAP Billing Service Manager invoking callback 1 of 1

    A few milliseconds later:
    2020/10/16 10:49:16.268 8946 9365 Info UnityIAP Billing Service Manager invoking callback 1 of 1

    And my server side validation complained that the same purchase was being attempted twice.

    This only happens when I update the package on the package manager from 2.0.6 to 2.1.1.

    Do you have any idea what it might be?

    Unity IAP is 2.0.0 (I need both Unity IAP 2.0.0 and In App Purchasing packs right?
     
  11. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please provide specific steps to reproduce. Also review the release notes, it discusses the aggressive recover flag, we are continuing to improve this behavior.
     
  12. JustAnotherDude

    JustAnotherDude

    Joined:
    Oct 28, 2013
    Posts:
    279
    I did not yet attempt to reproduce on a new project.

    Steps are:
    1-Start an purchase
    2-Click on 1-tap buy
    3-Immediately close (not minimize) the app
    4-Start app again and notice the callbacks are called twice.

    Is there anything that could trigger those callbacks twice?


    Regarding aggressive recover, I did see on the logs it was set to false.
     
    Last edited: Oct 16, 2020
  13. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Thank you, those are good steps. We've heard of this behavior, callbacks being called twice which is not good. We are continuing to work on this.
     
    JustAnotherDude likes this.
  14. JustAnotherDude

    JustAnotherDude

    Joined:
    Oct 28, 2013
    Posts:
    279
    Any updates on this? Is the bug confirmed to exist?
     
  15. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Yes, we are working on this, no ETA yet
     
    JustAnotherDude likes this.