Android In-app Purchases: Part 3 – The Final Step
If you’re looking to increase your Android app monetization you might want to learn more about in-app purchases. In the previous articles I talked about the high-level aspects of the topic and the initial steps to the actual implementation using Eclipse with the Android SDK.
Today, I will guide you through the final steps to implement in-app purchases and give you some personal advice about it.
Our app currently has a lot of dummy or “static response” data provided by Google. We should ensure the basic code we have created is working correctly before introducing our own SKUs, prices and other variables. You cannot test In-app purchasing/billing using the emulator. You will need to load your app onto an actual device that is running Android version 1.6 or higher. The easiest way to do this is to connect your device to your PC via USB and right click your app in Eclipse and choose “Run As Android Application”. Then click the “Buy” button in your app. If you see the following screen, you are on the right track.
Then click the “Buy” in the Google Play purchase dialog which should then create a screen similar to this:
1. Creating Your Own SKU
Once we have successfully tested our code using Google’s static response data, we can load our own SKU into the app. Find the line in your code that says:
static final String ITEM_SKU = "android.test.purchased";
Change what is in the parentheses to the SKU you want for your own product. The line of code for my app became:
static final String ITEM_SKU = " pro.template.pack ";
2. Upload APK
Now package your code (full export with Keystore signature) and upload it to the Developer Console. If this is the first time you have uploaded an app to Google Play, follow the steps in the Android app publishing tutorial, and then come back here. Be sure to “ALPHA TESTING” rather than “PRODUCTION”.
3. List Products in Developer Console
The In-App Products page in Developer Console only appears if you have a Google Wallet merchant account and the application’s manifest includes the com.android.vending.BILLING permission. Once you have uploaded an APK with the correct permissions, you will have the option to list your product by clicking “Add new product“.
Once you click “Add new product” there are seven pieces of information you will need to enter. The process is similar to setting up a paid app:
- Product Type – the first thing that will happen is that you will get a dialog box in which you designate the product as Managed, Unmanaged or Subscription
- Product ID – in the same dialog box, you will enter the Product ID. This is also referred to as your SKU. It is not visible to your users, but it should be unique and descriptive. The letters can only be lower case, but you can also include numbers, underlines and dots. Once you press Continue, you will enter the rest of your information.
- Languages and Translations – this works the same as Languages and Translations for the app itself. You can localize by entering custom translations or selecting for Google to provide the translation of the title and description. The default is that In-app products inherit the app’s default language.
- Title – This will be visible to the user. You can include numbers and letters (upper and lower case.) For optimal viewing by users, the title should be less than 25 characters, but it can be up to 55 characters long.
- Description – this is a required field and will be visible by users. Should be very descriptive. Can be up to 80 characters long.
- Price – a default price in your home currency is required. You can also specify prices for other currencies as long as they are listed as one of the app’s target countries. You can manually enter a price for a currency or allow Google Play to provide the conversion.
- Publishing State – this is at the top of the screen. The default is “ – Inactive”. Click the button and choose Activate. Once you do this, it will take a few hours to propagate across Google’s servers.
It will then take a few hours to propagate through the Google servers. With your app itself Published in Alpha and the In-app product in Active status, you are now ready to test.
Google does not allow us to make test purchases with the same Google ID (Gmail) as we use for the Developer Console. You have two options:
- Recruit testers – simply get Gmail addresses of willing friends, family and colleagues. They will need to enable USB Debugging on their device. USB Debugging enablement can vary by device, so do a Google search to learn how to guide your tester on this. Help them help you.
- Create your own alternate Google IDs – you can create alternate Gmail accounts to test on your own device. When you do this, you will need to go into Settings on your device and enter this account under Users, then log into the device with it. This can be a little tricky, and you might need to Google how to accomplish this with your particular device.
Once you have some Google IDs for testing, click on Settings for your app in the Developer Console and scroll to the “LICENSE TESTING” section. There, you can enter up to 400 accounts for testing, then press Save at the top of the screen. You and your testers can now make as many test purchases as needed without fear of incurring actual charges. If you skip this step, charges will be incurred as I learned when I received a PayPal email “You have authorized a payment to Google”.
To test In-app purchases, you cannot simply run the app from Eclipse while your device is connected as in the earlier test phase. Now you will need to export the app (including signing it with your Keystore) and copy the APK to the test devices. Make sure all previous versions of the app are uninstalled, then install the new APK and test away.
Once your testing is complete, you will need to upload the latest version of your APK to the Developer Console and push to “PRODUCTION”.
This article follows a “happy path” meaning everything goes well. But in reality, things did not go perfectly for me, and they probably will not for you. Implementing In-app purchases is a multi-step process that is more complex than I had anticipated. There are fewer online resources for learning than I would have expected for such an important topic. In fact, while creating this tutorial, I had to enlist a professional developer (found through Fiverr) to untangle the mess I had created.
Do not let the complexity hold you back. Read the documentation that Google provides at android.com. Follow this and other tutorials. Google any errors you encounter in your code. Enlist professional help if needed as I did. Be patient but persistent. Do move forward with your app the way you feel it should go. Good luck. And always, please use the comments section below to share your experiences.