I'm implementing in app billing with a Xamarin forms app. iOS got up and running easily but with Android I can't get anything to got through. I am following the 'Getting started' instructions that are part of the component and using code provided in the example application.
I am doing the following to connect:
_serviceConnection.OnConnected += async () => {
_serviceConnection.BillingHandler.OnGetProductsError += (int responseCode, Bundle ownedItems) => {
Console.WriteLine("Error getting products");
};
_serviceConnection.BillingHandler.OnInvalidOwnedItemsBundleReturned += (Bundle ownedItems) => {
Console.WriteLine("Invalid owned items bundle returned");
};
_serviceConnection.BillingHandler.OnProductPurchasedError += (int responseCode, string sku) => {
Console.WriteLine("Error purchasing item {0}",sku);
};
_serviceConnection.BillingHandler.OnPurchaseConsumedError += (int responseCode, string token) => {
Console.WriteLine("Error consuming previous purchase");
};
_serviceConnection.BillingHandler.InAppBillingProcesingError += (message) => {
Console.WriteLine("In app billing processing error {0}",message);
};
_serviceConnection.BillingHandler.QueryInventoryError += (int responseCode, Bundle skuDetails) => {
Console.WriteLine("Query Inventory Error");
};
GetInventory();
};
Inside the GetInventory method I do this:
_products = await _serviceConnection.BillingHandler.QueryInventoryAsync (new List {
ReservedTestProductIDs.Purchased,
ReservedTestProductIDs.Canceled,
ReservedTestProductIDs.Refunded,
ReservedTestProductIDs.Unavailable
}, ItemType.Product);
// Were any products returned?
if (_products == null) {
// No, abort
return;
}
I am using the test product IDs but I also have products set up in the developer console and have tested with them as well. The first thing I noticed is that _products is always null after the call to 'QueryInventoryAsync'. I then added the handler for 'QueryInventoryError', which returns a 'response code 6' which is a 'Fatal Error' according to docs and not much else is given.
I am using the key provided by the developer console when calling the 'Connect' function. I've checked it a couple time. I am running the application from Xamarin Studio. I have uploaded an APK with Billing enabled and gone through the appropriate steps setting up in app billing in the console.
Do I have to run the tests from an APK that has gone through the consoles testing features (i.e. can I not test responses from running it from xamarin studio in a device connected via USB)?
I get the same results using the sample application provided in the InAppBilling plug in.
Thanks for any help.