Windows-8.1

Add in app purchases in your Windows Phone App

In app purchases is an excellent way to increase your revenues from your Windows Phone app. It lets you distribute your app for free and then charge the users for some added features or service. I will show you how you can easily add it in your app. You would need an active Windows Phone developer account for this tutorial as even for testing purposes you need to create a product for your app.

Step 1. Start off with submitting your app as beta version in the marketplace or if your app is already live then skip this step

Go to Windows Phone developer portal and submit a new app at https://dev.windowsphone.com/en-us/AppSubmission/Hub

 

Go to App Info and fill in the details. Reserve your app’s name and choose its category.

 

Go down to More Options and choose distribution channel as Beta. Add the live account email ids of your beta testers.

 

 

Browse and upload the XAP package for the project that you compiled earlier. You will need to fill in all the mandatory fields and upload the app icon and screenshot too.

 

Submit the app and go to App details page and note down the App ID from there.

 

Step 2. Update App ID and Publisher GUID in WMAppManifest.xml of your project


 

Step 3. Add a product to your app in Windows Phone Developer portal


 

Products can be of two types, consumable and durable. Consumable products need to be re-bought once used where as durable products need to bought only once. Fill in the details of your product and save it.

 

Add title, description and product icon.

 

We have successfully created a beta app and have also added an in app product for it. Now we need to move to the coding part.

Step 4. In app product listing

  1. The file in_app_purchase.xaml shows the XAML that could be used to list the in app products. Copy and paste in in the ControlPanel of your app.
  2. Next a clss ProductItem has been defined in file product_item.cs which is will contain the information about the product. Copy and paste it above the constructor in the MainPage.cs
  3. Lastly place the code in in_app_purchase.cs in MainPage.cs which will populate the products for the current app.

Step 5. Buy an Item ButtonBuyNow_Clicked is the event handler on click of Buy now button. It takes the user to his wallet where he can purchase the product.
The screenshot shows the product listed in the app.

Remove ads

That’s all you need to do to let the user buy any in app product from your app. I have posted another tutorial where I will show how IAP can be used to implement blocking ads in your app. That way you can offer the app free with advertisements to your users and let them make an IAP if they wish to remove the ads

Download full project WAT-Test.zip

Vivek Maskara

I am pursuing BTech in Software Engineering from Delhi Technological University. I develop apps, create websites and blog about my app experiences.

  • Faysal Ahmed

    I get the following error HResult 0x805A0194 in the ListingInformation li = await Store.CurrentApp.LoadListingInformationAsync(); code line

    • Inzi Butt

      did you get that working. i am encounter this problem too.

  • Inzi Butt

    change product id with app id from store but can not figure out which id is now paste in publisher id. plese help.

Read more:
How to create your first Windows Phone app
How to change the App name and Tile name of your Windows phone app
Data binding in Windows Phone app – One way binding
Close