【发布时间】:2018-12-04 00:19:08
【问题描述】:
我们在 Microsoft Store 中有一款 UWP 产品。该产品有许多订阅附加组件。用户在应用内购买订阅插件。 编辑我们的代码由 Microsoft Docs Enable subscription add-ons for your app 拼凑而成
StorePurchaseResult result = await product.RequestPurchaseAsync();
if (result.Status == StorePurchaseStatus.Succeeded)
结果返回StorePurchaseStatus.Succeeded。微软已将用户的钱用于订阅附加组件。到目前为止一切顺利。
我们需要这样的产品列表
string[] productKinds = { "Durable" };
List<String> filterList = new List<string>(productKinds);
StoreProductQueryResult queryResult = await storeContext.GetAssociatedStoreProductsAsync(filterList);
productList = queryResult.Products.Values.ToList();
然后遍历
foreach (StoreProduct storeProduct in products)
{
if (storeProduct.IsInUserCollection)
...
}
但 storeProduct.IsInUserCollection 总是返回 false。 Microsoft 已接受插件的付款,但未将其添加到用户的产品集合中,因此我们无法验证他们是否已为插件付款。
我们哪里出错了?
EDIT 2根据@lukeja 的建议,我运行了这个方法
async Task CheckSubsAsync()
{
StoreContext context = context = StoreContext.GetDefault();
StoreAppLicense appLicense = await context.GetAppLicenseAsync();
foreach (var addOnLicense in appLicense.AddOnLicenses)
{
StoreLicense license = addOnLicense.Value;
Debug.WriteLine($"license.SkuStoreId {license.SkuStoreId}");
}
}
这只会输出一个附加组件。免费的附加组件。我们有 16 个附加组件,其中只有一个是免费的。
为什么我们的任何付费附加订阅都没有退还?
EDIT 3 appLicense.AddOnLicenses 仅包括当前用户的附加许可,而不是应用的所有附加许可。 @lukeja 提供的代码示例在支付订阅的用户的上下文中运行时按预期工作。
【问题讨论】:
标签: windows-store-apps windows-store