我在我的Xamarin Forms 5应用程序中实现了InAppBilling
插件,用于自动续订订阅。
我在Google Play上设置了“订阅”,并且它们处于活动状态。当我要求订阅项目列表时,我可以获得列表,但当我尝试购买时,我会收到以下错误,表明该项目不可用。
我在一个通过USB连接到我笔记本电脑的真实的设备上运行这个程序。你知道我做错了什么吗?
下面是我的购买订阅方法,它直接来自documentation here:
public async Task<bool> Subscribe(string productId)
{
var billing = CrossInAppBilling.Current;
try
{
var connected = await billing.ConnectAsync();
if (!connected)
return false;
//check purchases
var purchase = await billing.PurchaseAsync(productId, ItemType.Subscription);
//possibility that a null came through.
if (purchase == null)
{
//did not purchase
return false;
}
else
{
//purchased!
if (Device.RuntimePlatform == Device.Android)
{
// Must call AcknowledgePurchaseAsync else the purchase will be refunded
//await billing.AcknowledgePurchaseAsync(purchase.PurchaseToken);
}
return true;
}
}
catch (InAppBillingPurchaseException purchaseEx)
{
//Billing Exception handle this based on the type
throw new Exception("Error: " + purchaseEx);
}
catch (Exception ex)
{
//Something else has gone wrong, log it
throw new Exception();
}
finally
{
await billing.DisconnectAsync();
}
}
正如我之前提到的,我看到订阅项目在Google Play上可用并处于活动状态。我还确保,我从“订阅”而不是“应用内产品”中获取它们。我使用的是从Google Play控制台上的“产品ID”列中复制并粘贴的ID-请参阅下文:
你知道问题出在哪吗
1条答案
按热度按时间zlhcx6iw1#
有点晚,但我有同样的问题,原来的原因是我的电子邮件地址不在我在Google Play控制台使用的许可证测试列表.