Windows store app: How to test in-app purchases

I just added a simple in-app purchase in my latest app to allow for the user to remove the advertisement. Before releasing the app I wanted to try the in-app purchase function to see if everything worked out as it should. To just try the function you simply have to change your

Windows.ApplicationModel.Store.CurrentApp

to

Windows.ApplicationModel.Store.CurrentAppSimulator

and run your purchase function. Simple enough.
But this testing function has a limitation in that it resets every time you start the app. I wanted to see how it looked after purchasing and then restarting the app (to make sure the ads were removed on start-up if the purchase had been made).

It turned out it could be done by finding a file on your computer that should be in the following path:

C:\Users\YOURUSERNAME\AppData\Local\Packages\YOURAPPGUID\LocalState\Microsoft\Windows Store\ApiData

where YOURUSERNAME is, well, your user name and YOURAPPGUID is the identifier for your app (find this in your package.appmanifest file in the packaging section). The file is called WindowsStoreProxy.xml and looks like this:

<?xml version="1.0" encoding="utf-16" ?>
<CurrentApp>
    <ListingInformation>
        <App>
            <AppId>00000000-0000-0000-0000-000000000000</AppId>
            <LinkUri>http://apps.microsoft.com/webpdp/app/00000000-0000-0000-0000-000000000000</LinkUri>
            <CurrentMarket>en-US</CurrentMarket>
            <AgeRating>3</AgeRating>
            <MarketData xml:lang="en-us">
                <Name>AppName</Name>
                <Description>AppDescription</Description>
                <Price>1.00</Price>
                <CurrencySymbol>$</CurrencySymbol>
                <CurrencyCode>USD</CurrencyCode>
            </MarketData>
        </App>
        <Product ProductId="1" LicenseDuration="0">
            <MarketData xml:lang="en-us">
                <Name>Product1Name</Name>
                <Price>1.00</Price>
                <CurrencySymbol>$</CurrencySymbol>
                <CurrencyCode>USD</CurrencyCode>
            </MarketData>
        </Product>
    </ListingInformation>
    <LicenseInformation>
        <App>
            <IsActive>true</IsActive>
            <IsTrial>true</IsTrial>
        </App>
        <Product ProductId="1">
            <IsActive>true</IsActive>
        </Product>
    </LicenseInformation>
</CurrentApp>

I have highlighted the two lines that you need to edit. Change the ProductId to whatever you’ve named your “product” in your code to and you are ready to test your app with the purchases complete.

Note: If you happen to ruin the file in some way, just remove it and VS will generate a new one for you.

One thought on “Windows store app: How to test in-app purchases

  1. Looks like you can name and place the file anywhere (i.e. not just C:\Users\YOURUSERNAME\AppData\Local\Packages\YOURAPPGUID\LocalState\Microsoft\Windows Store\ApiData\WindowsStoreProxy.xml)

    Excerpt from https://code.msdn.microsoft.com/windowsapps/Licensing-API-Sample-19712f1a

    StorageFolder proxyDataFolder = await Package.Current.InstalledLocation.GetFolderAsync(“data”);
    StorageFile proxyFile = await proxyDataFolder.GetFileAsync(“trial-mode.xml”);
    licenseChangeHandler = new LicenseChangedEventHandler(TrialModeRefreshScenario);
    CurrentAppSimulator.LicenseInformation.LicenseChanged += licenseChangeHandler;
    await CurrentAppSimulator.ReloadSimulatorAsync(proxyFile);

Leave a Reply