How to get products from Play Store? Metadata is empty.

I was trying to get localized price text from the Play Console with Unity IAP, however, their metadata is always default. Their prices are shown as “$0.01”. Their availability is also wrong. There are some products that are inactive, but in the code, their availability is true.

This is the simplified version of the code:

    private void Start()
    {
        var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance(AppStore.GooglePlay));
        builder.AddProduct("gold.1000", ProductType.Consumable);    // This product is active on Play Console
        builder.AddProduct("gold.3000", ProductType.Consumable);    // This product is inactive on Play Console

        UnityPurchasing.Initialize(this, builder);
    }

    public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
    {
        for (int i = 0; i < controller.products.all.Length; ++i)
        {
            // The both products are available somehow even though 'gold.3000' is inactive on Play Console
            Debug.Log("ID: " + controller.products.all[i].definition.id + " - Available: " + controller.products.all[i].availableToPurchase);
         
            if (!controller.products.all[i].availableToPurchase)
                continue;

            // This is '$0.01' for the both products. I think, the game doesn't connect to the game on Play Store
            Debug.Log(controller.products.all[i].metadata.localizedPriceString);
        }
    }

Also, how does Unity IAP know which products are available in my game? I haven’t entered any ID or something to connect Unity IAP with the products on Play Console.

As you mention, you need to connect the productIDs to the products in your Google console. And you’ve already done that, ensure these same products are defined on your console (like “gold.1000”) These instructions should help. There are some bad links, but is generally correct. You need to publish your game to Google then make it available to your testers (including yourself) Unity - Manual: Configuring for Google Play Store Please don’t share “simplified” versions of your code, show the exact syntax. You might want to compare to IAPManager.cs in the Sample IAP Project Sample IAP Project

I followed the instructions on the page. I have already created products on Play Console. “gold.1000” and “gold.3000” exist on the console.

One thing that is missing is that I didn’t test it on a phone yet. I don’t know if I need to test it on a phone to get metadata. I’m currently trying to test the localized prices, not the transactions. Do I need to test it on a phone to get metadata?

Also, as I said, I haven’t given any ID or something to Unity IAP. I just activated it from the services tab, and imported the package. Do I need to something extra to let Unity IAP which game it’s running on?

Yes, IAP won’t retrieve products in the Editor, it needs to be deployed to your device for IAP to work. And you have given the ID (gold.1000)

1 Like

Okay, thank you.