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

Google Play subscription changes (Account hold, restore)

Discussion in 'Unity IAP' started by seven_, Jul 15, 2020.

  1. sanathkukkillaya

    sanathkukkillaya

    Joined:
    Nov 14, 2019
    Posts:
    37
    I am getting a strange error since yesterday, while testing subscription purchase. We have two products in our game: a monthly subscription and an yearly subscription. For testing, we are getting 5 min for the regular monthly subscription and 30 min for the yearly one. Till yesterday, we were able to get the subscription receipt once we do a purchase. The same receipt could be obtained even on reopening the app.

    However since yesterday, I am getting a message with a warning alert "Open the app to confirm your subscription", when I check my subscription in the google play store. And then when I open the app and check for the subscription, I am not getting any receipt. Which causes lots of problems since we then do not get subscription info and cancellation info as well. But if I again try to buy the product from the game, I get a google play error telling you have already subscribed.

    Is anyone aware of any recent update to the Google play billing process? Or am I missing something obvious here? I am also having multiple issues with testing Google play subscription due to incorrectly received expiry dates. Should I avoid using Unity subscriptionmanager as suggested by Google or go with it as suggested by Unity? I am really confused here and have a very anxious client to answer to since the app is scheduled for a Christmas release.

    Can someone please help?
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    @sanathkukkillaya So you are seeing different behavior but you didn't change your code? That would imply an issue on the Google side, as you mentioned. And you are the second post I've seen here today on this same behavior. So you know, Unity doesn't handle any of the transactions, the requests go directly from the device to the Google (or Apple) stores, so we don't do any intermediate processing.
     
  3. sanathkukkillaya

    sanathkukkillaya

    Joined:
    Nov 14, 2019
    Posts:
    37
    So you think this could be some overnight change from Google side? One thing that I do know is that our client did publish the app on the play store for testing. Could this have affected the product somehow? I know that I am just shooting in the dark here though without any concrete details, but unfortunately, at the moment, I cannot share more details about the product (since the client manages most of it, we just have the id).

    You did mention that someone else also asked about this? Could you maybe link me to that post? I could probably continue in that thread itself, or maybe just get some more info about this?
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Let's focus on your issue to not conflate issues for now. When did the client publish, you mean just now? Yes, a newly published app could certainly behave differently, if that is the case. You said "since yesterday". If they published a new version of the app, then it's likely not related to Google.
     
  5. sanathkukkillaya

    sanathkukkillaya

    Joined:
    Nov 14, 2019
    Posts:
    37
    Client must have published around couple of hours back. But we are facing this issue since at least around 12 hours or more (our morning time). What we do know is that we shared the build with our client yesterday night (around 24 hours back). Client then did some checking and didn't report anything. The client did generate a services-json file for us, which is apparently required by our back-end team for validation of the IAP. However before the back end team even got around to implementing this, we started facing the above mentioned issue (of needing to open app to confirm subscription). About the back end team, I am sure of this, since we are coordinating with them.
     
  6. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    From your description of the timing, I doubt it is a Google issue. Please reproduce if you can, and provide the device logs. They will tell us what's going on https://forum.unity.com/threads/how-to-capturing-device-logs-on-android.528680/
     
  7. sanathkukkillaya

    sanathkukkillaya

    Joined:
    Nov 14, 2019
    Posts:
    37
    @JeffDUnity3D I have uploaded the logs as you requested. As you can see when I purchase the product, I get the receipt correctly, which I then pass to the back-end for some validations and storing purpose (currently it is disabled, I believe). Since we have only two products, the other product receipt is null (or hasReceipt is false).

    When I restart the game after this, as shown in the logs I get the issue where there are no products. So user is not subscribed, which is not true, since user purchased the product. In play store, it shows me a red icon with message "Open App to confirm".
     

    Attached Files:

  8. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Can you share your code? Specifically, what are you returning from ProcessPurchase, Pending or Complete? Is this where you are doing the back-end validation?
     
  9. sanathkukkillaya

    sanathkukkillaya

    Joined:
    Nov 14, 2019
    Posts:
    37
    Pending processing code is below. In PurchasingHandler.Purchase, we send the receipt to the back-end to validate the receipt.

    Code (CSharp):
    1.         private IEnumerator ProcessPendingPurchase()
    2.         {
    3.             Debug.LogError("Routine Started");
    4.             Product product;
    5.             IAPProduct currentIAPproduct;
    6.             jobCompleted = true;
    7.             yield return new WaitForEndOfFrame();
    8.             while (IsPending() && jobCompleted)
    9.             {
    10.                 jobCompleted = false;
    11.                 product = pendingTransactions.Dequeue();
    12.                 Debug.LogError("Processing Transection : " + product.transactionID);
    13. #if UNITY_ANDROID
    14.                 currentIAPproduct = products.Find(x => x.iapAndroidID == product.definition.id);
    15.                 if (currentIAPproduct != null)
    16.                 {
    17.                     PurchasingHandler.Purchase(currentIAPproduct.subscriptionType, 1, product.receipt);
    18.                     Debug.LogError(product.receipt);
    19.                 }
    20. #elif UNITY_IOS
    21.                 currentIAPproduct = products.Find(x => x.iapIOSId == product.definition.id);
    22.                 if (currentIAPproduct != null)
    23.                     PurchasingHandler.Purchase(currentIAPproduct.subscriptionType, 2, product.receipt);
    24. #endif
    25.                 jobCompleted = true;
    26.                 yield return null;
    27.             }
    28.  
    29.             if (!IsPending())
    30.             {
    31.                 pendingPurchaseHandler = null;
    32.  
    33.                 if (iap.CheckSubscription())
    34.                 {
    35.                     Debug.LogError("Is Subscribed");
    36.                     //TODO:load subcription module from login
    37.                     SubscribedUser = true;
    38.                 }
    39.                 else
    40.                 {
    41.                     Debug.LogError("Is Not Subscribed");
    42.                     SubscribedUser = false;
    43.                 }
    44.             }
    45.  
    46.             yield return new WaitUntil(() => PurchasingHandler.IsPurchaseCompleted);
    47.             Factory.Get<LoadingCanvas>().HideLoadingScreen();
    48.  
    49.         }

    This is our PurchaseComplete code. We call the our chooseSubscription page, which then loads the main game, through chooseSubscritption.OnPurchaseComplete(). We also call the IAP.CompletePurchase() which should confirm and complete the purchase.


    Code (CSharp):
    1.         private void OnPurchaseComplete(string productId)
    2.         {
    3.             SubscribedUser = true;
    4.             Debug.Log("Purchased Item SuccessFully" + SubscribedUser);
    5.  
    6.             var chooseSubscrition = UIFactory.Get<ChoosePlanScreen>();
    7.             if (chooseSubscrition != null && chooseSubscrition.IsActive())
    8.             {
    9.                 chooseSubscrition.OnPurchaseComplete(productId);
    10.             }
    11.             else
    12.             {
    13.                 if (chooseSubscrition == null)
    14.                 {
    15.                     Debug.LogError("Screen is null");
    16.                 }
    17.                 else
    18.                 {
    19.                     Debug.LogError("Screen is inactive");
    20.                 }
    21.             }
    22.  
    23.             iap.CompletePurchase(productId);
    24.         }
    The following is the IAP purchase code

    Code (CSharp):
    1.         public void CompletePurchase(string productId)
    2.         {
    3.             var product = _storeController.products.WithID(productId);
    4.             Debug.LogError("Purchase Completed : " + product.definition.id);
    5.             _storeController.ConfirmPendingPurchase(product);
    6.         }

    Let me know if anything else also is needed
     
  10. sanathkukkillaya

    sanathkukkillaya

    Joined:
    Nov 14, 2019
    Posts:
    37
    @JeffDUnity3D Were you able to look into this issue? Do you think anything is wrong with the way I am making the purchase? Or should I try using the Google Play billing library?
     
  11. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Your code looks correct, we already use the Google Play v3 billing library. We may have an issue in our code, I will take a look. We've heard similar reports, it seems that ConfirmPendingPurchase may be silently failing, or similar.
     
  12. sanathkukkillaya

    sanathkukkillaya

    Joined:
    Nov 14, 2019
    Posts:
    37
    Thanks for clarifying. This can help with the client situation for now. Please do let us know when a fix is available or if you find a workaround that can help in this scenario.
     
  13. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    I have reproduced, we are looking into it.
     
  14. sanathkukkillaya

    sanathkukkillaya

    Joined:
    Nov 14, 2019
    Posts:
    37
    @JeffDUnity3D Could you please give some update on the progress here. We need to submit a build to the play store by this weekend, and we are not able to complete the subscription module due to this issue.
    Do you know of any temporary workaround that we might use until this issue is resolved? Any input from your side would be welcome on this.
     
  15. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    We are working on this, but we don't expect the next release until the first week of January. There are no workarounds that I know of, other than returning Complete from ProcessPurchase each time.
     
  16. sanathkukkillaya

    sanathkukkillaya

    Joined:
    Nov 14, 2019
    Posts:
    37
    Thank you for the clarification, and the temporary workaround. I'll check if returning Complete from ProcessPurchase each time can help.
     
  17. AJ_Games_

    AJ_Games_

    Joined:
    Dec 13, 2020
    Posts:
    10
    Hello
    Can any one tell me how can I make subscription purchases in unity ?
     
  18. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Separate issue, please open a new thread. Subscription purchases are exactly like any other product type, there is no special handling.