Skip to content
September 7, 2012 / iunkn

Supporting In App Purchase

Please refer this later blog post for In App Purchases.

The content in this blog post may not be applicable anymore.

———————————

Let’s say you want to ship a freemium game where you ship the game as free but you want to lock down on the higher levels or features behind a pay wall. With the r6 update, the metro plugin enables this scenario. Here is a step by step guide:

Working with In App Purchases before publishing to the Store:

When you want to expose in-app-purchases, you will want to test the purchase experience. For this, Windows 8 provides a way to test using a test mechanism, which I am exposing to Construct 2 via this plugin. Let’s see how you can add and test your in app offer before switching to production.

1. Set the Show Purchase property in Metro plugin to True. This will make sure that the user will be provided with a Purchase option in the Settings Charm.

2. Note that In App Purchase Feature Id is set as MyPaidFeature and In App Purchase Test Mode is set to True.  The feature id is used to identify your feature and for testing purposes the plugin supplies an xml file which is the representation of your feature in the Windows Store. Do not change this feature id. (If you want to change this, you will have to update the xml file as well.)

Property Sheet showing settings for turning on In App Purchase

3.Thats it! Now you are ready to use In App Purchase. You can use the following expression and trigger to base your options.

Triggered when InAppPurchase is completed by user.

Make sure to check if the user owns the feature during layout start.

[09/26/2012: Edited to add details on how to configure while submitting to store]

Switching to production

Once you are done testing, 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. Give something like “AdFreeExperience” or “Level2Unlock” etc, Note that this id is not visible to the user. You will get to define the user visible description and pricing details later in the process.

2. In Construct 2 project, set “In App Purchase Test Mode” to False and set the “In App Purchase Feature Id” to the string you set in Dashboard in step 1 above.

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 from Settings Charm, 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.

Important limitation: Currently the plugin supports only one in-app-purchase feature. Ie you cannot have two features (like Level 2 unlock for $1.49 and Level 3 unlock for $2.49. You can have only one feature for one price)

Advertisements

11 Comments

Leave a Comment
  1. Jan / Sep 7 2012 8:31 pm

    Looks like a really good Plugin, but when i have installed the plugin and open Construct 2 i get the error message: “Unable to load plugin in C:\… Cannot open file …\plugins\metro\common.js This Plugin will not available in the editor”

    • iunkn / Sep 7 2012 8:40 pm

      @Jan: Thanks for trying out. When you say you installed the plugin, did you run the install.cmd script from Admin command prompt? Please note that the script is assuming that system driver is C: and copying over things to C:. If your system partition is not C: please edit the install.cmd script to your system partition for example D: or something else.

      Also are you getting the error on just opening Construct2 or opening the sample? Make sure that you are on r102.

  2. gorbett / Sep 10 2012 3:38 am

    Which version of Construct 2 does this work with? I am using the beta r102 and receive the following error after exporting “Space Blaster” with the plugin and running in VS 2012:

    Unhandled exception at line 188, column 100 in ms-appx://220d9464-3c7f-452d-83c4-fd7c61b20e0f/c2runtime.js

    0x800a138f – JavaScript runtime error: Unable to get property ‘hi’ of undefined or null reference

    • iunkn / Sep 10 2012 5:47 am

      Windows8 RTM and r102 is what I have been using. Please make sure to turn off Mimifying when exporting. I just now exported SpaceBlaster with the plugin and was able to run it in VS2012.

      • gorbett / Sep 10 2012 5:03 pm

        It was mimify that was doing it. Unchecked and worked great! Any idea when that will be supported? Great plugin! Very interested in the progress. If you need anything from Microsoft to keep up the great work, let me know.
        Also, I could not get the command prompt to copy over the files from the plugin folder. I manually copied them.

  3. Eyehawk / Sep 27 2012 1:22 am

    Hi iunkn, this really is outstanding work, thanks for putting it all together!
    Sorry, a bit of a dumb question: How do I configure the in game purchases? E.g. how do I set prices, and how do I create different items to purchase? I’m currently using r7

    • iunkn / Sep 27 2012 6:19 am

      @Eyehawk: I have updated the blog above to answer your questions. Let me know if that helps.

      • Eyehawk / Sep 27 2012 7:41 am

        @iunkn – many thanks that clarifies things immensely! My app isn’t ready for submission yet, so I’ll have to wait until then to go through the steps. It’s a shame that we can’t have more than 1 IGP at the moment.

  4. eyemobi / Oct 10 2012 7:37 pm

    @iunkn – Just out of curiosity, once a user has made a purchase, does that information get saved to their profile? If the user then logs into another device (e.g. their surface tablet), and they install the game/app is their purchase still retained?

    • iunkn / Oct 10 2012 8:21 pm

      Yes. The purchase information is tied up to the Microsoft account they use to purchase from the Windows Store.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s