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

(Android) Some users do not receive purchased items

Discussion in 'Unity IAP' started by Dinochrome, May 7, 2021.

  1. Dinochrome

    Dinochrome

    Joined:
    Apr 23, 2018
    Posts:
    19
    Hello everyone!

    Recently ran into an IAP problem that I cannot solve myself.
    Only a small percentage of users seem to have this problem. The user buys a product, and after a while (usually on another day), when he opens the app, all purchased products disappear. If he tries to buy them again, he will receive a duplicate transaction error.

    I'm using quite common IAP implementation

    Code (CSharp):
    1. var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
    2. builder.AddProduct(product_id, ProductType.NonConsumable);
    3. ...
    4.  
    And when IAP is initialized

    Code (CSharp):
    1. if (IsInitialized())
    2.         {
    3.             Product product = m_StoreController.products.WithID(productId);
    4.             if (product != null && product.hasReceipt)
    5.             {
    6.                ... success              
    7.             }
    8. ...
    9.  
    And here's the thing - all products are returned from the server as not purchased,
    Code (CSharp):
    1. (product.hasReceipt == false; product.availableToPurchase == true;)
    although in fact the products were purchased, and an attempt to purchase them again will return a duplicate transaction.

    IOs builds work fine, most Android users have no problem either. Google support replies that this is a developer problem (i.e. mine).
    Has anyone faced such a problem? I would be glad to any advice. Thanks in advance.
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

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

    Dinochrome

    Joined:
    Apr 23, 2018
    Posts:
    19
    Unfortunately no, for me IAP works well in both apps on all my devices (I have currently two apps with the same code and the same problem). The fact is that after payment they receive a working application. Everything works fine, but the next day the application “forgets” that it was bought. Really strange behavior.
    I doubt they made deferred purchase, but I'll ask. Thanks for the advice!
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    What do you mean "forgets"? Is it in the IAP code, or how you award the product to the user? And what do you mean "receive a working application"?
     
  5. Dinochrome

    Dinochrome

    Joined:
    Apr 23, 2018
    Posts:
    19
    Some parts of the application are in trial mode until the user buys the appropriate option. A fully working app means that the user purchases some (or all) of the options and the app becomes fully unlocked on all of their devices. Then (usually the next day) the user launches the app and it is in trial mode again, as if it had not been purchased. IAP information from Google says that the app was not purchased, but it was actually purchased, and when the user tries to buy it again, they receive a "recurring transaction" event.
     
  6. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    We will need more information. Understood it can be problematic if you can't reproduce and don't have the device logs.
     
  7. Dinochrome

    Dinochrome

    Joined:
    Apr 23, 2018
    Posts:
    19
    Seems that I found source of my problems. I launched an IAP initialization in the "Start" method at the beginning of the only scene of my app. In other words, immediately after the application is launched. When I made a small delay (0.5 seconds), users reported that the problem disappeared.
     
  8. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    What version of IAP are you using? That sounds like an issue from a previous version.
     
  9. Dinochrome

    Dinochrome

    Joined:
    Apr 23, 2018
    Posts:
    19
    3.1.0. The first thing I did when the problem occurred was to update to the latest version. I don't think this is a Unity issue because it only appears in the Play Store and not the App Store. One user said that a simple reisntall helped get the app unlocked.
    And the problem arose again today, the delay didn’t work. I am running out of options, I just thought that someone might have the same error and be able to fix it.
     
  10. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    A reinstall will trigger Restore (and the call to ProcessPurchase) on Google, but not on Apple. And I trust you've tested by purchasing and then restarting your app.
     
  11. Dinochrome

    Dinochrome

    Joined:
    Apr 23, 2018
    Posts:
    19
    Yes, I've tried many combinations on my 2 devices (install - remove, install on another device, install on both etc). Everything works as it should every time.

    As for users with this problem, as far as I know reinstall didn't work for all of them, only for a few. I'll try to find somebody with this problem and ask him for logcat logs. This seems to be the only way now.
     
  12. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Did you specifically try purchasing, then restarting the app? Not on two devices and not reinstalling, just restart the game after purchasing.
     
  13. Dinochrome

    Dinochrome

    Joined:
    Apr 23, 2018
    Posts:
    19
    Yes, IAP worked as it should. However, users reported that the problem went away after a while. I'm starting to think this wasn't a Google or app problem at all, but I can't verify it anymore.