IAP interrupted purchase - how to handle

Just wondering.
While testing my IAP setup, I encountered the situation that the App Store tells me the product was already purchased but not downloaded.
How should you handle a situation like this?
In the callback routine there does not seem to be an event that says “resuming” or such.
Should the IAP handle this automatically after init()?

Using a Restore button does work, but unfortunately the default iTunes reply does not include such a suggestion to the suer.

BTW, I’m using the standard structure for the callback routine (see below). Could it be that the FinishTransaction call should be somewhere else?

  
function transactionCallback( event )  
 if event.transaction.state == "purchased" then  
 print("Bought: " .. event.transaction.productIdentifier)  
 elseif event.transaction.state == "restored" then  
 print("productIdentifier", event.transaction.productIdentifier)  
 print("receipt", event.transaction.receipt)  
 print("transactionIdentifier", event.transaction.transactionIdentifier)  
 print("date", event.transaction.date)  
 print("originalReceipt", event.transaction.originalReceipt)  
 elseif event.transaction.state == "cancelled" then  
 print("Transaction cancelled by user.")  
 elseif event.transaction.state == "failed" then  
 print("Transaction failed, type: " .. event.transaction.errorType .. "\n" .. event.transaction.errorString)  
 else  
 print("Unknown event")  
 end  
 store.finishTransaction( event.transaction )  
end  

Thanks
[import]uid: 123200 topic_id: 26331 reply_id: 326331[/import]

I don’t understand your question.

When you try to purchase a product that you have purchased before, the Store alerts you.
This is automatically. You can choose “cancel” or “ok” and download it again without pay again.
I don’t understand what the problem is.

[import]uid: 105206 topic_id: 26331 reply_id: 106768[/import]

Okay, sorry about the unclear question.

I was just wandering if you need to code any action for an interrupted sale (not canceled or failed).
Say I buy an add-on, but somehow the process aborts (I press Home or there’s a phone call) but after the purchase is approved.

Does the store automatically try to resume downloading/finishing a purchase when I open the app again (and have a store.init() in the beginning)?

How about when I do not leave the app but the process still does not finish properly (say the network went down). When I want to use the newly bought add-on it will work because the store did trigger the “purchased” state but the process was not completely done. This should be cleaned up, right? Do I need to press my Restore button so store.restore() is called?

Or am I fabricating a non-existent problem here?
[import]uid: 123200 topic_id: 26331 reply_id: 106780[/import]

@dutchottie, I think it’s a very valid and a very good question. I would like to know the answer to the very same question. I mean, I’d like to code to handle the situation you’ve described, but I have no idea what transaction.state I need to specify for this particular scenario. I really wish there’s a laundry list of all possible transaction.state that transactionCallback returns.

Naomi [import]uid: 67217 topic_id: 26331 reply_id: 106826[/import]

store.init()'s behavior is described here.
http://developer.anscamobile.com/reference/in-app-purchases
Is your question not addressed by this?

As for errors and states, your guess is as good as ours. We only know what is documented by Apple and they don’t really document any of this. Maybe you guys should start a wiki or forum thread that maintains a matrix of everything you learn.
[import]uid: 7563 topic_id: 26331 reply_id: 106867[/import]

Ah, okay, thank you @ewing. Apple does make things harder when it doesn’t have to be. I guess I’ll need to add print statement to display transaction.state and start collecting data. Ugh. Another item added to awfully-tiresome-thing-to-do list.

Thanks again.

Naomi [import]uid: 67217 topic_id: 26331 reply_id: 106878[/import]

@ewing
Thanks for the reference, although the docs are really good, it doesn’t answer my question.
Judging from what others say I guess there’s no real answer at the moment.
If I find out anything more, I’ll be sure to post it.

Thanks all!!
[import]uid: 123200 topic_id: 26331 reply_id: 106887[/import]

Hey Corona Subscribers Devs, did you see it at the newest daily build? Look below the details:

CoronaSDK 2012.814
Post date: Tue, 2012-05-15 07:09

Release notes for build 2012.813 through 2012.814

casenum 13526: iOS: In-App Purchases: store.restore failures/cancellations now give you a callback with the transaction.state of “failed”. The errorType will be “restoredFailed”. The errorString will give you Apple specific information about the kind of failure (e.g. ‘‘Cannot connect to iTunes Store’, Your Apple ID or password is incorrect.’). Note that Android will never give you this errorType since it doesn’t make strong distinctions between buy/restore.
THANK YOU ANSCA MOBILE TEAM! We just got an amazing new status regarding IAP (what`s a pain) haha.
Cheers,
Rodrigo.
[import]uid: 89165 topic_id: 26331 reply_id: 106900[/import]