The last couple of weeks we have been experiencing a number of failed In-App Purchase failures on Android (iOS has been fine).
We use the Xamarin.InAppBilling component (version 2.2.0) which has been absolutely fine for many months, but recently we can see that we are invoking line (A) but the usual IAP callbacks are not being invoked, which implies...
Google doesn't receive the purchase request - we can rule this out, they are being charged.
Google doesn't reply - Our most likely scenario
A bug in the Xamarin.InAppBilling - unlikely since it has been working to date.
We haven't registered a callback properly - unlikely because we have logging on the first line of each callback...
_serviceConnection.BillingHandler.OnUserCanceled += BillingHandler_OnProductCanceled; _serviceConnection.BillingHandler.OnProductPurchased += BillingHandler_OnProductPurchased; _serviceConnection.BillingHandler.OnGetProductsError += BillingHandler_OnGetProductsError; _serviceConnection.BillingHandler.OnPurchaseConsumed += BillingHandler_OnPurchaseConsumed; _serviceConnection.BillingHandler.OnPurchaseConsumedError += BillingHandler_OnPurchaseConsumedError; _serviceConnection.BillingHandler.OnProductPurchasedError += BillingHandler_OnProductPurchasedError; _serviceConnection.BillingHandler.OnPurchaseFailedValidation += BillingHandler_OnPurchaseFailedValidation; _serviceConnection.BillingHandler.OnInvalidOwnedItemsBundleReturned += BillingHandler_OnInvalidOwnedItemsBundleReturned;
Here's an excerpt of the code that invokes the purchase...
Device.BeginInvokeOnMainThread (async () => {
var products = await _serviceConnection.BillingHandler.QueryInventoryAsync (new List<String> { consumableSku }, ItemType.Product);
if (products != null && products.Count == 1) {
var product = products [0];
logger.Log ("FeatureService purchaseConsumableFromGooglePlay product:"+product.ToString()+ " payload:" + this.developerPayload);
// (A)
_serviceConnection.BillingHandler.BuyProduct (product, this.developerPayload);
} else {
this.iapConsumableEvent.Purchased = false;
this.Publish<IapConsumableEvent> (this.iapConsumableEvent);
}
});
logger.Log ("FeatureService purchaseConsumableFromGooglePlay completed");
Most of the time the BillingHandler callbacks are invoked, but when it doesn't work it seems that those callbacks are not invoked.
We have seen this on Android 7 and 8 (so it's an Android 8 issue).
We are not sure where to go from here, any suggestions on debugging this further is appreciated.