Sunday, January 25, 2015

Step by step Google Play IAP implementation with Corona SDK

Corona SDK is awesome. It is super easy to use.  In fact, a few lines in Lua is all you need to implement IAP for your Android app.  However, implementation is just a small part of the whole process to get IAP working. You will spend quite a bit of time setting up your IAP on Google Play server.

If you are trying to implement IAP in your app for the first time, it is not very obvious what you need to do. There are a lot of steps as you see below, but they are quite easy and it should take less an hour to do all of them

1) Become at least basic subscriber
You will need to be Basic or higher subscriber to use IAP feature in Corona SDK.  The free version of the SDK will not build the code that uses IAP API.

2) Setup project
Next, in your build.settings, add the following permission in your build.settings

   android =
    {        usesPermissions =

Also, in plug in section

    plugins =
        [""] =
            publisherId = "com.coronalabs",
            supportedPlatforms = { android=true }

3) Build initial version of your app with release key
You will need to tell Google that your app is using IAP. So, build your app using the release key.  Your app doesn't need to be completed.  It just need to have right permissions and is signed correctly.

4) Upload apk to Google Play in Alpha or Beta test
Once you get apk file signed with release key, you will have to create a new entry for it in Google Play developer console, then upload and publish your apk to Alpha or Beta testing.

5) If not, setup merchant account
You will need to have a merchant account to use IAP.  If you don't have one, set it up now.

6) Add IAP items
Once you have merchant account setup, and if your uploaded app has the right permission, you will be able to add items that you plan to offer to your game's players.

There are two types of items, managed and unmanaged.  The difference is that Google keeps track for managed item for you and you can look it up in future.  For example, if you let the players to remove banner ads for $0.99, the players should be recover it when they factory reset the phones and reinstall your app.

As of IAP V.30, purchasing records of unmanaged items are recorded on Google's server.  When the users use the items, you will have to call the server to let it know the item is consumed.  The users won't be able to buy the same item until it is consumed.

By the way, make sure you write down the item ids.  You will need to use them in your code.

7) Add test users
 To be able to test IAP in your app while it is in beta, you will need to add test users.  Go to the APK section of your app entry and click on Manage list of tester.

In the popup dialog, you can add list of test users.  The easiest way is to create Google Plus community, invite your test user to join that community, then add URL of that community so all members become test users.

8) Implement IAP logic
Now setup of Google Play side is completed.  You have to finish the IAP part of your application. Go to You can almost completely copy-and-paste the code there.

9) Upload your app with completed IAP code to Play Store and publish it in Alpha or Beta.
Even if it's iin Beta or Alpah test, you still need to fill in the descriptions, upload icons and screenshots.  When you have done all that, you can publish the app.  Do not promote it to production yet, just keep it in Beta or Alpha.

10) Announce the test URL to your tester
In APK section of your app, click on Manage list of testers again.  This time you will see the download link for your app.  If you don't see it, that means you have not published your app.

You can send this link to your testers. Only your testers can download the app using this link. 

11) Testing the IAP without getting charged
The testers can buy IAP items without being charged.  Test it until you are sure that it is working correctly.

12) Promote to production
When ready promote to production so anyone can buy your IAP items.

No comments:

Post a Comment