What does IStoreController.products actually return?

Hello everyone. I wonder what IStoreController.products actually means. The description in docs is very scarce:
Store products including metadata and purchase receipts.
Is this all purchased products that user has from the store (all games, all times).
Is this purchased products for my game only.
Is this purchased & non-purchased products for my game only.
etc
Could anyone explain? I need to send some statistics for a unique paying user, so I need to know that at the time user is purchasing something in my game - she’s doing this for the first time and for the current game. Could anyone give any hints on how could I achieve that? At the moment I’m doing it like this, but the statistics doesn’t appear (like all users are not unique) although I have some purchases:

private bool isUniquePayingUser() {
            Product[] products = m_StoreController.products.all;
            for (int i = 0; i < products.Length; i++) {
                if (products[i].hasReceipt) {
                    Debug.Log("Not unique paying user!");
                    return false;
                }
            }
            Debug.Log("Unique paying user!");
            return true;
        }

So I wonder maybe I’m treating the products collection wrong

1 Like

Your code looks correct. The store controller contains all products available for sale in this game, for this user. Can you rephrase this statement “but the statistics doesn’t appear (like all users are not unique) although I have some purchases:” what stats don’t appear?

Hi Jeff, thank you for the reply!
At the moment I have only 1 product in my game and it’s non-consumable (a set of levels player can play after she completed free levels). So every player that purchases it should be unique, because it cannot be purchased twice.

In ProcessPurchase handler I’m doing something like this:

public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
{
......
if (_isUniquePayingUser) //the variable is set earlier by the result of the method I provided in the original comment
            {
                trackUniquePayingUser();
            }
trackPurchase(args.purchasedProduct);
.....
}

So I’m sending statistics in the trackUniquePayingUser method and it doesn’t show up on my statistics console.
You can see that after the condition statement I’m sending trackPurchase statistics and it arrives every time player makes a purchase. So for the last week I’ve got 6 trackPurchase events and only 2 trackUniquePayingUser events in my statistics.
So now I’m trying to understand what’s wrong and am I using the correct way to determine the fact that user is purchasing something first time with the code in my first comment. If the code seems correct to you then it could be something with the statistics API I’m using.

@kumade What Android device are you testing on? Are you able personally to (attempt) to purchase twice? Or do you specifically hide the button. That is, you may be incorrectly tracking failed purchases. Perhaps the same user purchased once, then tried a few more times. However, your tracking code is correctly located in ProcessPurchase which implies a successful purchase. Add Debug.Log statements in your code to confirm, they will show in the adb logcat logs How To - Capturing Device Logs on Android

@JeffDUnity3D thanks for the reply. I’m not testing, it’s in production already :slight_smile: So multiple devices, different users etc. When I did test - everything worked as expected on my device (device logs had been shown and stats had been sent).
I’m hiding the button if the purchase is successful, yes. So I’m only sending statistics and hiding the button in ProcessPurchase which means that I’m not tracking failed purchases.

Please test with a new account on your device, and provide the device logs with your Debug.Log statement visible in the log. Then have this user make a purchase, and show the device logs again to confirm your logic.