In App Purchases (IAP) does not work on Android

I have already spent so much time trying to understand what might be wrong and still couldn’t find the answer. When I test IAP inside unity editor, everything works and I do not get any errors or exceptions video

However, when I try to press the IAP button on android device, for some reason I get a NullReferenceException (see the screenshot). My application is uploaded to Google Play Console >> Internal Testing. What can cause this error?

IAPShop.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Purchasing;

public class IAPShop : MonoBehaviour
{
    private string gems100 = "gems100";
    public void OnPurchaseComplete(Product product)
    {
        if (product.definition.id == gems100)
        {
            // reward the player
        }
    }

    public void OnPurchaseFailed(Product product, PurchaseFailureReason reason)
    {
        Debug.Log("Purchase of " + product.definition.id + " failed due to " + reason);
    }
}

You will want to avoid Codeless IAP, it has known issues. Does your NRE go away if you comment out the Debug.Log statement? We haven’t seen any NRE’s in our code, so it may be in your code. You’ll want to add additional Debug.Log statements to find out. But as mentioned, you should avoid Codeless IAP altogether. Instead, you would be advised to use the Sample IAP Project v2 here that uses Scripted IAP. Note the comment in the forum post where you need to change some of the code (homework to help you understand the code!) https://discussions.unity.com/t/700293/3 Also, ensure to follow the steps here https://docs.unity3d.com/Packages/com.unity.purchasing@4.1/manual/UnityIAPGoogleConfiguration.html