我在商店中使用产品ID “捐赠”创建了一个新的IAP。
然后在应用程序中向此IAP发出请求,代码如下:

var purchaseResults = await CurrentApp.RequestProductPurchaseAsync("Donate");

但是,当我在Windows应用程序中调用该函数时,将显示一个错误消息对话框:

选择另一个项目:“我的应用程序名称”中不再提供此应用内购买项目

我尝试调用var listingInfo = await CurrentApp.LoadListingInformationAsync();var productListings = listingInfo.ProductListings;似乎列表中没有产品。

怎么会这样谢谢!

最佳答案

如果要基于Windows SDK 14393(或更高版本)构建应用程序,我强烈建议使用StoreContext类而不是CurrentApp,StoreContext可以更方便地实现IAP操作,并且易于调试。

对于您的情况,您可以使用购买api,如下所示:

private readonly StoreContext context = StoreContext.GetDefault();

// you can get the StoreId of Iap product from your dashboard of Windows Dev Center
var result = await context.RequestPurchaseAsync(product.StoreId);
if (result.Status == StorePurchaseStatus.Succeeded)
{
    // successfully purchased
}
else if (result.Status == StorePurchaseStatus.AlreadyPurchased)
{
    // purchased already
}
else if (result.Status == StorePurchaseStatus.NotPurchased)
{
    // purchase progress cancelled by user
}
else if (result.Status == StorePurchaseStatus.ServerError || result.Status == StorePurchaseStatus.NetworkError)
{
    // error occured
}

并且您还可以像这样列出您的IAP产品:
var result = await context.GetAssociatedStoreProductsAsync(new string[] { "Durable" });
if (result.ExtendedError != null)
{
    // error
}
else
{
    // list all durable iap product
    var products = result.Products.Values;
}

关于windows - UWP IAP : This in-app purchase item is no longer available,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/35102136/

10-11 21:53