Introduction and Background
A small overview of in-app purchases in Windows Store platform, in this post I will only cover the short summaries of quickly editing the small modules that you have recently created and to enable users to purchase them to support your development environments. Building applications is a tough task, and programmers need to be given what they deserve. Sometimes, respect is just not enough. Sometimes, the module you created is a tough one and you have full rights to ask for some money in a repay. It is your choice to select a price that users have to pay before they can consume the service.
Windows Store allows you to simply create a block of code, around the service, feature or application itself. That code is capable of managing the payment information, client information and other required stuff to make sure the user pays you before they can access the information and the service you are providing them with. Windows Store holds information for users too, it knows if a user has already made the purchase. If so, Windows Store won’t bother the users again to make the purchase and will hold the information for that license, user has acquired.
App monetization methods
On Windows Store you are offered with many methods and ways to earn money and to get support for your development environments and stuff! A few of them are:
- Ads display in your application.
• The ads are of both types, static images and videos.
- Providing paid services in your applications.
- Asking for a pre-use purchase of your application. Paid apps.
You can ask for an upfront payment by your users. Many application developers use this method to support their development scenarios. This allows them to have an upfront payment to continue their programming and to support any of the updates to their clients. Not just this, the clients are also able to get free updates to the application later one.
But sometimes you want to allow your users to download and install the applications for free! This allows you to allow your users to try out your application. Users like free stuff, especially the stuff that is not available currently in their device’s marketplace. You can develop an application and start to offer a trial-period to allow users to use your service. If they like it, you can then ask them to purchase the license.
Otherwise, you can add a service separately that needs users to purchase it. You can add the price for it and allow users to purchase it. This method is very simple, helpful and handy! Your users can try out the application that they want to, and you can get the revenue for the features that were difficult to build and deploy. In this post, I will discuss and talk about the monetization methods by “in-app purchases” in Windows Store applications.
In-app purchases in Windows Store apps
In-app purchases requires you to have a Windows Store developer account and that you have published your application! In-app purchases are edited (and published) from the Windows Store dashboard. You create a new in-app purchase in the dashboard, you edit the details and then update the application’s code to call those in-app purchases and provide the users with a service.
If you do not have a Windows Store developer account, you can still edit the application, you can test the license information but you won’t be able to publish the application, you won’t be able to ask your users (if any!) to purchase the services. So, first step would be to create a new developer account. Register as a developer.
If you are all set up for publishing a new application, continue with the sections and by the end you will be able to include in-app purchases for earning some revenue for your development tasks!
Creating a new app
Although, for development purposes you can test the application for performing the purchases without an online application, or a developer account. For that, you can use CurrentAppSimulator object, instead of CurrentApp object from Windows Store API. CurrentAppSimulator allows you to perform actions
without having to call the active Windows Store APIs, and to just test the code in your application. This
lets you test many things in your application and how user interacts with your application.
However, if you do not like to waste time, you can just head over to the “hard core” stuff. Where you publish an application, create a new in-app and start consuming it and allowing the users to purchase it. First of all, head over to the dashboard (provided: You have a developer account!) and create a new application. Publish it to the store.
Note: Developing application, uploading the source code and getting it to be published after verification takes time. My application took 16+ hours. Yours should have to go through the same procedure so be patient. I assume that you are having an application ready.
Once your application is created, continue to the next section and start creating and developing for an in-app purchase.
Creating the in-app product
The in-app product first needs to be defined in the Windows Store and the team then needs to approve the service. Once the product service has been approved by the team, you can use the product ID of that service to program your application. The product ID is used to check the license information for the application and if user owns the license to use the service or not.
License Information
License Information object of the application holds the information about the license. License can be checked for,
- ExpirationDate
- IsActive
- IsTrial
- ProductLicenses
These properties can be checked to determine the information about license of the application (if your application is a paid application), otherwise you can check for licenses of the in-app products. The in-app products also have a license and they also have properties set up, like active, trial etc. You can check against them!
An example of this license information is something like this,
- var license = CurrentApp.LicenseInformation;
-
- if (license.IsActive)
- {
-
-
- } else
- {
-
- }
The same applies to in-app products! You would use the same method, the code for in-apps is in a later section so continue to read.
Create a product in Windows Store
You will be able to create a new in-app product online, on your application’s dashboard! Head over there and find the following option.
Figure 1: Windows Store showing IAPs option
Click on this option and it would take you a new page where you can create a new IAP! Click on, “Create a new IAP” and enter a new product ID.
Figure 2: Enter a new product ID here and click on “Create IAP”.
You may have read that you need to be sure of the name. You won’t be able to update or delete it once you publish it.
Editing the in-app product
You will then be able to update the properties for that product in Windows Store. This is when your updates and properties would need to be verified. You will get the following three properties that you can edit to make your product a bit “understandable”.
- Properties
• Type of the purchase:
• Consumables are those services that can be consumed. Like, 500 gold coins! Users can use them and re-purchase them.
• Durables are those who have a lifetime. Like a premium service of 30 days.
• Content type
• Keywords
• Tag
- Pricing and availability
• Base price
• A few other settings like Markets to sell the product in.
- Descriptions
• Language
• Description and title for the purchase. This is shown in the Windows Store.
You can edit the properties there, and then continue to submit it to the store. The team there would read the information and would approve it if there aren’t any problems with it. Chances are, it gets approved within an hour. Then you would continue to write the code to handle the products.
Remember: It takes at least one day to make the changes on the system. So, even if you upload the package along with the products, it would take one day for Windows Store to be able to start selling your products.
Writing the application to provide services
The Windows Store side is a very short process that you can perform in within less than 30 minutes. The longer part is to write the source code to handle the user’s license and to allow or request the user to purchase the license and service. The code is very short, intuitive and simple! I will explain the entire process here, so that it is very easy for you to get started earning revenues from Windows Store applications that you build.
Create a module
I wonder why this section even exists. Just create a module, a function or a service that performs some actions in your application. Suppose, you want to earn something from it. You can create it as a function, so that you can wrap the function within another code block that checks for a license. License information would be used to either allow the user to consume the service or to reject the request and to ask the user to purchase the service from Windows Store.
Add the license check-up!
I shared a code above, to determine the license for the application, you would do the same in case of in-app product too. You would see if a user has the license or not. The following code would do the thing for you:
-
- if (license.ProductLicenses["productId"].IsActive)
- {
-
-
-
- } else
- {
-
- }
You can use the CurrentApp.RequestProductPurchaseAsync(“productId”) function to allow the user to purchase the product from Windows Store. Windows Store would open a new window for the user to make a purchase. You can then (as its result) check if the user made the purchase or not. If he made the purchase, then allow him to use the service otherwise just end the request.
The common example for this would be like the following:
-
- var license = CurrentApp.LicenseInformation;
-
-
- variapLicense = license.ProductLicenses["productId"];
-
-
- if (iapLicense.IsActive)
- {
-
- provideService();
- } else
- {
-
- awaitvarresultOfPurchase = CurrentApp.RequestProductPurchaseAsync("productId");
- if (resultOfPurchase.Status == ProductPurchaseStatus.Succeeded)
- {
-
- } else
- {
-
- }
- }
This way, user would be able to purchase the item from Windows Store. The process is mostly similar to this one:
Figure 3: Windows Store purchase window is loading up.
Figure 4: Windows Store shows the details for the purchase the user is about to make. Also allows them to add a payment method to their account.
Figure 5: Windows Store shows the following methods (or any other, or less; depending on the country of users) to allow them to make the purchase.
This would then allow the users to make a payment and then it would update their licenses to be able to consume the service later. It would update the “IsActive” property of their license information.
Points of Interest
In this post you were taught how to earn revenue from your Windows Store applications. MSDN documentation has a lot of great resources available for developers to learn more about in-app purchases and services provided to developers to ensure that users pay for their services and for the users, to allow developers that they have indeed made the purchase and you should allow them to use the service.
There are many other topics that you should consider reading, such as:
- Allowing consuming of services like tokens.
- Managing the services from Windows Store.
- Adding more in-app products.
- Using receipts to verify the purchase status.
- Validating the receipts of services.
As a further read, you should consider reading “Enable in-app product purchases” guide on MSDN. I hope I have helped you with this post, and I think this is the last post for 2015, catch you in the next year.
Happy New Year!