IAP doesn't work in VR mode (Cardboard)

Hi,

I have used Sample IAP code from Sample IAP Project and tested for one consumable item. I created a gameObject with MyIAPManager.cs attached. The button OnClick runs BuyProductID method like below:

void BuyProductID(string productId)
{
            if (IsInitialized())
            {
                Product product = m_StoreController.products.WithID(productId);

                if (product != null && product.availableToPurchase)
                {

                        MyDebug(string.Format("Purchasing product:" + product.definition.id.ToString()));

                        m_StoreController.InitiatePurchase(product);
                }
                else
                {
                        MyDebug("BuyProductID: FAIL. Not purchasing product, either is not found or is not available for purchase");
                }
            }
            else
            {
            MyDebug("BuyProductID FAIL. Not initialized.");
            }
 }

THE PROBLEM: Everything works fine in the editor but on Android device the app crashes just after this line:

MyDebug(string.Format(“Purchasing product:” + product.definition.id.ToString()));

It looks that a product is available to purchase but m_StoreController.InitiatePurchase(product) causes that crash. I can’t figure out what is the problem. I tried many things already, even the stuff like clearing the cache or editing the path to Unity to be without any spaces, but nothing helped out.

The app is made for Google Cardboard and used to well on Android (purchase window was showing show normally) when compiled in Unity 2018. I’ve started to get this issue after upgrading to unity 2019. I’ve upgraded IAP to 1.23.

It HAPPENS ONLY if in XR Settings >> Virtual Reality Supported & Cardboard are chosen.

If VR stuff is off all works well.

In attachment my logcat from Android(company, app and product names have been replaced).

Thanks in advance!

5192624–516077–log.txt (16.8 KB)

There are no errors in the log. Can you try to determine exactly which line is causing the issue? Is it the MyDebug itself, for example.

Hi, thanks for the reply!

private void MyDebug(string debug)
{
Debug.Log(debug);
myText.text += “\r\n” + debug;
}
shows me on the screen as follows:
Complete = true
OnInitialized: PASS
Purchasing product: com.company.vrappname.productsmall

Then I get crash with a small window appearing on the phone:

It seems that the crash appears when it executes
m_StoreController.InitiatePurchase(product);

I need to mention that I changed the path to Unity after upgrading to IAP 1.23.
Could it be the case?

Please place debug statements before and after InitiatePurchase, etc.