我使用产品ID “捐赠”在商店中创建新的IAP。 然后我在应用程序中向此IAP发出请求,这是代码:
var purchaseResults = await CurrentApp.RequestProductPurchaseAsync("Donate");
但是,当我在Windows应用程序中调用该函数时,会显示一条错误消息对话框:
选择其他商品:我的应用名称
中不再提供此应用内购买商品我尝试拨打var listingInfo = await CurrentApp.LoadListingInformationAsync();var productListings = listingInfo.ProductListings;
似乎列表中没有产品。
这会怎么样?谢谢!
答案 0 :(得分:0)
如果您正在构建基于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;
}