IAP Badger: a unified approach to in-app purchases

Okay, IAP Badger has been built and uploaded as a plugin, so it should appear on your builds soon-ish.

One important point to mention:

  • Like Google, Amazon now returns a ‘purchased’ rather than a ‘restored’ state for products during the restore process.
  • So you can keep track of restored vs purchased items, IAP Badger will convert these rogue ‘purchased’ transactions back into ‘restored’ ones.

I think that made sense.

Simon

I have activated the IAP Badger plugin, but I’m seeing this error: 

module ‘plugin_iap_badger’ not found:

                    no field package.preload[‘plugin_iap_badger’]

Any thoughts?

[EDIT]

Forgot to include in build settings. 

Hi again,

I’ve just uploaded another version to Github and the Corona plug-in server.

Fixes:

* fixed store loading issue, causing the Corona error message on Android devices about attempting to load incorrect versions of the store library

* fixed build definition issues with the plug-in version of the library introduced in the last upload.

Simon

i have a doubt in restoring purchase function in iap badger. I think this function restores  any previously purchased products if available when reinstalling the game. If it is right, should i need to provide a restore button in the game.

Yes - you should definitely have a restore purchases button in your game - note that the restore function in IAP Badger  only restores non-consumable products.

On Android, Google also recommend that you initiate a restore when your app is first launched, so users automatically get their purchase entitlements updated when they re-install or move an app from device to device.

On iOS, Apple explicit ask you not to do this, because on iOS this involves asking the user for their password (Android doesn’t ask for a password on restores).

Simon

I’m unlocking my levels in purchase listener provided within this

iap.purchase("levelUnlock", purchaseListener)

and likewise do i need to unlock levels in the restoreListener function in this restore call after successful restore

 iap.restore(false, restoreListener, failedListener)

Im just submitting Stellar Trek to Amazon right now, will report back with what happens.  Thanks Simon!

Good luck gb8!

Hi vimaleee,

iap.restore(false, restoreListener, failedListener) will initiate the restore process.

If there are no products to restore, IAP Badger will call failedListener after a given timeout period.

restoreListener will be called, potentially several times, with details of each item that needs to be restored.

Have a look at therestore section of the tutorial for a more detailed explanation.

Simon 

Thanks Simon,  Stellar Trek was accepted at Amazon with no problems : Submission Live Stellar Trek at 26 Apr 2016

Super job and thanks again for the stellar IAP Badger and such great support!

Greg

Hi Simon.
Was there a recent breaking change made? I’m getting  a runtime error on building ( ios9 ) :

Runtime Error: Runtime error: module 'plugin.iap\_badger' not found:resource (plugin.iap\_badger.lu) does not exist in archive

Someone else documented the same problem I’m having here : https://forums.coronalabs.com/topic/62977-iap-badger-resource-not-found-when-built-for-ios/

I have always done the following and it has worked up until now:

-- build.settings : ["plugin.iap\_badger"] = { publisherId = "uk.co.happymongoose", } -- main.lua : local iap = require( 'plugin.iap\_badger' )

But in your documentation it says use local iap = require “plugins.iap_badger” ( pluralised plugins ) … have things changed with the corona syntax for requiring plugins or is this just an unrelated typo? If so, do you know how I can fix this problem? I was going to publish this week.   :unsure:

NOTE: I’m using daily build CoronaSDK-2016.2874

Hi Julius,

Someone else PM’d me about this this morning.  It’s odd, because I have made no changes at all to the plug in at all.

(The documentation thing is a typo - it should read plugin.iap_badger - and I’ve updated the documentation to reflect this.)

If you need to publish this week, my advice would be to grab a copy of the code from Github (you can find it here).  It’s identical to the plug in version, except you don’t need to include any reference in build.settings and you include it as you would any other file in your project.

I’ll investigate and post an update on this thread.

Simon

For those of you building on iOS, I’ve updated the library to remove references to  store.availableStores.apple by the way.  This should ensure the iOS store library loads correctly.

The change is up on Github now.

Simon

Thanks Simon. It’s odd that the plugin dropped off the Corona server like that. I’d prefer to wait until you push it back up before I publish rather than grabbing a copy of the code from Github because I like the idea of future-proofing a bit more and the easier management when I make updates. Any idea when you’ll be able to re-upload it?

I’ve just pushed through a rebuild to Bitbucket (that includes the iOS reference fix).

