Hi,
i writing code to add In App purchase to my app, i can retrive correctly the list of In App products, but when i run the function PurchaseAsync i have this error exception 0x80070005 E_ACCESSDENIED.
Why ?
I using Xamarin and PlugIn.InAppBilling multiplatform from Montemagno that work perfectly with Android and iOS
This is my code:
string idProdottoAcquisto = "PRODUCT_ID_IN_STORE;"
string[] idProdottiAcquisto = new string[1];
idProdottiAcquisto[0] = idProdottoAcquisto;
System.Collections.Generic.IEnumerable<InAppBillingProduct> ProdInfos = await billing.GetProductInfoAsync(ItemType.InAppPurchase, idProdottiAcquisto);
if (ProdInfos.Count() < 1)
return false;
bool RispostaData = false;
bool RispostaAlert = false;
Xamarin.Forms.Device.BeginInvokeOnMainThread(async () =>
{
RispostaAlert = await DisplayAlert("Confirm", "Do you want buy\n" +
ProdInfos.ElementAt(0).Name + " (" + ProdInfos.ElementAt(0).Description + ")\n" +
ProdInfos.ElementAt(0).CurrencyCode + " " + ProdInfos.ElementAt(0).LocalizedPrice, "YES", "NO");
RispostaData = true;
});
while (!RispostaData)
Thread.Sleep(500);
if (!RispostaAlert)
return false;
InAppBillingPurchase buy = await billing.PurchaseAsync(idProdottoAcquisto, ItemType.InAppPurchase, "Verified");
if (buy != null && buy.State == PurchaseState.Purchased)
{
return true;
}
else
return false;