Community "kickstarter" for a working IAP addon.

Cool, thanks! Is there a way to know which country the player is from within Codea, or should I try and figure it out in Xcode?

Also, I think I got it to work!!! I had to pass “0” to purchaseItem() (I have only one IAP, I’m guessing the number needs to be incremented accordingly if there is more than one).

Additionally, I think there is a typo in your explanations. instead of:

registerItem("com.YourCompany.IAPname")

I think it should be:

registerItem("IAPname")

@Rodolphe - when you request the product info from Apple you actually get back a table of data that has the current store price automatically converted into the correct currency for the region you’re in. Also if you’ve translated the product description text that will also be correctly returned depending on the target device settings. Doing it this way means that you can update your store price after the app has been submitted. In fact if you’re clever about how you set up your in App Store then you can add extra IAP’s after the app has been published and get all the details back from Apple to allow you build up a complete shopping cart.

Wow, this is great, I got it to work, thanks!

Good to know @TechDojo ! That’s sweet. Do you know how I can store that info?

Awesome @Rodolphe !!! That’s exciting!

Thanks a lot for your work @pelicantacos !

@pelicantacos - not sure what you mean, you don’t normally store it locally, it get’s downloaded from Apple when you init the store - you get a product list and then you iterate over the product list and request each product individually.

If your call to init the store didn’t complete (ie if you’re offline) then there’s no point having this info as you can’t buy anything anyway.

If you’re on about how to pass the info back from your obj-C / Swift code to Codea, in Corona they pass it back as a table of data - actually setting that up can be a bit of a pain - sorry :slight_smile:

I’m not sure if this is what you are after, @pelicantacos, but I managed to get the price (and the currency symbol, which is great) by simply doing this to getProductInfo():

  function getProductInfo(id,price)
      iapItems[id] = {
      price = price
      }
      priceOfIAP = price -- add this
  end

  print(priceOfIAP)

That’s kind of “hacky”, like everything I do :smiley: and it won’t work for more than one IAP, but it should be easy to improve…

Cool @Rodolphe! I like it! I’m sure you could just add it to a table, with table.insert or something similar. I’m currently moving everything over to Corona for my app and learning Lua on there as I believe that will fit my needs in the future, with trying to move Color Troll over to Android. It’s actually really nice and there are some great tutorial videos out there (somewhat old though, so it’s making me think I should make some!), which have helped a lot in setting everything up.

I’m glad everything is coming along nicely!

@pelicantacos, for short info, a Russian rubs is like this:
584?

Hello all, I was wondering if there is still a way to get the addon files created by @pelicantacos? I am working on learning how to implement functionality from the objective-c side, but would definitely appreciate using the addons already created.

@TechDojo it looks like the other members of the thread aren’t active on the forums anymore, is there any chance you still have those files?

Also open to any other solutions people have found!

Thanks!

@pelicantacos Thank you for updating it! They look like the right ones to me.
I appreciate you sharing your work and hopefully I can implement it correctly!

Put me down for $20 USD

@cmingo - Sorry I don’t have any of the above files. Currently the solution I’m using (although it’s not in Codea but it is in Lua) is to use the IAP Badger plugin for the Corona SDK. You can get the source via the original developers website at http://happymongoosegames.co.uk/iapbadger.php - when used in conjunction with the docs on the Corona IAP plugin (https://docs.coronalabs.com/daily/api/library/store/index.html) and the info above you should be able to work it out fairly easily.

(oops sorry I didn’t catch this quickly enough, glad you managed to find the solution though! these tax things were so obscure to me…)

@pelicantacos Im so grateful that you were able to post your files, and tbh, I just got to the dirty Obj-C work this week and lately, I’ve been working with IAP. I of course used your files because I don’t want to recreate the wheel, but I keep receiving an error from Xcode:
Every single time I say, “purchaseItem(0)”, my app starts to glitch and I start getting errors, even tho I’ve registered the id and done all the work in iTunes connect. I don’t know what I am doing wrong, and I am in urgent need of a response. @Rodolphe Can you help as well? I saw that you were able to get it to work. Thanks in advance!

Nevermind, got it to work, it turns out I had to do my tax forms.

@CamelCoder how funny! Glad you fixed it! There are so many options as to where it could go wrong, so I’m happy to know you were able to get it working. Good luck! If you haven’t started in Corona yet, you really should download it. Once you have created an app in Codea successfully, Corona SDK is the next logical step as there are many more plug-ins and its ease of operation is nice. It’s a great, and powerful, next step in the coding journey. Codea is amazing and I wouldn’t be where I am today without, but if you are starting down the IAP line, I would recommend to move to Corona.

@pelicantacos I have corona on my computer, but I like Codea more. I tried it for a few hours, I sitll have to get used to it tho. Is there any way to take a Codea project and make it Corona-compatible?

@CamelCoder, yeah, it’s not entirely the same and I felt that way at first because I’ve spent the last 5 years in Codea. I thought it’d be easier at first, but it wasn’t :frowning:

As for switching projects over, I don’t know of any, sorry!

Once you get the hang of Corona though, you realize the work flow is much easier and the APIs work more efficiently, especially with things like buttons and images, so it will take some time, but well worth it. On my app I made for the iOS App Store, Color Troll, I was just going to remake it in Corona but decided not to and to just leave it there in Codea, though it would have taken me probably 1/4 the time in Corona vs. Codea. The other nice thing with Corona is that it transports it to Google or iOS without a hitch.