[Resolved] Google Play In-App Billing

I implemented Google Play In-App Billing in my previous game app, but it looks like things have changed, and I’m a little bit at a loss after looking at the  Store API pagesLicensing API pages as well as Android Developer doc pages.

 

The In-App Billing guide for Corona seems to be out of date too – or at least, I don’t feel like it could help me with implementing the Google Play In-App Billing now.

 

I also checked the In-App Billing sample code (CoronaSDK > SampleCode > Store > Licensing), but I feel I need a little more explanation.  What is the difference between Store API and Licensing API?  Can we still use store API for Google Play In-App Billing, or do we now need to work with Licensing API only?  Or do we need to use both?  How does it really work?

 

Also, what I’m so not sure about is how to handle consumable items.   In this Android developer doc, it says we’d need to send a _ consumePurchase  _call for consumable items.  But I don’t see any API calls in Corona sample code that resembles anything like consumePurchase function.

 

I’d so appreciate any tips, pointers and suggestions as to how I may proceed from here.

 

Naomi

 

Edit:  BTW, I’m now using daily build 1054.

Naomi,

 

Corona currently uses version 2 of Google In-App Billing, not version 3.  Version 2 supports both managed and unmanaged purchases, and the consumePurchase() function is not an option, nor necessary.  The only thing you have to watch out for is don’t let the end-user purchase a managed item that has already been purchased, or else they’ll get an “Already purchased” error from Google Play onscreen.  Although, your app should already know what was purchased and shouldn’t be an issue except in the case where the end-user is making purchases between 2 different devices, in which case, restore is your only option.

 

Google Licensing (aka: LVL) is only used for copy protection.  Google is just being a bit pushy about this service, because they nag you about it when setting up in-app purchases and expansion file support.  We’ve actually just released Google Licensing support now.  Please have a look at our documentation for this feature via the link below.  Also check out sample project “Store/Licensing” for an example.

http://docs.coronalabs.com/daily/api/library/licensing/index.html

Thank you so much, Joshua.  That explains it.  It sounds like I just need to implement In-App Billing the way I did the last time around.

 

Also, it’s good to know about Google Licensing.  Am I correct to understad that we can use this LVL service to ensure APK file is somewhat protected from piracy?  Meaning, if I use this service, and set my app to be “paid”, and if I don’t release any other APK file outside Google Play, when anyone tries to install my paid app outside of Google Play without paying, it wouldn’t install?  And perhaps requires or prompt the user to actually pay for it?  

 

If that’s the concept behind it, it sounds like I can release paid version without worrying about it being utterly unprotected.

 

Thanks again!

 

Naomi

How Google Licensing works is that you are supposed to call our “license.verify()” function on application startup, which sends a network request to Google Play to verify that the currently running app has been purchased on that device.  Once verified, you should store something on your end to indicate that your app was correctly purchased or use LVL’s caching feature via a policy that you can set in your “config.lua” file.

 

Now, the reason you should verify the app on startup every time is in case your app was copied to another person’s device.  This is possible with an LVL enabled app because Android allows those types of apps to be installed on external storage (ie: the SD card) making them publicly accessible.

Ah, got it!  Thank you so much, Joshua.

 

Naomi

Naomi,

 

Corona currently uses version 2 of Google In-App Billing, not version 3.  Version 2 supports both managed and unmanaged purchases, and the consumePurchase() function is not an option, nor necessary.  The only thing you have to watch out for is don’t let the end-user purchase a managed item that has already been purchased, or else they’ll get an “Already purchased” error from Google Play onscreen.  Although, your app should already know what was purchased and shouldn’t be an issue except in the case where the end-user is making purchases between 2 different devices, in which case, restore is your only option.

 

Google Licensing (aka: LVL) is only used for copy protection.  Google is just being a bit pushy about this service, because they nag you about it when setting up in-app purchases and expansion file support.  We’ve actually just released Google Licensing support now.  Please have a look at our documentation for this feature via the link below.  Also check out sample project “Store/Licensing” for an example.

http://docs.coronalabs.com/daily/api/library/licensing/index.html

Thank you so much, Joshua.  That explains it.  It sounds like I just need to implement In-App Billing the way I did the last time around.

 

Also, it’s good to know about Google Licensing.  Am I correct to understad that we can use this LVL service to ensure APK file is somewhat protected from piracy?  Meaning, if I use this service, and set my app to be “paid”, and if I don’t release any other APK file outside Google Play, when anyone tries to install my paid app outside of Google Play without paying, it wouldn’t install?  And perhaps requires or prompt the user to actually pay for it?  

 

If that’s the concept behind it, it sounds like I can release paid version without worrying about it being utterly unprotected.

 

Thanks again!

 

Naomi

How Google Licensing works is that you are supposed to call our “license.verify()” function on application startup, which sends a network request to Google Play to verify that the currently running app has been purchased on that device.  Once verified, you should store something on your end to indicate that your app was correctly purchased or use LVL’s caching feature via a policy that you can set in your “config.lua” file.

 

Now, the reason you should verify the app on startup every time is in case your app was copied to another person’s device.  This is possible with an LVL enabled app because Android allows those types of apps to be installed on external storage (ie: the SD card) making them publicly accessible.

Ah, got it!  Thank you so much, Joshua.

 

Naomi

Do the latest daily builds still use Google In-App Billing version 2, or version 3?

@borderleap, I think it’s still using version 2 of Google In-App Billing.  I haven’t heard otherwise, and I haven’t changed my code that I built for version 2, and it’s still working fine with the daily build 1196.

Naomi

Version 2.

Thanks Naomi & Rob!  Yeah I was thinking version 2 as it looks like consumable purchases with version 3 still need to go through as managed somehow…??  Sounded complicated.

Not sure I understand how Google Licensing helps protect IAP.  It seems like the most common scenario to use licensing is if you have a paid app, correct?  How does it work if you have a free app with IAPs?

Also, please correct me if I’m wrong, but Google’s Managed Products are for IAP’s like “Pro Upgrade” or “Unlock All Levels”, while the Unmanaged Products are for things like “100 coins” or “20 Hints”?  

@JonPM, I don’t use Google Licensing, and I haven’t really looked into it.  But about your second question, yes, managed products are equivalent to non-consumable products and unmanaged products are consumable products.

Naomi

Google Licensing (aka: LVL) is used for copy protection.  It is used to detect if the person who is running your app has actually downloaded/purchased your app from Google Play.  It checks by contacting Google’s servers.

Google Licensing is sometimes used by freely distributed apps as well because it allows the following:

  • Allows your app to be installed on external storage (ie: the SD card).  Note that Google Play will not normally install your app to external storage since the device cannot prevent the SD card from being inserted into another device that did not purchase your app.  Google Licensing allows SD card installation because it will check if the current device/user purchased the app.
  • Allows your app to use expansion files.  Google Licensing is needed in this case because Google Licensing provides a temporary URL where the expansion file can be downloaded from after the app was verified.  In this case, I think Google doesn’t want to waste server bandwidth on apps that were copied/stolen.

Do the latest daily builds still use Google In-App Billing version 2, or version 3?

@borderleap, I think it’s still using version 2 of Google In-App Billing.  I haven’t heard otherwise, and I haven’t changed my code that I built for version 2, and it’s still working fine with the daily build 1196.

Naomi

Version 2.

Thanks Naomi & Rob!  Yeah I was thinking version 2 as it looks like consumable purchases with version 3 still need to go through as managed somehow…??  Sounded complicated.