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
- 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.
- 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
- 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.
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