2016-01-30 85 views
9

我在店內創建了一個新的IAP,商品編號爲產品ID爲「捐贈」。 後來我讓應用中要​​求該IAP,這裏是代碼:UWP IAP:此應用內購買商品不再可用

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

然而,當我調用該函數在我的Windows應用程序,顯示錯誤消息對話框:

選擇另一項:此應用程序內購買的產品不再提供我的應用程序名稱

,我試圖調用var listingInfo = await CurrentApp.LoadListingInformationAsync();var productListings = listingInfo.ProductListings;似乎沒有在列表中沒有的產品。

這會如何發生?謝謝!

+0

你見過這個[問題](HTTP ://stackoverflow.com/questions/34402180/in-app-purchase-trouble-on-windows-10-uwp)(它看起來非常類似於你的)? – JeyMcKey

回答

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; 
} 
相關問題