Recover Purchased Consumable item after network outage

I implemented in-app billing for my game, i am testing various condition that can cause problem in this process.

I used consumable items (coin) in it.

when a user purchase coin,this code will happen in callback :

if ( transaction.state == "purchased" ) then print( "Transaction succuessful!" ) store.finishTransaction( transaction ) timer.performWithDelay(10, function() store.consumePurchase( products[1],transactionCallback); end )

As i read in this post,if network outage happens before store.finishtranscation , market will send transaction again and again.if user closed the app in this situation(purchased but not finished transction due to network outage ) how should i recover the purchase after user started app again?


Thanks

Arash

Hi Arash,

The “.finishTransaction()” API is not even functional for Google IAP. See here:

https://docs.coronalabs.com/plugin/google-iap-v3/finishTransaction.html

Brent

Hi brent,

So if network outage occured before calling store.consumetransaction , when should i consume the purchased item so it can be available to purchase?


Thanks
Arash

Hi Arash,

I don’t think it’s necessary to call the consume following a timer delay, however IAP is not my absolute “specialty” and if you have a forum post or resource which you can point me to which states otherwise, please tell me (but not the previous link you posted; that was misleading in stating the Google IAP uses the .finishTransaction() API, which it doesn’t).

Is your concern that somehow a network outage will occur at the same time a purchase is completed and the consume command is called?

Thanks,

Brent

i read about using timer for consumePurchase in this post : https://forums.coronalabs.com/topic/52699-google-iap-v3-crash-while-calling-storeconsumepurchase/?hl=consumepurchase

also  in that post Rob Miracle said about using finishtransaction on android.

Is your concern that somehow a network outage will occur at the  same  time a purchase is completed and the consume command is called?

 

yes, network outage,app crash,killing the process of game(by user or by OS).these are the conditions that may happen and i had this experience on developing apps on native android,here is the method that google suggested for above conditions,however  corona does not support getPurchases , AFAIK :

 

What google says:

  1. Send a getPurchases request to query the owned in-app products for the user.
  2. If there are any consumable in-app products, consume the items by calling consumePurchase. This step is necessary because the application might have completed the purchase order for the consumable item, but stopped or got disconnected before the application had the chance to send a consumption request.
  3. Get a response code from Google Play indicating if the consumption completed successfully.
  4. If the consumption was successful, provision the product in your application.

.restore() should trigger a getPurchases(), though it may not report consumables.  Since Google will give you an error if you haven’t consumed the purchase, if you try and purchase, get the error, consume the purchase and retry the purchase.

Rob

Hi Arash,

The “.finishTransaction()” API is not even functional for Google IAP. See here:

https://docs.coronalabs.com/plugin/google-iap-v3/finishTransaction.html

Brent

Hi brent,

So if network outage occured before calling store.consumetransaction , when should i consume the purchased item so it can be available to purchase?


Thanks
Arash

Hi Arash,

I don’t think it’s necessary to call the consume following a timer delay, however IAP is not my absolute “specialty” and if you have a forum post or resource which you can point me to which states otherwise, please tell me (but not the previous link you posted; that was misleading in stating the Google IAP uses the .finishTransaction() API, which it doesn’t).

Is your concern that somehow a network outage will occur at the same time a purchase is completed and the consume command is called?

Thanks,

Brent

i read about using timer for consumePurchase in this post : https://forums.coronalabs.com/topic/52699-google-iap-v3-crash-while-calling-storeconsumepurchase/?hl=consumepurchase

also  in that post Rob Miracle said about using finishtransaction on android.

Is your concern that somehow a network outage will occur at the  same  time a purchase is completed and the consume command is called?

 

yes, network outage,app crash,killing the process of game(by user or by OS).these are the conditions that may happen and i had this experience on developing apps on native android,here is the method that google suggested for above conditions,however  corona does not support getPurchases , AFAIK :

 

What google says:

  1. Send a getPurchases request to query the owned in-app products for the user.
  2. If there are any consumable in-app products, consume the items by calling consumePurchase. This step is necessary because the application might have completed the purchase order for the consumable item, but stopped or got disconnected before the application had the chance to send a consumption request.
  3. Get a response code from Google Play indicating if the consumption completed successfully.
  4. If the consumption was successful, provision the product in your application.

.restore() should trigger a getPurchases(), though it may not report consumables.  Since Google will give you an error if you haven’t consumed the purchase, if you try and purchase, get the error, consume the purchase and retry the purchase.

Rob