We are trying to use the Xamarin.InAppBilling component to make in-app purchases. We were able to successfully buy a product and to enumerate the products. However we are facing a problem to get the already purchased products. We get the following exception when we execute the following code.
06-18 10:59:28.638 I/mono-stdout(24862): BillingHandler_InAppBillingProcesingError - Erro Message: Error validating previous purchase : System.NullReferenceException: Object reference not set to an instance of an object
06-18 10:59:28.648 I/mono-stdout(24862): at Xamarin.InAppBilling.InAppBillingHandler.GetPurchases (System.String itemType) [0x00000] in :0
We call this method with the following code:
var _purchases = _serviceConnection.BillingHandler.GetPurchases(ItemType.Product);
We instantiate the billing class with the following code. The value variable is our public key I got from Google Play. We used to use the Unify method, but we removed it just to make sure it was not causing the problem.
var value = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs/EobJD6fxSBDdGDxaXqSK5g+GCKRRqp3AN/p/862leJpEgV75iyu45UsCVJ4vYUb51IF5j/lbEdCiYeweGUw9DwbORTKH+1Ahv8A7wVpFGtVP2TtD7tEqadsad/+FOiUZamwQgdfdgdd6yxu5KQqKWHpHqGHuDSoLybcDQGUybqIU4DYUpTNskq1AKCOKpA2SbuTxkktooVVviUAs/HPDAn9rHY1Eqfqa8yAI1tAMqL/qbj0uqKcyt4zKx5GFH+q5qozhtYMamizkn5KiS7mePZ5Yhwlb01eGyMRXZp8pICNnVrxTMM4fqzZK9Y3bcXFm8EwhQ72Xr2J7TP90VcXiHP9KzdWxCFwIDAQAB";
_serviceConnection = new InAppBillingServiceConnection(MainActivity.Main, value);
The code that get the purchases is executed inside the OnConnected event.
I do not know what else to look. Can you help us?