In this post I am going to talk about building "Buy Now" functionality of a Windows Phone 7 trial app. I will give several different strategies/approaches with examples and source code.This post is also focused on some important thing that you need to consider when implementing the "Buy Now" option.

To begin with, in short Trial mode gives you the option to allow users to try your application before buying it. The trial license does not expire, but is replaced by a full license when the customer purchases the application. That is why it is very important to provide a suitable and user friendly way for purchasing the full version of your WP7 app.

The easies way to implement a "Buy Now" functionality is to use the standard approach with navigation between Pages using NavigationService. At first we will create two separate WP7 Pages: FullFunctionPage.xaml and BuyPage.xaml.

FullFunctionPage.xaml - this is the page that users will see if using the Full version of your app.

BuyPage.xaml - this is the page that will appear when a user wants to buy your app

Although it is it a good solution it is not suitable in all cases, moreover if your app has a cool UI, for example with lots of animations in a particular style then users will expect the "Buy Now" functionality to be just so attractive or at least in the same style.

Implementing "Buy Now" functionality using PopUp

In this approach we use PopUp instead of PageNavigation. We will use the Coding4Fun MessagePrompt control because it is fully customizable and has a lot of benefits in comparison with the standard Popup or Message Box. Like for example we can add composite content as a body, we can add customized Image buttons, etc. (You will have to add references to : Coding4Fun.Phone.Controls.dll and Microsoft.Phone.Controls.Toolkit)

In this example we will use the previously created BuyPage.xaml WP7 Page as a content of the Message Prompt. We will also remove the default popup buttons and will change the color of the Overlay. Here is how we determine which page is visible and how the "Buy Now" popup should look like:

That was all about how to implement "Buy Now" functionality for your WP7 Trial application using different techniques. Stay tuned with the rest of the content and Part 3 of this series: Creating a Windows Phone 7 Trial Application |Part3: Advanced Buy Now implementation where I will demonstrate a "Buy Now" implementation with automatically show/hide message depending on the calculated time since the Trial first launch date.

How are we supposed to know the guid of the app before we submit it to the marketplace?

@Dimitris

posted by: winphonegeek on 5/29/2011 9:34:40 PM

Short answer: You can't.

In order to get an id assigned to your app you have to publish it first.

However, according to the documentation if the ContentIdentifier property is set to null, the detail page for the calling application will be displayed.
So it seems that you only need to set this property in cases when you want to show details for an application different from the calling one.

pros/cons for different buynow options??

posted by: om on 11/16/2011 11:15:45 PM

From the ways shown above to get the BuyNow body contents, ss one way better than other or is it simply a matter of preferece?

Thanks for this wonderful series.

RE: pros/cons for different buynow options??

posted by: winphonegeek on 11/17/2011 2:11:25 PM

It is a combination of personal preference and also what will work best with the specific task that you have. For example you might decide that using a popup will be annoying for the users in one case, while in other cases using a popup will be the only option.

RE: pros/cons for different buynow options??

posted by: om on 11/19/2011 6:29:34 AM

Thank you winphonegeek.

Urgent reply needed

posted by: XX on 4/26/2012 2:01:26 PM

Do you have any idea how we check this functionality during development phase of a project. Does partnernet has any provision for this?

You have used Microsoft.Phone.Marketplace in your code. Can we also implement this using Microsoft.Xna.Framework.GamerServices - Guide class ?? Or there is any specific difference between these classes??

After the Sale

I have a question regarding after the sale. The answer was probably here somewhere and I probably missed it. If so, I'm sorry.

Once the sale is made, is the app "reset" such that it will flow through the App.xml and the test for a full or trial license will automatically be done or is control simply returned and now a test must be made to see if the sale was complete?