Cool! Glad I could help somehow! Congrats on this milestone! [import]uid: 4883 topic_id: 16336 reply_id: 65076[/import]
Congrats, omarcaleroherrera2!
Naomi [import]uid: 67217 topic_id: 16336 reply_id: 65104[/import]
Hey, @ezraanderson1979, what might be troubling you with IAP? I’m no expert, and perhaps sharing your difficulty here might help others solve their problems too (I’ve been indirectly helped many times by reading forum posts)… and not only that, someone more knowledgeable might be able to help you much better than I could. So do you mind posting what might be troubling you here?
Naomi [import]uid: 67217 topic_id: 16336 reply_id: 72356[/import]
@d3mac123 and @chris.r.martone, thank you so much for your reply comments. I was testing this on device. But then…
EDIT:
My keychain was messed up, which I cleaned up. (I think I can do this in my sleep now.) Now that code signing issue is out of the way, I can finally test this using Ad Hoc build. (If I confused anyone regarding what build to use for testing In-App Purchase, I sincerely apologize.)
EDIT#2: Please ignore the third paragraph of the post #17 of mine below. For some reason, I can’t edit the post #17 to fix the issue, so I’m making an edit post here for whoever that might get confused. To test IAP in the iTunes Connect sandbox, you need to use Ad Hoc build. Using Dev certificate was very very wrong for this purpose, and I was stupid enough to get stuck with it way longer than I should have. Seriously, it’s a simple mistake but somehow it took me a while to get out of that trap. I repeat, don’t use Developer Certificate to generate a build to test on device. [import]uid: 67217 topic_id: 16336 reply_id: 61190[/import]
Hey, @ezraanderson1979, I don’t think IAP work in the xcode simulator. I think it needs to be tested on a device (but I could be wrong).
Naomi [import]uid: 67217 topic_id: 16336 reply_id: 72367[/import]
after reading this forum:
“uploading the binary and canceling it”
http://developer.anscamobile.com/forum/2011/10/19/app-purchase
and reading this comment:
“It looks like I just needed to wait a little while before the products in iTunes Connect sandbox propagated properly. unpackValidProducts works fine now”
i hope things will work for me soon, because i keep getting this error “in-app features not available”
-
Does in-app-purchase work in the xcode simulator for testing purposes.
-
if this is in my code “io.output():setvbuf(‘no’)” should i be seeing any calls in the console Messages, when in-app-purchase is trying to do something in the xcode simulator.
-
Can you test in-app purchase if itunes-connect/in-app-purchase page/status says: “ready to submit”
-
Can you test in-app purchase if apps status says: “ready for upload” or “canceled by developer”
i just saw you were online and was hoping to befriend you, because you seam to be a brilliant person with lots of perseverance. And i was hoping you can help shed some light on this because i just tested inmobi/admob/adsense/mopub a bizillion times and do not want to repeat the process for in-app-purchase
[import]uid: 89663 topic_id: 16336 reply_id: 72362[/import]
Hey, @ezraanderson1979, I just saw the edited version of your post #46. What a nice complement, and I don’t even deserve being called a brilliant person, but I do agree I have a solid perseverance (haha). And I share your feeling about testing some thing upteen times and not wishing to go through that again. I felt the same way after IAP fiasco that the first step I took for OpenFeint / Game Center integration was to ask for advice (after I felt like I did the decent amount of preliminary homework). It helped me greatly (and I’m so thankful of the gracious & helpful community we have here.)
Anyhow, here’s all I know (and others might know better still):
-
I believe you need to install the Ad Hoc build to a iOS device to test IAP.
-
I have io.output():setvbuf(‘no’) in my code too (with a reminder to remove it when I’m ready to submit my game to app store.) I am not entirely sure what it does, to be honest, and my note says it is to “disable output buffering for console in device!” And honestly, I don’t know exactly what that means.
-
Mine says “ready to submit”, but my game still accesses iTune Connect sandbox and forces my test user to make the purchase every now and then.
-
Mine says “Developer Rejected”, but as I noted above, I can still test IAP.
I hope this helps.
Naomi [import]uid: 67217 topic_id: 16336 reply_id: 72445[/import]
can you help me with in app purchase?
i am just alittle confused should only take a couple of minutes.
[import]uid: 89663 topic_id: 16336 reply_id: 72355[/import]
Hey, @ezraanderson1979, I’m so glad to hear you’ve got it sorted.
And thank you sooo much for explaining to me what io.output():setvbuf(‘no’) does. I suspected it must be something of that sort, and you know what, some of the games that are already in app store have this line of code still in their build – my Xcode shows this someone else’s app under application section of my device. Now I know I definitely want to remove it before it’s shipped.
Cheers,
Naomi [import]uid: 67217 topic_id: 16336 reply_id: 72532[/import]
Hey Chris, I think you just debugged my code. I think I shouldn’t use the quotation marks. (I’ll edit the code above to avoid confusion.)
I have gone through the “buying” process once, and I saw the “Transaction successful!” on my terminal, but I still needed to do some work on savePurchase function which had nothing in it when I completed the purchase cycle on the device I was testing on. But then, I am unable to revert the purchase status of the device back to unpurchased status – which essentially made it impossible for me to test the savePurchase function.
I have another device that I’m testing on, but I don’t want to go through the entire purchase cycle with it, because, I’m thinking, once I do that, and even if I find a problem, this device would turn into purchased status too. Then what? How would I test the savePurchase function after that.
If you know of how to revert the device back to non-purchased state as it relates to the game I’m testing, I’d love to know. That would be a great help.
EDIT: I don’t understand why, but the “edit” link is removed from my post (#31 above) – so I can’t remove the quotation marks from the savePurchase function. Yikes.
EDIT2: I am now working to add a consumable item to my In-App Purchase options, and I am back to debug my savePurchase function. And, really, the product parameter should be a number after all – at least that’s how it needs to be with the way I’m using this function. So… here’s the second edit:
[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(1) – when saving product1
savePurchase(2) – when saving product2
savePurchase(3) – when saving product3[/lua]
Also note, oddly enough, my test user’s purchase status gets cleared by iTunes Connect every so often (I don’t know exactly how often it gets reset, but it works anyhow), so I no longer worry about testing the purchase process repeatedly. Cheers. [import]uid: 67217 topic_id: 16336 reply_id: 61889[/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 (1000, function() print('Calling: store.init'); store.init( storeTransaction) end )
timer.performWithDelay (3000, function() print('Calling: iap\_setupMyStore'); setupMyStore() end )
[import]uid: 89663 topic_id: 16336 reply_id: 72564[/import]
Hi Everyone,
I am facing problem for InApp purchase in which i am confused to choose which kind of provisioning profile and cerificate, because i cant able to loadProducts using my development profile.
Please give me suggestion on this issue…
Dhananjay [import]uid: 84082 topic_id: 16336 reply_id: 102085[/import]
i am using adhoc, provisioning stuff really annoys me, i almost always use adhoc unless its a build for the store.
io.output():setvbuf(‘no’) allows you to see your print statements, debugcode, and webpopupClicks in realtime in the osx/application/console or xcode organizer console. very useful if you are testing things that don’t work in the corona simulator.
ansca really needs to make every thing work in the corona simulator, one of my biggest frustrations is having to do multiple builds for device/xcode-sim for testing purposes. example:native controls/in-app
my in-app is still not working, i don’t know whats wrong. this link had some useful info on test accounts.
"THANK YOU JASON!
Problem solved, you need a test account that NEVER has a credit card attached to it, NEVER is logged into itunes store or app store via device, and if you do login to itunes or agree to any app store stuff it voids the test account and will never work again.
So, To test your In App Purchase app, you need to use a new account that does not have a credit card. logout of the store, and only use your new account inside the app you are testing.
Thanks for the help guys! "
[import]uid: 89663 topic_id: 16336 reply_id: 72519[/import]
use ad-hoc
ios provisioning portal > provisioning > distribution > new profile > ad-hoc [import]uid: 89663 topic_id: 16336 reply_id: 102130[/import]
Hi! Trying to get InApp purchases working too… I have all the code in the app and I’m able to view some messages from Apple already:
- You are about to purchase A that costs B$
- You already purchased that but didn’t download, want to download now?
The thing is the transactionCallback listener isn’t firing or so it seems, as it never does what it should or show up the alert I have there for testing purposes.
I’m pretty sure everything is setted up ok (AdHoc build, Test users and App Code) apart from the products on iTunes Connect, they are actually on ‘Ready to Submit’ state and checked to be available with the next binary I’ll upload. The app isn’t finished yet so I don’t have the final screenshot but I filled that with a fake image. Could this be the reason why they are not firing? Does everything need to be finished and purchases in ‘Ready to Review’ state to be able to test them?
I hope someone has an answer, I’ve been fighting with this for quite a while…
So thanks everyone! [import]uid: 13811 topic_id: 16336 reply_id: 109556[/import]
do you mean you have an alert that is suppose to fire in the callBack? it is unclear to me what the problem is maybe post your code.
[import]uid: 89663 topic_id: 16336 reply_id: 109610[/import]
Here is all my store code apart from the store.purchase{ “com.mydomain.product1” } that’s on buttons. There is indeed an alert supposed to fire in the callback and there is also some code that should be doing its thing wich I just removed to not post it here.
But about the products in iTunes Connect, do they need to be on a specific state to be able to test them, or they could stay as they are now ‘Ready to Submit’?
Thanks for helping ezraanderson1979!
store = require "store"
local listOfProducts = {
"product1",
"product2",
"product3"
}
local validProducts, invalidProducts = {}, {}
local unpackValidProducts = function()
if (not validProducts) then
native.showAlert("In-App features not available", "initStore() failed", { "OK" })
else
for i=1, #invalidProducts do
native.showAlert("Item " .. invalidProducts[i] .. " is invalid.", { "OK" })
end
end
end
local loadProductsCallback = function(event)
native.showAlert("Loading products", "Loading store products", { "OK" })
validProducts = event.products
invalidProducts = event.invalidProducts
unpackValidProducts()
end
local transactionCallback = function(event)
local transaction = event.transaction
native.showAlert("Transaction Callback", "Entered Callback: " .. transaction.productIdentifier, { "OK" })
if (transaction.state == "purchased") then
print("Transaction successful!")
if (transaction.productIdentifier == "com.mydomain.product1") then
-- Code to unlock thing and save in file
elseif (transaction.productIdentifier == "com.mydomain.product2") then
-- Code to unlock thing and save in file
elseif (transaction.productIdentifier == "com.mydomain.product3") then
-- Code to unlock thing and save in file
end
native.showAlert("Thank You!", "Thank you for your purchase!", { "OK" })
elseif (transaction.state == "restored") then
print("Transaction restored (from previous session)")
print("productIdentifier", transaction.productIdentifier)
print("receipt", transaction.receipt)
print("transactionIdentifier", transaction.identifier)
print("date", transaction.date)
print("originalReceipt", transaction.originalReceipt)
print("originalTransactionIdentifier", transaction.originalIdentifier)
print("originalDate", transaction.originalDate)
if (transaction.productIdentifier == "com.mydomain.product1") then
-- Code to unlock thing and save in file
end
elseif (transaction.state == "cancelled") then
print("Transaction cancelled by user")
elseif (transaction.state == "failed") then
print("Transaction failed, type:", transaction.errorType, transaction.errorString)
else
print("Transaction ended with unknown event")
end
store.finishTransaction(transaction)
end
local restorePurchases = function()
store.restore()
end
local setupMyStore = function()
store.loadProducts(listOfProducts, loadProductsCallback)
end
local startStore = function()
store.init(transactionCallback)
end
if (store.canMakePurchases) then
timer.performWithDelay(1000, startStore)
timer.performWithDelay(2000, setupMyStore)
timer.performWithDelay(3000, restorePurchases)
end
[import]uid: 13811 topic_id: 16336 reply_id: 109628[/import]
Ready to Submit works for me. its late i am going to bed i will look at the code tomorrow. [import]uid: 89663 topic_id: 16336 reply_id: 109634[/import]
Hmmm if that works for you I can say I’m totally lost now…
[import]uid: 13811 topic_id: 16336 reply_id: 109752[/import]
So weird… I’ve done everything you said, but I’m not seeing anything on Console related to my products, but when I press a purchase button I get an error like this:
unknown wifid[13] : Wifi:[360275152.627397]: Client itunesstored is background application
I’ve tried it on wifi and 3g and I get the same, does this mean something for you?
[edit]
Oh and something else, I don’t see apple’s messages anymore with the new changes, looks like it doesn’t see what product I want to buy [import]uid: 13811 topic_id: 16336 reply_id: 109778[/import]