UWP IAP : This in-app purchase item is no longer available

I create a new IAP in store with the Product ID "Donate". Then I make request to this IAP in the app, here is the code:

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

However, when I call the function in my windows app, an error message dialog is shown:

Choose another item : This in-app purchase item is no longer available in My App Name

and I tried call var listingInfo = await CurrentApp.LoadListingInformationAsync();var productListings = listingInfo.ProductListings;It seems that there is no product in the list.

How would this happened? Thanks!


ANSWERS:


If you are building your app based on Windows SDK 14393(or higher), I strongly recommend StoreContext class instead of CurrentApp, StoreContext is more convenient to implement an IAP action, and it is also easy to debug.

For your case, you could use the purchase api like this:

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
}

and you could also list your IAP product like this:

var result = await context.GetAssociatedStoreProductsAsync(new string[] { "Durable" });
if (result.ExtendedError != null)
{
    // error
}
else
{
    // list all durable iap product
    var products = result.Products.Values;
}


 MORE:


 ? How to connect to SQL server database from a Windows 10 UWP app
 ? How to connect to SQL server database from a Windows 10 UWP app
 ? How to connect to SQL server database from a Windows 10 UWP app
 ? Windows Universal App and SQL Server
 ? How do I interact with SQL in a Windows Store App
 ? UWP / EF Core SqlServer - Threading Dependency
 ? SqlConnection in Portable Class Library
 ? How to exit or close an UWP app programmatically? (Windows 10)
 ? Shared model to access SQL Server from UWP
 ? How to use a Database from a Windows tablet UWP app?