Skip to content
October 2, 2012 / iunkn

Trials and In App Purchase revisted

The plugin now supports trial version of Windows 8 apps for Construct 2 and also in-app-purchases are revamped significantly.

Trial version

Let’s say you want to provide a feature limited trial version of your game in Windows 8. All you need is from within Construct 2, you need to check if the app is currently running in trial mode then you want to restrict some of the features from your app. For this purpose, the plugin provides a simple check: Is in Trial mode which returns true if you app is in trial mode and returns false if your app is in full purchase mode. Note that if your game is a free app, Is in Trial mode will always return true.

Use Is in Trial mode condition to check if your app is currently in trial mode and restrict functionality.

You can limit the game’s feature and once you feel you want to prompt the user, you can do so and direct the user to the purchase page with this action: Request App Purchase.

Limit the feature of the game with Is In Trial Mode check and prompt the user to buy using Request App Purchase option.

After the user completes a purchase you will receive the trigger On Purchase Completed. At this point, you can check if the app is in trial mode again and activate the features that you want to expose in full mode.

Once the user purchases the app/upgrades from trial mode, you can enable functionality for full version.

In app purchases

Earlier the plugin used to support only one kind of in-app-purchase. Now I have extended it to supported as many in app feature kinds as you want 🙂

Condition: Is In-App Feature Purchased – supply the feature id which you want to check. This is valid only in case of a full version – either a free or a non-trial version of the game.

Check if the user has purchased an in-app-feature and if so, activate the feature. Note that In app features can be purchased only in full mode. Not in trial mode.

Action: Request In-App Purchase – supply the feature id which you want the user to purchase.

Prompt the user to buy an in app feature and enable a feature when the user buys it.

OnPurchaseCompleted will be invoked when the user finishes purchasing. At this point, check if your feature is purchased with Is InApp Feature Purchased and enable the feature.

Testing trial mode/in app purchases

Set “Purchasing Test Mode” to true in Metro object properties in Construct 2. This means that the exported app is going to use the in-app-purchase-testing-only.xml file to simulate a listing of your app in the Windows Store. You can edit this file to simulate how you want to display your app – for example free/ with trial/ with in app purchase etc,.

Set Purchasing Test Mode when you are testing your app for scenarios around trial mode/purchasing.

You will be able to see in-app-purchase-testing-only.xml in the project when you export your game as Windows 8 app. Edit it as required:

1) By default I have set up the file for a trial version. If your game is a free game, change IsTrial to false in VS2012:

            <!-- Set this to false if you are going for a free app-->

2) By default I have provided 2 in app features MyPaidFeature1 and MyPaidFeature2. Feel free to change these to something meaningful and use them throughout your project in Construct 2. Give something like “AdFreeExperience” or “Level2Unlock” etc, Note that this id as such is not visible to the user. You will get to describe a user visible description later.


        <!-- Make sure you use the same Id here, while referring in Construct 2 and while
             you upload your app for certification in the Windows Store. Note that you can
             set the price values in the ListingInformation section above--> 
        <Product ProductId="MyPaidFeature1">
        <Product ProductId="MyPaidFeature2">

You can also change the price information for your in-app-purchases. Make sure to change MyPaidFeature1 in all the places within this xml file.

        <Product ProductId="MyPaidFeature1">
            <MarketData xml:lang="en-us">

Edit: Added the following section on JavaScript console on 10/09/2012

When you are running with VS2012 and you test the trials and in-app-features, I have added some helpful messages to keep track of what is going on wrt the purchases. If you see the JavaScript Console below(you should be able to see this in the default view. If not, type in JavaScript console in the Quick Launch box on top right corner of the VS2012 window), you will see messages whether your purchases went through etc,. For example, you can fail a purchase and see if you game is behaving well and double check with the output below to what you are expecting. Here you can see I purchased the full version of the app and failed a purchase request for feature “MyPaidFeature1” and then tried again and succeeded the request. This logging happens only if you are using the test mode of course.

