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.
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()).
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.
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).
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.
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.).