Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simulating a Windows 8 Store apps purchase

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?

like image 835
lysergic-acid Avatar asked Apr 26 '13 17:04

lysergic-acid


2 Answers

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.

like image 92
Jignesh.Raj Avatar answered Sep 28 '22 10:09

Jignesh.Raj


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.

like image 28
Santy Avatar answered Sep 28 '22 10:09

Santy