Recently I wanted to offer my customers the opportunity to donate some money. No extra features, just a clean donation option.
In-app purchases seemed to be the best option. The idea is to have a list of products which have a price and contain “donate” in their product ID (Fig. 1).
In the app the list of products can be retrieved and shown when a donate button is tapped. If donations have been given can be checked by enumerating the existing licenses and looking for the “donate” term (Fig. 2).
Reasonably simple right? Well the principle is simple, but in-app purchases are a bit tricky to develop, debug and get through certification. (It took me 7 submissions to get it right..)
Those are the things that can result in certification failure:
- no internet connection -> exception
- store does not respond properly -> exception
- error message looks to much like a error message -> fails requirement 3.2
The CurrentApp static class offers the methods to retrieve LicenseInformation and to execute purchases, but it won’t function until the app is actually released. Therefore you have to use the CurrentAppSimulator – conditionally depending on the build mode. For example:
Even in the certification environment, the store does not know your app, which results in an exception!
As you usually need to handle this, its common practice to show a MessageDialog informing the user what has gone wrong. The dialog should not look like a error message, but rather like a information, otherwise the tester might decide to let you fail said requirement 3.2!
As I want to offer in-app donations in multiple of my apps, I created a UserControl for it – the AppBar button you saw above.
I set up a code sample at MSDN, so you can take a look at the code there =)