I'm completely failing at IAP :-(

I apologize if this has already been mentioned, but i didnt fancy reading every post fully :stuck_out_tongue:

But, have you tried putting your information into the IAP sample app to see if it would work there? If it did, then it would show that theres something wrong with your code, and not itunes connect.

The sample project is here:
http://developer.anscamobile.com/assets/InAppDemo.zip [import]uid: 69826 topic_id: 18067 reply_id: 69595[/import]

I am having similar issues. Would like to know of any resolutions? [import]uid: 24305 topic_id: 18067 reply_id: 70466[/import]

Sandbholbrook, have you attempted all of the things suggested above?

Peach :slight_smile: [import]uid: 52491 topic_id: 18067 reply_id: 70493[/import]

I’m planning on doing something with IAP…just not sure, but I’m very interested on this.
Also, are you saving additional check to local file/db besides the IAP check?

Please let us know if you got it working and how.
Thanks,
RD [import]uid: 7856 topic_id: 18067 reply_id: 70946[/import]

put this at the top of your code

  
 io.output():setvbuf('no')  

if testing on the devices view live output in xcode/organizer/console

if testing in the xcode/simulator view live output in applications/console

this does not work for me

  
 local listOfProducts = {  
 "com.ezraanderson.item1",  
 "com.ezraanderson.item2",  
 "com.ezraanderson.item3",  
 }  

set your products up this way for it to work.

local validProducts = {}  
local invalidProducts = {}  
 local listOfProducts = {  
 "item1",  
 "item2",  
 "item3",  
 }  
  

test your code like this

function unpackValidProducts()  
  
  
 print("valid"..#validProducts)  
 print("in-valid".. #invalidProducts)  
  
 for i=1, #validProducts do  
  
 print("validProducts = "..i..": ".. tostring(validProducts))  
 print("validProducts"..i..".title = " .. tostring(validProducts[i].title))  
 print("validProducts"..i..".description = " .. tostring(validProducts[i].description))  
 print("validProducts"..i..".price = " .. tostring(validProducts[i].price))  
 print("validProducts"..i..".productIdentifier = " .. tostring(validProducts[i].productIdentifier))  
 print("---------------------------")  
  
 end  
  
end  
function loadProductsCallback( event )  
  
 validProducts = event.products  
  
 invalidProducts = event.invalidProducts  
  
 unpackValidProducts ()  
  
  
end  
function setupMyStore (event)  
 store.loadProducts( listOfProducts, loadProductsCallback )  
end  
  
  
function storeTransaction( event )  
  
 local transaction = event.transaction  
  
 if transaction.state == "purchased" then  
 -- If store.purchase() was successful, you should end up in here for each product you buy.  
  
 local alert = native.showAlert( "Rapid Racer", "Transaction Successful!", { "OK"})  
  
 doSomethingHere()  
  
 elseif transaction.state == "restored" then  
  
 local alert = native.showAlert( "Rapid Racer", "Transaction restored (from previous session)", { "OK"})  
 elseif transaction.state == "cancelled" then  
  
 local alert = native.showAlert( "Rapid Racer", "User cancelled transaction", { "OK"})  
  
 elseif transaction.state == "failed" then  
  
 local alert = native.showAlert( "Rapid Racer", "Transaction failed!"..transaction.errorString, { "OK"})  
 --print("Transaction failed, type:", transaction.errorType, transaction.errorString)  
  
 else  
  
 local alert = native.showAlert( "Rapid Racer", "Unknown event", { "OK"})  
 end  
  
 store.finishTransaction( transaction )  
end  
  
  

use timer delay to start it

timer.performWithDelay (100, store.init() )  
timer.performWithDelay (1000, setupMyStore() )  
  

[import]uid: 89663 topic_id: 18067 reply_id: 72566[/import]

I need some serious help.

Tonight I will try to write any errors to the console with:

 io.output():setvbuf('no')

to see what errors (if any) I am getting from the device

This is what got me here:

  1. Copy and pasted the lemonade IAP code to my app… no changes to this code except next step.
  2. Changed out product info to my inapp created in iTunesConnect
    Format: com.domain.appname.inappname (this in-app was created weeks ago)
  3. From the simulator, I press the upgrade button and get “Ka-Ching Purchasing com.domain.appname.inappname” written in the terminal
  4. I build my app for the device using a developer provision.
  5. I sign-out of App store from device.
  6. I launch app from device.
  7. The app retrieves the valid product info… the correct name and price of my in-app.
  8. When I press the upgrade button… I expect to be prompted to login to the app store but nothing happens.

What else am I missing? Please help.

Warm Regards,
Brandon
[import]uid: 24305 topic_id: 18067 reply_id: 74930[/import]

I’ve just gone through the process of submitting my first app with IAP for approval. I was fortunate not to have any problems while testing though.

To see if I could replicate your problems, I followed the steps you outlined above in the Lemonade example, and substituted the product list with my IAP product (I have only one), and then built the app with my provisioning profile.
I was able to get the product info and was asked for my ID for purchase with no problem.

I have a few observations:

The developer provisioning profile should be the one for your app:
example:
If your IAP product ID is com.companyname.myiap.myproduct, then the provisioning profile for building the app should be for com.companyname.myiap, which means you can’t use the Team Provisioning profile for testing.

When you define your IAP in iTunes Connect, you have to set it to ‘Cleared for sale = yes’ in the Pricing and availability section of the IAP setup.

Other than that I don’t know what could be wrong. [import]uid: 70847 topic_id: 18067 reply_id: 74944[/import]

Thank you ingemar! Thanks for taking the time to investigate my woes.

You led me in the right direction. In iTunesconnect, my inapp was rejected and so I resubmitted the inapp… the status changed to pending and the app purchase works from the app.

Many thanks!!

Brandon [import]uid: 24305 topic_id: 18067 reply_id: 74956[/import]

@sandbholbrook
Great news! Glad I could be of help :slight_smile: [import]uid: 70847 topic_id: 18067 reply_id: 74958[/import]

Another tip for IAP
between your non IAP version and IAP version you MUST delete the app from the hardware then install it fresh from with your IAP test build.

For me it worked perfect on sim but failed on hardware. As soon as I removed it and installed fresh it worked on hardware. [import]uid: 110373 topic_id: 18067 reply_id: 80504[/import]