in-app purchase template

@Naomi. You have been such a great help. I am learning so much from you. Thanks again! [import]uid: 104131 topic_id: 29458 reply_id: 120307[/import]

@e1fabre, no problem at all. I’m happy to help. I’ve been helped – it always feels like god-sent, honestly. So I’m giving back to the community what I can. I hope you’ll do the same down the road.

Cheers,
Naomi [import]uid: 67217 topic_id: 29458 reply_id: 120332[/import]

@Naomi,
I just want to thank you and report that thanks to you everything seems to works fine now. Resetting the device worked for me. I also found out that some time even resetting the device is not enough. From time to time I also have to shut the device down an order for me to get the “Download again” message.

One last question. Do I need a restore button? Do you have a restore button in your games for non-consumable goods? Thanks again for your help.

[import]uid: 104131 topic_id: 29458 reply_id: 119742[/import]

@e1fabre, glad to hear you got IAP sorted. About restore button, from what I gleaned, it does sound like you need a restore button for non-consumable goods. I’ve seen posts about Apple rejecting app without it. So I added it in my first game (called Beetle Bounce ) under Options screen.

Cheers,
Naomi [import]uid: 67217 topic_id: 29458 reply_id: 119764[/import]

@ Macmanman223, Thank you for the link.

@Naomi, I can’t thank you enough for helping me with my issues with IAP. My final question is based on the “Restore” button. From what i am reading from the forum, Apple is rejecting apps that don’t have a “Restore” button. I would hate to spend all this time working on an app and have it rejected. I found a sample code in the forum for a restore button. My questions are:

  1. in the Restore function sample code below where it said "

–If the product is called for restore do your restore code here
print (“Success! Product restored”)"

Do I put in the same unlock code I have under the “transactionCalback function”, if event.transaction.state == “purchased” there.

local transactionCallback = function( event )
if event.transaction.state == “purchased” then
print(“Transaction successful!”)
–my unlock code

  1. How do I test it to make sure that it works. What should I expect to see when I test the “Restore” function.
    Thanks again for your help.

[code]

---------------RESTORE BUTTON ------------

–Call Restore Function
local function callRestore()

–Restore Function
local function restorePurchases(event)
–Check for restored state
if event.transaction.state == “restored” then
–Product 1
–If restore state is true then check for a match on the product identifier
if event.transaction.productIdentifier == “com.xxx.xxx.xxx” then
–If the product is called for restore do your restore code here
print (“Success! Product restored”)

I am not sure what should go here?
store.restore()
end

–Finish Transaction
store.finishTransaction( event.transaction )
end
end

–Call the apple store
store.init( “apple”, restorePurchases )
–Lastly call the restore function
store.restore()
end
restorebutton: addEventListener (“tap”, callRestore)

–Restore button
local restore_Btn = display.newRect (0, 0, 50, 50)
restore_Btn.x = 200; restore_Btn.y = 200
restore_Btn: addEventListener (“tap”, callRestore)
[/code] [import]uid: 104131 topic_id: 29458 reply_id: 120274[/import]

@e1fabre, yes to your question #1. As for your question #2, it works the same way in sandbox as it would when your app goes live. Launch your app, unlock your app (using your test user account), delete the app from the device, then reinstall it and hit your restore button to unlock your app.

Good luck with finalizing your app!

Naomi

[import]uid: 67217 topic_id: 29458 reply_id: 120278[/import]

@Naomi. You have been such a great help. I am learning so much from you. Thanks again! [import]uid: 104131 topic_id: 29458 reply_id: 120307[/import]

@e1fabre, no problem at all. I’m happy to help. I’ve been helped – it always feels like god-sent, honestly. So I’m giving back to the community what I can. I hope you’ll do the same down the road.

Cheers,
Naomi [import]uid: 67217 topic_id: 29458 reply_id: 120332[/import]

@Naomi. I was ready to submit the apps, however, I just found out it doesn’t scale correctly in IPAD 3. Can you please tell me which corona build and X code you are using to solve this issue? I am using build 2011.704. I was hoping to submit the app this week. I am not sure it will be possible now. Thanks again for all your help. [import]uid: 104131 topic_id: 29458 reply_id: 124398[/import]

@e1fabre, if I remember correctly, you need 704B (not the very first 704 release build but a 704 release build that came soon after the issue was discovered and fixed.) I no longer have the copy of 704B, but if you search the forum (google 704B and coronalabs), you’ll probably find the link. If not, post a request for the link on a general forum. I’m sure someone from Corona Labs or other users who has the link handy will post it for you.

