In app purchases, help needed

Just to help Naomi (maybe), the link of the iPhone Config Utility is: http://support.apple.com/kb/dl851

PS: I did know that this soft exist but had never used it as usually I use the Xcode.
Regards, [import]uid: 89165 topic_id: 16336 reply_id: 61270[/import]

Thanks Chris and Rodrigo. After looking at Xcode a bit more carefully, I realize Xcode shows the library with folder for provisional profiles. In fact, I’ve always deleted all provisional profiles before dragging & dropping brand new clean provisional profiles – but it didn’t and doesn’t yield the result I’m looking for. * sigh * [import]uid: 67217 topic_id: 16336 reply_id: 61313[/import]

You Welcome Naomi!
So haven`t you got it working yet?

I would like to ask you if you did try to build your app using something like the Team Provisioning Profile* ? Maybe its a stupid question but just trying to get into understanding your problem better as we know, your problems can be my problems in the near future as well…so lets try to help. :]
PS: I did not try to build any app as yet because I am still learning but it cannot stop me listening to the others problems.
Regards,
Rodrigo. [import]uid: 89165 topic_id: 16336 reply_id: 61376[/import]

Hi Rodirgo, I have not been able to make the codesigning error go away. I deleted everything from my keychain, redid the dev certificate and distribution certificate, and created another set of provisional profiles. The codesigning works perfectly fine with distribution certificates, but the error never goes away when I build with dev certificate. I am going to cut the loss and move on.

EDIT: I don’t need to move on after all. All I needed to do was to test it on Ad Hoc. I feel so stupid to think I needed to use dev build (after I’ve been testing device build using Ad Hoc for the longest time). [import]uid: 67217 topic_id: 16336 reply_id: 61418[/import]

Hi Naomi,

So you got it right? :slight_smile:

Happy for “hearing” it!
[import]uid: 89165 topic_id: 16336 reply_id: 61481[/import]

Thank you so much for the kind words, Rodrigo.

I’m still working on it, but I’ve seen the end of the tunnel. I finally get the product information that I was so trying to hard to fetch from iTunes Connect. See below my unpackValidProducts function. OMG, I’m so happy! Terminal printed the validProducts!!! And I have only one products in In-App Purchase, so this is pretty much the end of my tunnel. Hooray!!!

[lua]function unpackValidProducts()
print (">>>>>>>>>>>>>>Loading product list")
if not validProducts then
print(“not validProducts”)
native.showAlert( “In-App features not available”, “initStore() failed”, { “OK” } )
else
print(“looping through the invalidProducts”)
for numLoop=1, #invalidProducts do
native.showAlert( “Item " … invalidProducts[numLoop] … " is invalid.”,{ “OK” } )
end
end
if validProducts then
print("validProducts = " … tostring(validProducts))
print("validProducts[1].title = " … tostring(validProducts[1].title))
print("validProducts[1].description = " … tostring(validProducts[1].description))
print("validProducts[1].price = " … tostring(validProducts[1].price))
print("validProducts[1].productIdentifier = " … tostring(validProducts[1].productIdentifier))
end
end[/lua]

The moral of the story really is about never giving up but persevere. I have persevered and finally broke through!
[import]uid: 67217 topic_id: 16336 reply_id: 61506[/import]

Duh, it looks like I was trying to solve something entirely stupid. Scrolling all the way down to #15 on http://developer.apple.com/library/ios/#technotes/tn2259/_index.html clearly states I’m supposed to use Ad Hoc to test this thing. Perhaps what I thought was a problem was not a problem. The problem might’ve been me not reading things correctly. (If it proves true, I might still be able to get this thing worked out after all – although I lost days and days of productivity.)

EDIT: Yes, it was my stupidity. Ad Hoc did the thing, and my ad hoc build made all way to unpackValidProducts (and there it drops dead.) I redid everything again this morning (including In-App Purchase product in iTunes Connect, by deleting it and creating new one, I’ll wait for a few hours before I resume with this endeavor.) I think I can do this thing in my sleep now, having gone through re-do process bazillion times.

NEW EDIT: It looks like I just needed to wait a little while before the products in iTunes Connect sandbox propagated properly. unpackValidProducts works fine now. [import]uid: 67217 topic_id: 16336 reply_id: 61429[/import]

@omarcaleroherrera2, I kind of took over your original post. I’m sorry. I’m wondering if you were able to get your In-App Purchase working. If I could help in some ways, I’d love to help. [import]uid: 67217 topic_id: 16336 reply_id: 61509[/import]

So, I’ve done it! I set up a front end for the store, and I completed the full cycle! YES!!!

I wondered what “product” must be in store.purchase function mentioned above, and my hunch proved right:

[lua]-- the sample says
–you should enter here the product being purchased here
store.purchase( {product} )

– since I have only 1 product, what I inserted in place of the product is:
store.purchase( {validProducts[1]} )[/lua]

Cheers! [import]uid: 67217 topic_id: 16336 reply_id: 61528[/import]

Thank you Naomi. I think the IAP is working. Following the indications of D3mac. My app consists of a initial screen with four images corresponding to the four levels. I’m tryng to implement something that send to the level in the case is purchased and send to the buy screen in the other case. But still having troubles with that. I’m tryng to create a file for the case “purchased” in the buy screen and then to read it in the menu and depends of that send to each screen but doesn’t works. Here I post a part of the code if you could help me. Thank you!

Here is the part to create the file:

[code]function transactionCallback( event )
if event.transaction.state == “purchased” then
savePurchase(“com.bigteethmedia.funkyinstruments.TheSportsAlley”)
elseif event.transaction.state == “purchased” then
– escribe
local filePath = system.pathForFile( “datas.txt”, system.DocumentsDirectory )
print( “Creating file…” )

– create file b/c it doesn’t exist yet
file = io.open( filePath, “w” )
file:write( “Purchased\n” )
io.close( file )
–os.remove( filePath )

elseif event.transaction.state == “restored” then
savePurchase(“com.bigteethmedia.funkyinstruments.TheSportsAlley”)
elseif event.transaction.state == “cancelled” then
elseif event.transaction.state == “failed” then
infoString = "Transaction failed, type: ", event.transaction.errorType, event.transaction.errorString
local alert = native.showAlert("Failed ", infoString,{ “OK” })
else
infoString = “Unknown event”
local alert = native.showAlert("Unknown ", infoString,{ “OK” })
end
store.finishTransaction( event.transaction )
end

[/code]

And here is the complete code in the menu to change the screen depending on is purchased or not

module(..., package.seeall)  
  
system.activate("multitouch")  
function new()  
 local localGroup = display.newGroup()  
  
 local background = display.newImageRect("portada.png", \_W, \_H)  
 background:setReferencePoint(display.CenterReferencePoint)  
 background.x = \_W / 2  
 background.y = \_H / 2  
  
  
  
local play = display.newImage("tolevel.png")  
 play:setReferencePoint(display.TopLeftReferencePoint)  
 play.x = 5  
 play.y = 4  
 play.scene = "level1"  
  
  
  
local play2 = display.newImage("tolevel.png")  
 play2:setReferencePoint(display.TopLeftReferencePoint)  
 play2.x = 246  
 play2.y = 5  
 play2.scene = "level2"  
  
  
 local filePath = system.pathForFile( "datas.txt", system.DocumentsDirectory )  
 local file = io.open( filePath, "r" )  
 if file then  
 -- read all contents of file into a string  
 local contents = file:read( "\*a" )  
  
 --print( "Contents of " .. filePath )  
 print( contents )  
  
 io.close( file )  
 --end  
  
 if not contents == "Purchased" then  
  
 local playblock2 = display.newImage("tocompras.png")  
 playblock2:setReferencePoint(display.TopLeftReferencePoint)  
 playblock2.x = 5  
 playblock2.y = 4  
 playblock2.scene = "levelcompras"  
  
  
  
  
local play3 = display.newImage("tolevel.png")  
 play3:setReferencePoint(display.TopLeftReferencePoint)  
 play3.x = 5  
 play3.y = 163  
 play3.scene = "level3"  
  
  
  
 local filePath = system.pathForFile( "datas.txt", system.DocumentsDirectory )  
 local file = io.open( filePath, "r" )  
 if file then  
 -- read all contents of file into a string  
 local contents = file:read( "\*a" )  
  
 print( "Contents of " .. filePath )  
 print( contents )  
  
 io.close( file )  
 --end  
  
 if not contents == "Purchased" then  
  
 local playblock3 = display.newImage("tocompras.png")  
 playblock3:setReferencePoint(display.TopLeftReferencePoint)  
 playblock3.x = 5  
 playblock3.y = 4  
 playblock3.scene = "levelcompras"  
  
  
  
  
 local play4 = display.newImage("tolevel.png")  
 play4:setReferencePoint(display.TopLeftReferencePoint)  
 play4.x = 246  
 play4.y = 163  
 play4.scene = "level4"  
  
  
 local filePath = system.pathForFile( "datas.txt", system.DocumentsDirectory )  
 local file = io.open( filePath, "r" )  
 if file then  
 -- read all contents of file into a string  
 local contents = file:read( "\*a" )  
  
 print( "Contents of " .. filePath )  
 print( contents )  
  
 io.close( file )  
 --end  
  
 if not contents == "Purchased" then  
  
 local playblock4 = display.newImage("tocompras.png")  
 playblock4:setReferencePoint(display.TopLeftReferencePoint)  
 playblock4.x = 5  
 playblock4.y = 4  
 playblock4.scene = "levelcompras"  
  
 end  
  
  
  
 function changeScene(event)  
 if(event.phase == "ended") then  
 director:changeScene("level1", "fade")  
 end  
 end  
  
 function changeScenes(event)  
 if(event.phase == "ended") then  
 director:changeScene("level2", "fade")  
 end  
 end  
  
 function changeScenes3(event)  
 if(event.phase == "ended") then  
 director:changeScene("level3", "fade")  
 end  
 end  
  
 function changeScenes4(event)  
 if(event.phase == "ended") then  
 director:changeScene("level4", "fade")  
 end  
 end  
  
 function changeScenesBlock2(event)  
 if(event.phase == "ended") then  
 director:changeScene("levelcompras", "fade")  
 end  
 end  
  
 function changeScenesBlock3(event)  
 if(event.phase == "ended") then  
 director:changeScene("levelcompras", "fade")  
 end  
 end  
  
 function changeScenesBlock4(event)  
 if(event.phase == "ended") then  
 director:changeScene("levelcompras", "fade")  
 end  
 end  
  
 localGroup:insert(background)  
 localGroup:insert(play)  
 localGroup:insert(play2)  
 localGroup:insert(play3)  
 localGroup:insert(play4)  
 localGroup:insert(playblock2)  
 localGroup:insert(playblock3)  
 localGroup:insert(playblock4)  
  
 play:addEventListener("touch", changeScene)  
 play2:addEventListener("touch", changeScenes)  
 play3:addEventListener("touch", changeScenes3)  
 play4:addEventListener("touch", changeScenes4)  
 playblock2:addEventListener("touch", changeScenesBlock2)  
 playblock3:addEventListener("touch", changeScenesBlock3)  
 playblock4:addEventListener("touch", changeScenesBlock4)  
  
 return localGroup  
end  
  

Naomi and D3mac. Thanks for your interest and your time in helping [import]uid: 81363 topic_id: 16336 reply_id: 61869[/import]

@omarcaleroherrera2, I’m as noob as it comes, and even more so with IAP related matter, so hopefully, someone more knowledgeable would be able to help. I’m also not sure which part of the process is broken for you. What part is causing you trouble?

That said, when I use savePurchase function, I don’t use the full product ID. Instead, I point to the corresponding array/table in product list. So, if I had 3 products, it would be:

[lua]-- my product list
local myProductList = {
“com.companyName.appName.productID1”,
“com.companyName.appName.productID2”,
“com.companyName.appName.productID3”,
}

– I don’t use this
savePurchase(“com.companyName.appName.productID1”) – when saving product1
savePurchase(“com.companyName.appName.productID2”) – when saving product2
savePurchase(“com.companyName.appName.productID3”) – when saving product3

– instead I use this
savePurchase(“validProducts[1]”) – when saving product1
savePurchase(“validProducts[2]”) – when saving product2
savePurchase(“validProducts[3]”) – when saving product3[/lua]

Not sure if the above is of any help. A bit more explanation on where things are broken might help someone knowledgeable to jump in to help. [import]uid: 67217 topic_id: 16336 reply_id: 61872[/import]

Thanks for replying Naomi.

The problem is that I’m trying to make a way to put a lock image on the menu if the item has not been purchased and when the user touch in that image, goes to the buy screen, and if the item has been purchased go to the level. For this I’m trying to create a file in the “buy level” that says “Purchased” and then in the menu file, read that file and if says “Purchased” or not do one of the actions, but in the terminal I get this error: menu.lua:184: ‘end’ expected (to close ‘if’ at line 78) near ''

Thank you again [import]uid: 81363 topic_id: 16336 reply_id: 61877[/import]

@omarcaleroherrera2, it sounds like your code is missing a closing end. Try looking at your code line by line, and make sure if-statements and functions all have end.

For example, line 35 has if file then , but I don’t know which line of end actually ends the if-statement. Because the indentation isn’t as consistent, it’s hard to see it. It almost feels like there are numerous end missing from the code block you posted above. [import]uid: 67217 topic_id: 16336 reply_id: 61880[/import]

Hey I had a question about your last post Naomi. you said --Instead I use this, and had savePurchase(“validProducts[1]”). Are those quotation marks intentional? Like you actually use them in the code?

Im just wondering because when you posted in my thread about the
store.purchase( {validProducts[1]} )

I am just confused on why sometimes it is quotations and sometimes it is in curly brackets.

btw CONGRATULATIONS!! From what I can tell your in-app purchase is 100% working yeah? [import]uid: 46742 topic_id: 16336 reply_id: 61881[/import]

Yeah, I am pretty sure that by deleting it off your phone, and creating a new test user account and going through the process with a new test user account should work. It sucks but I think it works and if it does, just create a bunch of test user accounts at once and go through them one by one. [import]uid: 46742 topic_id: 16336 reply_id: 61890[/import]

Also, i think it may not even matter what we have inside that savePurchase(“In here”) because i think that is used for differentiating between different purchases. and which one to save. Sine we both only have one in-app purchase, the savePurchase function really has no need for variables, as it will only be saving/restoring the same in-app purchase. i think… [import]uid: 46742 topic_id: 16336 reply_id: 61891[/import]

Hey Chris, see my post here:

https://developer.anscamobile.com/forum/2011/10/17/help-how-reset-purchased-state-device-once-purchased-i-cant-return-device-non

I’ve deleted, created new test users, went through the process again… but somehow, it didn’t work at all. I’m going to check to see if revised savePurchase function would help somehow (although I don’t see how it can possibly make any difference.) [import]uid: 67217 topic_id: 16336 reply_id: 61892[/import]

Wahoo!!! I got it! Fully functional, unlocked everything perfectly! If all goes well I should be submitted tonight! Thanks so much Naomi! This was fun, lets do it again! [import]uid: 46742 topic_id: 16336 reply_id: 61954[/import]

Congrats! Yes, let’s continue helping each other as we continue developing apps/games! Best of luck with your submission!! [import]uid: 67217 topic_id: 16336 reply_id: 61962[/import]

Naomi and D3mac123. My app with In App Purchase content is now ready for sale. Thank you so much for your help about that.
[import]uid: 81363 topic_id: 16336 reply_id: 65073[/import]