The docs from Corona says it will be picked up by their servers within a few minutes, but it may take over an hour for it to reach you.

If it doesn’t work this time, I’ll get on to the good people at Corona for advice.

Fingers crossed…*

Simon

(* very scientific, I know)

Just tried rebuilding some test code and it appears to be fixed now.  :slight_smile:

Simon

Do you mean that it should work by requiring normally with local iap = require( ‘plugin.iap_badger’ )? I still get the same error : 

Runtime error: module 'plugin.iap\_badger' not found:resource (plugin.iap\_badger.lu) does not exist in archive

Is there something I need to change? I have no idea how the plugins work or are added in a Corona server build, is there caching that needs to be emptied?

If it helps, here’s what’s output in the Device Log for iOS9:

[Device] Runtime Error: Runtime error: module 'plugin.iap\_badger' not found:resource (plugin.iap\_badger.lu) does not exist in archive [Device] no field package.preload['plugin.iap\_badger'] [Device] no file '/var/containers/Bundle/Application/24AA2E90-7A92-44A1-A398-2122C48EA24C/Quipadvisor.app/plugin/iap\_badger.lua' [Device] no file '/var/containers/Bundle/Application/24AA2E90-7A92-44A1-A398-2122C48EA24C/Quipadvisor.app/plugin/iap\_badger.lua' [Device] no file './plugin/iap\_badger.so' [Device] no file '/var/containers/Bundle/Application/24AA2E90-7A92-44A1-A398-2122C48EA24C/Quipadvisor.app/plugin/iap\_badger.so' [Device] no file './plugin.so' [Device] no file '/var/containers/Bundle/Application/24AA2E90-7A92-44A1-A398-2122C48EA24C/Quipadvisor.app/plugin.so'plugin.iap\_badger [Device] [Device] stack traceback: [Device] [C]: in function 'require' [Device] ?: in function 'require' [Device] /Users/juliusbangert/Documents/Projects/Quipadvisor/Code/Quipadvisor/main.lua:95: in main chunk

And here is what’s output for Android :

XT1039: WARNING: Could not load 'plugin.iap\_badger.LuaLoader' XT1039: ERROR: Runtime error May 04 03:56:10.162 XT1039: /Users/jenkins/slaveroot/workspace/Templates/label/android/platform/resources/init.lua:820: module 'plugin.iap\_badger' not found:resource (plugin.iap\_badger.lu) does not exist in archive XT1039: no field package.preload['plugin.iap\_badger'] XT1039: no file '(null)/plugin/iap\_badger.lua' XT1039: no file '(null)/plugin/iap\_badger.lua' XT1039: no file '/data/app/com.jubjubstudios.quipadvisor-1/lib/arm/libplugin/iap\_badger.so' XT1039: no file './plugin/iap\_badger.so' XT1039: no file '(null)/plugin/iap\_badger.so' XT1039: no file '/data/app/com.jubjubstudios.quipadvisor-1/lib/arm/libplugin.so' XT1039: no file './plugin.so' XT1039: no file '(null)/plugin.so' XT1039: no file '/data/app/com.jubjubstudios.quipadvisor-1/lib/arm/libplugin.iap\_badger.so' XT1039: no file './plugin.iap\_badger.so' XT1039: no file '(null)/plugin.iap\_badger.so' XT1039: stack traceback: XT1039: [C]: in function 'require' XT1039: /Users/jenkins/slaveroot/workspace/Templates/label/android/platform/resources/init.lua:820: in function 'require' XT1039: ?: in main chunk XT1039: getRunningAppProcesses: caller 10100 does not hold REAL\_GET\_TASKS; limiting output

@juliusbangert

For the require, he just means to do a require like you normally do a require for any other file local to your project. So if the iap_badger.lua file is in the root of your project, you use:

local iap = require( ‘iap_badger’ ) 

If you put the lua file in a folder called “lib”, then you use:

local iap = require( ‘libs.iap_badger’ ) 

The lua file can be found in this github repo:

https://github.com/happymongoose/iap_badger

@jerejigga. I believe he said he has pushed a rebuild to Corona Plugin Bitbucket. I know how to require lua files, I’m referring to the require plugin namespace.

My bad - I assumed because it was a pure lua plug in, if it worked on the simulator and built without any errors, it would also work on the device.

I’ve sent an email to Corona to get some advice on this.

Simon.