How to handle interrupted purchase transactions?

I’ve finally begun testing in app purchases on my Android device using the v3 plugin. I have a server running Coronium which I use to validate purchases and respond to let my app know to unlock whatever feature, add coins, etc.

Everything works for the most part. The issue I’m facing right now is how to handle the case of my app being closed between when Google Play responds with the receipt and when my server responds with the validation.

I call store.finishTransaction (for iOS devices) and store.consumePurchase (for consumable items on Google) only after my server sends back an affirmative response. If I close my app at the right time, nothing gets sent to my server, and the code to unlock whatever item never gets executed. When I tap the buttons to try again, Google Play just responds with

 transaction = { state = "failed", errorString = "Unable to buy item (response: 7:Item Already Owned)", isError = true, errorType = 7 }

What is the correct way to deal with this situation?

If you call store.restore() when your app starts up you will get a new transaction that would come in as a “purchase” of the item.  Since your server doesn’t know about it yet, it should treat it as a new transaction.

Rob

If you call store.restore() when your app starts up you will get a new transaction that would come in as a “purchase” of the item.  Since your server doesn’t know about it yet, it should treat it as a new transaction.

Rob