Skip to content
October 10, 2012 / iunkn

Trials and purchases in Settings Charm

This post assumes that you have already read Trials and In App Purchases revisited post and are familiar with the related terminology introduced there. (I have added a additional section on JavaScript console to the above mentioned post which will help you better test your trials/purchases. So make sure to give it a read).

As you know, the plugin already supports adding Help, About and Preferences pages to the app settings for your game, accessible from the Settings charm.

Aside: I get asked why we would want to support these pages when you can expose every preference (like audio/music controls etc,.), Help or About through the game’s main UI. The answer is that Windows 8 introduces the concept of accessing the app’s settings (in fact Windows’s settings) in a consistent and reliable manner. It is in the best interest of the user that you would want to consider doing this. If not, users might be frustrated when you don’t have these information exposed via app settings/settings charm, while every other app exposes it.

The plugin also supports a Purchase page if you chose to enable it. By default it is turned off. This is because it needs a little bit of work from your part to customize that page properly. It is really easy. Trust me. Besides, you stand to gain by supporting this because the more places you provide an option for the user to make a purchase, the better (of course balancing subtlety to discoverability is important else you user might hate it).

Alright, the first thing to do is to opt-in to show the Purchase page by setting the Show Purchase option to True:

After you have enabled it, go ahead and export your project. As discussed in Trials and In App Purchases revisited you can edit the In-App-Purchase-Testing-Only.xml file in your VS2012 project to reflect your strategy for monetization (trial true/false, features etc,.).

Now, open up Settings-purchase.html and you will find the code below: If your app uses trial version then you will find this part of the code useful. All you have to do is change the highlighted text to whatever you want. If you find the generic text useful enough, you don’t have to change anything.

// If in trial mode, prompt the user to upgrade to full version
if (!currApp.licenseInformation.isActive || currApp.licenseInformation.isTrial) {
  currApp.loadListingInformationAsync().done(
  function (listing) {
    // Provide pricing info if possible
    userPrompt.innerText = "Please consider upgrading to full version for: " + listing.formattedPrice + ".";
    showTrialUpgradeOption(divPurchase, purchaseContext, "Upgrade");
  },
  function (errMsg) {
    userPrompt.innerText = "Please consider upgrading to full version.";
    showTrialUpgradeOption(divPurchase, purchaseContext, "Upgrade");
  });
}

If your app supports in-app-purchases you will find a similar section of code as below. You will have to obviously update the featureId variable with the string that you have chosen to use throughout your project and also update the greeting string visible to your user. (If your app does not have any in-app-purchases, go ahead and delete this section from settings-purchases.html)

// If already in full version, prompt the user to purchase in-app-feature
var featureId = "MyPaidFeature1";
if (!currApp.licenseInformation.productLicenses.lookup(featureId).isActive) {
  currApp.loadListingInformationAsync().done(
  function (listing) {
    // Provide pricing info if possible
    var featureListing = listing.productListings.lookup(featureId);
    userPrompt.innerText = "You own the full version of this app. Please purchase Pink Monsters at " + featureListing.formattedPrice + " for added fun!";
    showFeaturePurchaseOption(divPurchase, purchaseContext, "Purchase Pink Monsters", featureId);
  },
  function (errMsg) {
    userPrompt.innerText = "You own the full version of this app. Please purchase Pink Monsters for added fun!";
    showFeaturePurchaseOption(divPurchase, purchaseContext, "Purchase Pink Monsters", featureId);
  });

I told you it would be easy! You can just change the texts mentioned above and you get a custom tailored purchase option for your game in the app settings part of the Settings charm for your game. Of course if you are little more into programming you know that you can extend the code above to more than one in-app-purchase etc,.

If you are still not sold and you want to find a live example which uses the above method to expose a purchase pane, please go ahead and check out Blast the bricks game that I wrote with Construct 2 and the Metro/Windows8 plugin.

Advertisements

15 Comments

Leave a Comment
  1. eyemobi / Oct 10 2012 4:30 am

    Great work iunkn! Thanks from all of us aspiring Win 8 mobile indie devs! 🙂

  2. Eyehawk / Oct 14 2012 5:31 am

    Hi iunkn, sorry for a silly question: I’ve put in a trial-feature using the the metro plugin, but no IGPs. Apart from setting test to False in the Metro plugin prior to Productionization, I didn’t need to do anything else right?

    • iunkn / Oct 14 2012 9:42 am

      Yes, that’s right. Once you have tested with test setting to true, you can change it to false before submitting for certification.

  3. eyemobi / Oct 14 2012 9:47 am

    Fantastic many thanks for your invaluable help! 🙂

  4. Eyehawk / Oct 25 2012 2:12 am

    Hi iunkn, I’ve got an app deployed, but I’ve noticed that the Trial Mode appears to not be activated, i.e. the whole game is currently unlocked. Is there something else I needed to do to enable the Trial mode in production? In the In-App-Purchase-TestingOnly.xml, the true flag is set, but where is this set for production?

    • iunkn / Oct 25 2012 2:25 am

      While you submitted for certification, from the dashboard, did you set the “Selling Details” section which gives you option for “Price tier” and “Free Trial Period” ?

      You can create a new release and set these values and resubmit for certification. (The xml file is only for testing locally).

  5. Eyehawk / Oct 25 2012 2:33 am

    Oh, no I didn’t realize I had to set that, I’ll have a look now. I just noticed that if in the Metro Plugin in C2, I set “Purchase Test Mode” to False, and then preview it in VS2012, that the Trial mode is also not activated. Should Trial Mode still work when it’s set to false?
    (It works in True/Test mode)

    • iunkn / Oct 25 2012 3:10 am

      Once you set the “Purchase Test Mode” to false, the Windows Store is the authoritative source of information for trials. But since the Windows Store knows about your app only after you pass certification, it will treat as full version if you set it to false. So it is strictly for testing purposes only.

  6. Eyehawk / Oct 25 2012 2:44 am

    Hey iunkn, just to double check, should I set under Selling Details:
    >> Price tier to = 1.99 (or whatever price)
    >> and Free Trial Period to = Trial Never Expires?

    The trial in my case basically limits the player to the first 5 levels, and then once the user has made the purchase, the remainder of the levels get unlocked.

    • iunkn / Oct 25 2012 3:12 am

      Correct. In your case, you can go for “Trial never expires”.

  7. Eyehawk / Oct 25 2012 3:15 am

    Fantastic! – You’re a legend thanks iunkn! 🙂

  8. Eyehawk / Oct 30 2012 7:47 am

    Hi iunkn, I’m not sure what’s happened, but the latest release went through, and the trial functionality still doesn’t activate, so all levels look like they’re unlocked. On top of this, pricing in the store has gone a bit haywire, i.e. a price is set on it if you look under “all prices”, but then if you filter by paid apps, it shows free.
    I’m wondering if this is because right at the start, on the first release, I didn’t pick that the app was a trial app. On release 2, it didn’t give me an option to pick trial anymore.
    I might have to try using IGPs rather than the trial period to fix this.

    • Eyehawk / Oct 30 2012 9:40 am

      Sorry, sorry! False alarm 🙂 I think because I had installed the game before, it allowed me to install it for free. I fired up Win 8 on a VM, and the trial mode appears to be good. Phew, stress averted :p

  9. Tringio / Jan 27 2013 6:02 pm

    I am getting a blank screen after exporting to windows phone 8 in C2 [r114]. If i disable Metro plugin then everything works. I used the sample Monster Project , the behavior is same please help.

    • iunkn / Jan 27 2013 6:20 pm

      Sorry, I have not yet had a chance to play with exporting for Windows Phone 8.

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