模拟购买Windows 8商店应用程序

7

我正在尝试编写代码,以模拟Windows 8(商店)应用程序的购买过程。

这段代码相当简单,并使用了Windows API:

var result = await CurrentAppSimulator.RequestProductPurchaseAsync("product", true);

// this is still false...
var active = CurrentAppSimulator.LicenseInformation.ProductLicenses["product"].IsActive;

第一次调用会打开对话框,允许我模拟购买的返回代码。

即使我选择了S_OK,下一行仍然检查许可证是否激活并返回false。

这里出了什么问题?


在这里查看答案:https://dev59.com/f3DYa4cB1Zd3GeqPFuxU - N_A
2个回答

11
你是否在更新WindowsStoreProxy.xml文件?如果不这样做,购买将永远无法激活。你不需要调用RequestAppPurchaseAsync...,只需使用requestProductPurchaseAsync.操作如下: 在调试模式下运行你的应用程序,在任何地方停止。 打开QuickWatch(SHIFT + F9),输入Windows.Storage.ApplicationData.current.roamingFolder.path并复制该值(我的是C:\Users\jerfost\AppData\Local\Packages\{package name}\LocalState)。 浏览到该位置并打开Microsoft\Windows Store\ApiData目录。 以文本编辑器打开WindowsStoreProxy.xml文件。 将CurrentApp/LicenseInformation/App/IsTrial更改为false。 将CurrentApp/ListingInformation/Product/MarketData/Name更改为您的唯一产品名称。 就这样了,希望能对你有所帮助。

ProductId是什么情况? 你确实需要将ProductId更改为您独特的产品名称,对吗? - Stefan Fabian

3

您不需要手动编辑XML,CurrentAppSimulator会自动完成。

只需检查WindowsStoreProxy.xml中的设置,并确保“IsTrial”设置为“false”即可。

<LicenseInformation>
    <App>
        <IsActive>true</IsActive>
        <IsTrial>false</IsTrial>
    </App>
    <Product ProductId="1">
        <IsActive>false</IsActive>
    </Product>
</LicenseInformation>

请记住 - 试用版本的应用程序中无法使用应用内购买功能。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接