store.purchase callback delay

Hi,

I discovered an odd problem where there is a long delay between google play store saying “Purchase Successful” and the callback declared in store.init() being called.

It occurs on Version 2013.1260 (2013.11.13). I don’t know if it is fixed in later version.

It is possibly related to the fact that in my code, there is quite a lot of functionality within the storeTransaction code-block, but I suspect it is a bug.

The solution seems to be to put a small delay in the callback. After introducing the delay, the problem went away… phew!

hope this helps somebody!

anthony

function storeTransaction( event )

   local function afterDelay()
 

       – rest of code

   end

   timer.performWithDelay(100, afterDelay)

end

 
store.init( storeTransaction )

store.purchase( {“com.coronalabs.NewExampleInAppPurchase.NonConsumableTier1”} )

I am not sure why you need to have a delay at all.  Your callback will trigger whenever the Google Play “purchased” state is returned.

I will say that in my testing with the Google Play IAP workflow, after I see the payment successful screen appear and close, it can take a second to like 8 seconds for that purchased state to get returned.  And the callback handles it fine.

I agree - I also see no reason why the delay makes a difference.

But, without the delay, I was waiting up to 30 seconds for the game to respond after the user received a “Purchase successful” message. Enough to give a bad user experience.

No idea why the delay made a difference unless there is a bug in Corona somewhere preventing a long block of code executing quickly after the callback.

Weird, never heard of that.  So basically you just put everything in your callback into its own function inside the callback, then delay calling that function by 1/10th of a second?

Will have to try it and see if it makes a difference for me.

I am not sure why you need to have a delay at all.  Your callback will trigger whenever the Google Play “purchased” state is returned.

I will say that in my testing with the Google Play IAP workflow, after I see the payment successful screen appear and close, it can take a second to like 8 seconds for that purchased state to get returned.  And the callback handles it fine.

I agree - I also see no reason why the delay makes a difference.

But, without the delay, I was waiting up to 30 seconds for the game to respond after the user received a “Purchase successful” message. Enough to give a bad user experience.

No idea why the delay made a difference unless there is a bug in Corona somewhere preventing a long block of code executing quickly after the callback.

Weird, never heard of that.  So basically you just put everything in your callback into its own function inside the callback, then delay calling that function by 1/10th of a second?

Will have to try it and see if it makes a difference for me.