Problem With Example Code Of In-App Purchase

Hi @informaticavelasco,

Sorry for the delayed response. IAP does not work in the Corona Simulator; you need to build for a device to test.

Brent

Hi!

I tried and I get the same on my device (iphone and iPod touch):

“NOTICE: In-app-purchase is not supported on this device”

What could be or what I’m doing wrong?

Thanks for your help!

Did you enter all of your required store/product info into the sample app code? You need to put this info in; it doesn’t just run “as is” without this core information. The sample app code is commented quite thoroughly, and indicates the place to enter your product info from iTunes Connect, etc.

Ok it worked!

Thank you very much for your help, it was very useful!

I have a question. Once committed to the test user … Condiconal what I do for the system to detect it as “already purchased”.?

Everything works OK, however, if I press the button again realizarme purchase. How I can do it right?

Thank you very much for your help!

Hi there,

For iOS, if you want to make a product so that it can only be purchased once, you should create it in iTunes Connect as a “non-consumable” item.  This type of product is meant for things that are bought with a permanent effect, like unlocking content within an app, removing ads, etc.  If you classify your product that way, and a user tries to buy it again, iOS will indicate that they’ve already purchased it.  Non-consumable items can also be restored to a user after they wipe/reset their device (using store.restore()).

Hope this helps!

  • Andrew

ok, problem solved! :smiley:

One last question, how should I do the conditional so that if it was bought to change the picture to one that says for example “already purchased”? Let me explain:

I have the main.lua and test2.lua. The  test2.lua file is locked until you buy the product. How do I create a conditional that says … “if bought … unlock and create link to test2.lua”?

I searched documentation but I have hardly found anything.

Thanks for your help!

Hi there,

In your callback listener function (which you passed to store.init()), you could include code that unlocks the test2.lua content in response to a “purchased” event.  You would probably also want to store the fact that the user has unlocked the test.lua content in a file.  That way, you keep a permanent record that the new content is unlocked (i.e., every time the app is started or resumed, your code would check that file to see if the test2.lua content should be unlocked).

  • Andrew

Hi Andrew!

I understand. But should be 4 different products … How do I identify the product purchased has not been purchased? I’m a little confused on this point. Sorry for the inconvenience.

Thanks!

Aitor

Hi there,

Your transaction callback function will receive a table that includes a field called productIdentifier, which is the product ID that you used in store.purchase(), and that you registered in iTunes Connect.

So, in your transaction callback listener, you can test whether the state is “purchased”, and then for each possible product identifier, take a different action (unlock test2.lua, unlock test3.lua, etc.).

Hope this helps.

  • Andrew

I could get a brief example to understand better?

thanks!

I think I understood what quisistes mean, I’ll try and keep you posted on the progress.

In the meantime could check this other post I emerged from this?

http://forums.coronalabs.com/topic/33279-in-app-purchase-with-two-image/

Thanks in advanced

By the way i also have problems with InAppDemo example - i carefully entered all my info from itunesconnect and i can easily buy any item, but when i tap Restore btn, state text in bottom left corner says that “Test restore failure” and only after this it asks me to enter my test user Apple ID and password. And of course, when i enter them, nothing happens. 

By the way i also have problems with InAppDemo example - i carefully entered all my info from itunesconnect and i can easily buy any item, but when i tap Restore btn, state text in bottom left corner says that “Test restore failure” and only after this it asks me to enter my test user Apple ID and password. And of course, when i enter them, nothing happens.