I'm working with the Xamarin.InAppBilling component, and consistently encountering an error. The problem is with the override method:
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) {
// Ask the open service connection's billing handler to process this request
_serviceConnection.BillingHandler.HandleActivityResult(requestCode, resultCode, data);
// Ask the open connection's billing handler to get any purchases
var purchases = _serviceConnection.BillingHandler.GetPurchases(ItemType.Product);
foreach (var purchase in purchases) {
FufillOrder(purchase);
}
}
When using the reserved id "android.test.purchased"
, a reserved product string, This override method works fine, both locally and in the live Beta channel of my application. The method is invoked, and the product is fulfilled.
However with any live In-App Products, those populated by a id string:
Products = await _serviceConnection.BillingHandler.QueryInventoryAsync(new List<string> {
"example",
}, ItemType.Product);
this method is not invoked when the user completes the purchase cycle.
To further confuse things - in the Android Merchant Console, the orders were successfully processed, and reported as 'Delivered', so no problem there.
However, the issue remains the same. The following code does not work for live products:
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) {
// Ask the open service connection's billing handler to process this request
_serviceConnection.BillingHandler.HandleActivityResult(requestCode, resultCode, data);
// Ask the open connection's billing handler to get any purchases
var purchases = _serviceConnection.BillingHandler.GetPurchases(ItemType.Product);
foreach (var purchase in purchases) {
FufillOrder(purchase);
}
}
The orders are not fulfilled, or consumed. Interestingly, I threw this on _serviceConnection.OnConnected:
var purchases = _serviceConnection.BillingHandler.GetPurchases(ItemType.Product);
foreach (var purchase in purchases) {
_serviceConnection.BillingHandler.ConsumePurchase(purchase);
}
And that doesn't work either for live products. They are not consumed. (though, again, it does work for android.test.purchased
).