Simulating a Windows 8 Store apps purchase

雨燕双飞 提交于 2020-01-01 03:04:05

问题


I am trying to put together code that simulates purchases for a Windows 8 (Store) app.

The code is pretty simple and uses the Windows API:

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

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

The first call opens up the dialog that allows me to simulate the return code from the purchase.

Even when i select S_OK, the next line still checks to see if the license is active and returns false.

What is wrong here?


回答1:


Are you updating the WindowsStoreProxy.xml file? You have to do that otherwise the purchase will never be set to active. You don't need to call RequestAppPurchaseAsync... only the requestProductPurchaseAsync. Do this...

Run your app in debug mode breaking anywhere Open QuickWatch (SHIFT + F9) and enter Windows.Storage.ApplicationData.current.roamingFolder.path and copy the value (mine was C:\Users\jerfost\AppData\Local\Packages\{package name}\LocalState Browse to that location and open the Microsoft\Windows Store\ApiData directory Open the WindowsStoreProxy.xml file in a text editor Change CurrentApp/LicenseInformation/App/IsTrial to false Change CurrentApp/ListingInformation/Product/MarketData/Name to your unique product name That should do it. Hope that helps.




回答2:


You don't have to manually edit the XML everytime, CurrentAppSimulator does it automatically.

Just check your setting in the WindowsStoreProxy.xml and ensure that 'IsTrial' is set 'false'-

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

Remember - In-app purchases does not work in Trial version of the app.



来源:https://stackoverflow.com/questions/16241881/simulating-a-windows-8-store-apps-purchase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!