Important: Select a feature id like (“AdFreeExperience” or “GoldPack”) and use it in the above xml in ProductId field and also in the calls in Construct 2 like Is In-app feature purchased – “AdFreeExperience” and Request In-App Purchase “AdFreeExperience”. Since this is a testing environment, purchasing is not persisted when you restart the game.

Switching to production

Once you are done thorough testing with the simulated environment above, you will have to do the following steps to prepare your app for Windows Store submission and before running WACK:

1. In the Windows Dev center Dashboard, while you are going through the steps, you will get a chance to enter the In-App-Purchase Id in the “Advanced Features” step. It is just a string.  You will get to define the user visible description and pricing details later in the process. This should be same as the ones that you have tested with. For example “AdFreeExperience” or “Level2Unlock”

2. In Construct 2 project, set “Purchasing Test Mode” to False. Double check if you are using the same ids from step 1. (Very important)

3. At this point, when you export the project, you are configured for using the Windows Store payment gateway. Of course, when you try to run the app and invoke purchase, now you will get some error like “This app is currently not in the Windows Store” (or something similar). This is understandable because the app is not listed yet. Once the app gets published in the store, the purchase action will work fine.

The key point to note is that you don’t get to do a real testing of the purchase scenario in production environment (which makes sense) before the app is listed. So you will have to use the testing method described above to thoroughly test things and switch to production environment with the above 3 steps and submit your app.



Leave a Comment
  1. eyemobi / Oct 2 2012 3:50 am

    Wow! Outstanding work iunkn! Many thanks for putting this together 🙂

  2. Eyehawk / Oct 13 2012 11:18 am

    Hi iunkn, things have been going well recently, but I noticed something strange recently:
    On my main PC, in the last 2-3 days whenever I preview the game from VS2012, in the console the following error appears:

    “HTML1701: Unable to add dynamic content ‘ a‘. A script attempted to inject dynamic content, or elements previously modified dynamically, that might be unsafe. For example, using the innerHTML property to add script or malformed HTML will generate this exception. Use the toStaticHTML method to filter dynamic content, or explicitly create elements and attributes with a method such as createElement. For more information, see
    [Construct 2] Error loading WindowsStoreProxy.xml: WinRTError: The system cannot find the file specified.”

    The game will start, and run for between 10-30 seconds, then it crashes, and the debugger returns:
    “Unhandled exception at 0x000007FDF86D47DB (atidxx64.dll) in WWAHost.exe: 0xC0000005: Access violation writing location 0x000000EA672DFFFC.”

    Now the weird thing is if I take the capx, export it as a Win8 app, then run in from VS2012 from MY LAPTOP, there are absolutely no errors. Just as an experiment, I installed VMWare viewer – also no issues. The only difference I can see is that my desktop is running 64bit Win8 (others are running 32bit).

    Also, note that if I create a non-store package, it crashes on the desktop but not on the VM or laptop.

    Any idea why the desktop could be failing with the preview?

    • iunkn / Oct 13 2012 5:52 pm

      The HTML1701 error is from jquery-1.7.1.min.js which Construct 2 uses. I have also been getting this error from the beginning and I have been ignoring it (not really sure if we can safely ignore it though).

      WindowsStoreProxy.xml is a file which Construct2’s Windows8 plugin uses. If you are not using that plugin, you can right click this file in the Solution Explorer of VS2012 and “Exclude from Project” and you should be fine.

      atidxx64.dll looks like AMD’s driver. You might want to get the latest driver for your PC’s graphics card. This also explains why you are not getting this failure in your other computers.

      • Eyehawk / Oct 13 2012 7:38 pm

        Many thanks iunkn, that helps a lot! It doesn’t sound like those 3 errors are critical, so I’ll go ahead and submit my game today to MS. I was only using the default Win8 plugin for roaming data, but I’ll switch to your Metro plugin one for that instead.

        Do you know in VS2012 if I can untick “internet” under the capabilities tab to still be able to access Roaming data?

        • iunkn / Oct 13 2012 8:43 pm

          AFAIK, the internet capability for an app is not needed for Roaming data and the Guidelines do not talk about it. But I haven’t tested it without the internet capability.

          (Note: In case you need to have internet capability, the certification requirements state that you will have to provide a privacy statement while submitting.)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s