That said, why do you want to keep using 704? You may want to seriously consider using the most recent stable release build.

Naomi
[import]uid: 67217 topic_id: 29458 reply_id: 124432[/import]

So, the sample code does not match the API docs.

The sample code refers to “store.availableStores.apple”, and then calls:

store.init(“apple”, transactionCallback)
or
store.init(“google”, transactionCallback)

But the API docs don’t mention the availableStores thing, and the docs for store.init() don’t mention anything about that extra argument. [import]uid: 143026 topic_id: 29458 reply_id: 124465[/import]

Okay, quick summary:

* It appears that the first argument of “apple” or “google” is no longer needed.
* But the loadProducts stuff doesn’t work on android.

I am not sure about availableStores; it always came back empty for me on Android, but I was running a test app with a local signature, so that may have been why. (Not nil, just empty.) Have uploaded new version to Google Play and will find out in a few hours whether that worked. [import]uid: 143026 topic_id: 29458 reply_id: 124474[/import]

@ Naomi. Thanks again for the quick reply Naomi. The problem I am having is that there are so many version of xcodes and corona builds it’s hard to know which works with which. It’s seem like some developers have been having problems with some versions of xcodes not compatible with some builds. Which build and Xcode are you using currently? I just want to make sure that I am using the correct build and Xcode version.

That sai, I really would like to submit something to the app store. Can I build just for Iphones and ignore Ipad for now? Do you know base on your experience if Apple would approve such an App? thanks again for all the help. [import]uid: 104131 topic_id: 29458 reply_id: 124682[/import]

?e1fabre, the game that’s already in App Store uses the release build 840 (and I’ve been using Xcode 4.3.1 on my system since New iPad came out.) 840 supports New iPad (a.k.a. iPad3 or iPad Retina). With my second game, I’m currently using daily build 912, but I will probably fetch more recent build soon.

You could build just for iPhones, but I believe iPad users can still download and install it. As for Apple, I don’t know if they’d approve/reject it, but if you are excluding iPad as its target device, I’d imagine they couldn’t possibly reject the app based on its issue with iPad. I just don’t have the first hand experience to tell you what may actually happen, though.

Naomi

P.S. @seebs, I hope you’ve got your problem with IAP sorted. [import]uid: 67217 topic_id: 29458 reply_id: 124708[/import]

Yes. The documentation and sample code are both slightly-wrong, I think. The (“storename”, callback) doesn’t seem to be necessary, and I couldn’t get a test against availableStores to work on Android with my test code (and didn’t want to include it in the live app), but I do have it working. [import]uid: 143026 topic_id: 29458 reply_id: 124710[/import]

@seebs, glad to hear you got yours working. You might want to report the inconsistency (or rather, wrong information posted on documentation as well as in sampel code) to Corona Labs.

Naomi [import]uid: 67217 topic_id: 29458 reply_id: 124752[/import]

@Naomi. I was ready to submit the apps, however, I just found out it doesn’t scale correctly in IPAD 3. Can you please tell me which corona build and X code you are using to solve this issue? I am using build 2011.704. I was hoping to submit the app this week. I am not sure it will be possible now. Thanks again for all your help. [import]uid: 104131 topic_id: 29458 reply_id: 124398[/import]

@e1fabre, if I remember correctly, you need 704B (not the very first 704 release build but a 704 release build that came soon after the issue was discovered and fixed.) I no longer have the copy of 704B, but if you search the forum (google 704B and coronalabs), you’ll probably find the link. If not, post a request for the link on a general forum. I’m sure someone from Corona Labs or other users who has the link handy will post it for you.

That said, why do you want to keep using 704? You may want to seriously consider using the most recent stable release build.

Naomi
[import]uid: 67217 topic_id: 29458 reply_id: 124432[/import]

So, the sample code does not match the API docs.

The sample code refers to “store.availableStores.apple”, and then calls:

store.init(“apple”, transactionCallback)
or
store.init(“google”, transactionCallback)

But the API docs don’t mention the availableStores thing, and the docs for store.init() don’t mention anything about that extra argument. [import]uid: 143026 topic_id: 29458 reply_id: 124465[/import]

Okay, quick summary:

* It appears that the first argument of “apple” or “google” is no longer needed.
* But the loadProducts stuff doesn’t work on android.

I am not sure about availableStores; it always came back empty for me on Android, but I was running a test app with a local signature, so that may have been why. (Not nil, just empty.) Have uploaded new version to Google Play and will find out in a few hours whether that worked. [import]uid: 143026 topic_id: 29458 reply_id: 124474[/import]