Windows phone 8.1 内购失败

Windows phone 8.1 in app purchase fails

我遇到了这个问题,所以我认为我会 post 答案,因为我在任何地方都找不到解决方案。

第一个问题: 在调用 CurrentApp.RequestProductPurchaseAsync() 时我会得到 "Can't find item in catalog ; We looked but can't find the item you wanted to buy" 或错误 805a0194。

第二个问题:无法找到获取我的购买是否有效的方法。

问题一的解决方案: 转到您的 Package.appxmanifest 并右键单击然后点击查看代码。如果您的应用程序已经像我的一样发布,请转到仪表板并从 Windows Phone 仪表板->应用程序->您的应用程序->详细信息中获取 AppId。将该 ID 粘贴到 Package.appxmanifest 中的 PhoneProductId 字段中。现在,只要您在商店中发布了产品并且您提供给方法的产品 ID 匹配,您的应用内购买就应该有效。

问题2的解决方法:我用这段代码来查看购买是否有效:

private async Task<bool> GetLicenseStatus(string id)
{
    try
    {
        var result = await   CurrentApp.GetProductReceiptAsync(id);
    }

    catch //user didnt buy
    {
            return false;
    }

    return true;
}