store.consumePurchase where to place it?

Hello everyone.

I would have a problem with the type of consumable purchases. I cannot understand where to put the code: store.consumePurchase

Currently my code is this:

local store = require( "plugin.google.iap.v3" ) local function transactionListener( event ) local transaction = event.transaction if ( transaction.state == "purchased" ) then store.consumePurchase( "money1000", transactionListener) end store.finishTransaction( transaction ) end store.init( "google", transactionListener ) store.purchase( "money1000" )

When I make the purchase and is successful (at least this works), it does not allow me to buy it again. Also waiting minutes or hours as is recommended. So is recognized me as purchase un-consumable. The question is: what should I do to make it recognize consumable and then buy it back again? (Obviously I know I have to redo a new in App-ID).

Note: My target is currently only Play Store

Thanks for the attention.

You should be able to consume the purchase, if its a type of item that can be multiple times in your listener function. Google may have changed the rules, but that used to work.

The intent was that if you used an IAP to buy a consumable like a potion or a power up, you should use that item before allowing them to buy more. But realistically if they are buying coins or gems, those go into a pool and it’s hard to say when those got used. Google may be enforcing this now in which case, wait until the player actually uses what they bought.

Rob

Hello Rob, thank you for having responded, excuse me but I still do not understand.

I understand that Google wants to know if the purchased item was used. But how?

In addition reading the official documentation in-App (https://developer.android.com/google/play/billing/api.html), Google wants to know when you get them back available through consumePurchase. But I see that Google does not understand, maybe I have to add another code?

It sounds to me like when you get a “purchased” call, you call store.comsumePurcahse(). You should get a second transaction that it was consumed at which point you would give the item to the user.

Though personally I don’t see why you wouldn’t go ahead and give the item on the “purchased” event and then basically confirm things when you get the second event.

I guess Googles concept here is you buy a 100 gem pack then delete the app before you use the gems, the user should be able to restore that purchase and once consumed, it can’t be restored.

Thanks Rob for having clarified the point. I’m sorry if I made you lose time, because I was able to make it work, and the mistake was mine. I was testing the app on the simulator first and then on the device. Unfortunately, the simulator did not accept store.consumePurchase, then did not send to Google the consumable token. Instead, trying first on device worked perfectly.

You should be able to consume the purchase, if its a type of item that can be multiple times in your listener function. Google may have changed the rules, but that used to work.

The intent was that if you used an IAP to buy a consumable like a potion or a power up, you should use that item before allowing them to buy more. But realistically if they are buying coins or gems, those go into a pool and it’s hard to say when those got used. Google may be enforcing this now in which case, wait until the player actually uses what they bought.

Rob

Hello Rob, thank you for having responded, excuse me but I still do not understand.

I understand that Google wants to know if the purchased item was used. But how?

In addition reading the official documentation in-App (https://developer.android.com/google/play/billing/api.html), Google wants to know when you get them back available through consumePurchase. But I see that Google does not understand, maybe I have to add another code?

It sounds to me like when you get a “purchased” call, you call store.comsumePurcahse(). You should get a second transaction that it was consumed at which point you would give the item to the user.

Though personally I don’t see why you wouldn’t go ahead and give the item on the “purchased” event and then basically confirm things when you get the second event.

I guess Googles concept here is you buy a 100 gem pack then delete the app before you use the gems, the user should be able to restore that purchase and once consumed, it can’t be restored.

Thanks Rob for having clarified the point. I’m sorry if I made you lose time, because I was able to make it work, and the mistake was mine. I was testing the app on the simulator first and then on the device. Unfortunately, the simulator did not accept store.consumePurchase, then did not send to Google the consumable token. Instead, trying first on device worked perfectly.