In app purchases, I need some serious help!

@happymongoose, I’ve implemented your iap code and all looks good so far.

I just have one question, how does your code handle the restore purchase with regards to GPGS?

Upon a new install I would like my app to check with Google if the customer has purchased the unlock game before, if so the game is automatically unlocked.

Thanks in advance.

Hi Quizmaster,

When your app is started, just call iap.restore() - I do this in a systemEvent listener for applicationStart.   When the store responds, everything that the user has purchased in the past will come back as a restored product (rather than a purchased one) and your app can respond as it needs to.

The code to do the restore is:

iap.restore(false, yourListenerFunction)

In this case, you don’t need to set a timeout listener, because you don’t care if the user hasn’t bought products in the past.

Hope that makes sense  :slight_smile:

Simon

Thanks for the quick reply and thanks for the wonderful code you created and thanks for making things easier for me.

I started with your simplified code, got that working then started going through your more detailed code and added salt, doNotLoadInventory=true and debugMode=true

THANK YOU!!

Just remember to remove your references to doNotLoadInventory and debugMode when you go into production (or want to test on live devices).

:smiley:

I will, thanks.

:slight_smile:

@happymongoose

Hi Simon

It looks like I’ve successfully got your iap badger working on my game.

I just have to add the bit to check for restore purchase in app startup and I’m done.

So in my code (where the game loads for the first time) do I have to do the following before checking for a restore…

require iap_bager, set up the catalogue, iapOptions and init?

One more question, iap.getLoadProductsCatalogue() does that only work in a live application?

Thanks.

Hi again,

At the start of your game: that order is correct.  

iap.getLoadProductsCatalogue will only fetch product information from a server on an actual device - your app doesn’t have to be in production though.  So, on Google Play, it’s enough that it is in alpha.

However, the function can also provide some debug/placeholder information on the simulator too.

Have a look at the following page: in the example code, you’ll see that in the catalogue, for the product buy50coins, there are entries called simulatorPrice, simulatorDescription and simulatorTitle.  These are the values you’ll get back when you call the function on the simulator.  This should allow you to use placeholder text and prices to check the layout of your app.

That’s great, I didn’t think about doing that at the beginning.

This is the first time I’ve done this, can you tell me if the price returned in the local currency also has the symbol with it like $ or £

Thanks for your help again.

:slight_smile:

I’m 99.65% sure you get a string back containing all the currency symbols included for you - you just print out whatever string they give you.

(I can’t get to my own code to check from where I am now).

I’ll find out soon enough I’m sure, thanks again.

I’m looking for Android Beta testers, would you like to test my game?

Here’s the Twitter page for it with some screen shots: https://twitter.com/gameshowapp

I could really use the feedback.

I’m afraid I’m massively busy at the moment, so I couldn’t promise anything.  If you message me the link, I’ll do my best to have a look over the following week or so.