Search Unity

Unity IAP payment interface won't appear

Discussion in 'Unity IAP' started by bfwbbrj199602, Apr 2, 2020.

  1. bfwbbrj199602

    bfwbbrj199602

    Joined:
    Apr 2, 2020
    Posts:
    3
    Hi, I'm currently trying to use google play in-app billing in my project. Now there's a tricky problem. I clicked the button to open the payment interface and switched the app
    to background before the payment interface appears, then when I reopen the app, the payment interface didn't appear and won't appear anymore unless I reboot the app. I did some research and found that it might be related to the following piece of code
    Code (JavaScript):
    1.  public void Purchase(ProductDefinition product, String developerPayload) {
    2.     if (this.purchaseInProgress) {
    3.       PurchaseFailureDescription description = new PurchaseFailureDescription(product.storeSpecificId, PurchaseFailureReason.ExistingPurchasePending);
    4.       this.unityPurchasing.OnPurchaseFailed(description);
    5.       return;
    6.     }
    Seems I'm still in the purchase progress so the interface won't appear anymore and because the interface never appeared, I can only reboot the app to solve this problem. Is there any workaround to this issue? or Am I doing something wrong?
     
  2. JeffDUnity3D

    JeffDUnity3D

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

    bfwbbrj199602

    Joined:
    Apr 2, 2020
    Posts:
    3
    Unfortunately this isn't my code, it's the code from the com.unity.purchasing.googleplay.GooglePlayPurchasing. And the cause of the problem is that once I switch to background before the payment interface appears, the purchaseInProgress will be set to true forever and I'm not allowed to start another transaction while the previous one is still in progress. I cannot change this piece of code because it's inside the googleplay sdk that unity provides. Also, there's not much useful information in the device log. Let me know if you need any additional information!
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Understood. We will attempt to test here as time allows. Can you repro with the Sample IAP project here? https://forum.unity.com/threads/sample-iap-project.529555/
     
  5. bolegames

    bolegames

    Joined:
    Jan 21, 2020
    Posts:
    1
    any solutions?
    I face the same problem
     
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Does it work as expected if you don't change focus? Are you testing with the Sample project?
     
  7. michaelkane

    michaelkane

    Joined:
    Oct 26, 2016
    Posts:
    4
    I'm getting the same issue as well, when looking into the code, when coming back to the app the initiated purchase never finishes, but when I try to initialize a new one I get a failure and I'm unable to get the app to stop getting this failure for all subsequent purchases until the user restarts the app.

    Error:OnPurchaseFailed: FAIL. Product: ‘xxxxxxxxx’, PurchaseFailureReason: ExistingPurchasePending

    I've attempted to confirm the pending purchase by saving the Product I initiated the purchase through and trying to void ConfirmPendingPurchase(Product product) method in the IStoreController, when the app resumes focus but I get this error:

    Log:Unable to confirm purchase; Product has missing or empty transactionID.

    Basically if I background the app while starting the Google Play purchase process I'm pretty much stuck from doing anything purchase related afterward.
     
    Last edited: Jun 12, 2020
  8. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    @michaelkane Thank you for the update, I will let the team know
     
  9. Fee_Xue

    Fee_Xue

    Joined:
    Dec 13, 2017
    Posts:
    7
    Hi, @JeffDUnity3D is there any solution about this issue. I meet some problem. Tried two ways:

    IStoreController.ConfirmPendingPurchase(Product product) method

    and

    IGooglePlayStoreExtensions.FinishAdditionalTransaction(string productId, string transactionId)

    both of the solutions are not working.
    I am using com.google.play.billing 3.0.0
     
    Last edited: Aug 24, 2020
  10. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Please confirm that you are seeing the same issue discussed in this thread regarding focus. Does it work correctly when you don't switch focus?
     
  11. Fee_Xue

    Fee_Xue

    Joined:
    Dec 13, 2017
    Posts:
    7
    yes, same issue. It works as expected if I don't switch focus. But if the google native payment popup shown, at this time I switch app to background, and then press App icon to go back to App, the native payment popup would disappear and previous purchase is always in pending. So I can not purchase anymore in current session because it has error "PurchaseFailureReason: ExistingPurchasePending".
     
    JeffDUnity3D likes this.
  12. krzysztofbury

    krzysztofbury

    Joined:
    Aug 9, 2018
    Posts:
    1
    Hi, any update on this topic? I have the same issue.

    I am using com.google.play.billing 3.0.2

    You have to:
    1. start payment, wait for google payment interface
    2. switch app or put it in the backgroud
    3. reopen BUT by clicking application icon, NOT from "Recently Used Apps"

    after application opens the google payment interface isn't visible but
    "void OnPurchaseFailed(Product i, PurchaseFailureReason p);" wasn't called

    when I was using only UnityEngine.Purchasing everything was working fine, looks like `com.google.play.billing 3.0.2` is not working correctly but it's needed for subscriptions


    Maybe problem is on google side, star this:
    https://issuetracker.google.com/issues/167918676
     
    Last edited: Sep 7, 2020
  13. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    As stated previously, we have already identified the issue. FYI you don't need to reopen by clicking the app icon, right? It's already open, just in the background. But the issue remains, we are looking into it.
     
  14. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Can you test with IAP 2.0?