What are the additional values of the state field and are there code samples on how to use them?
For example: “pending”… isn’t this messing with old code? And what is the new “restoreCompleted” for exactly when a restore is also handled in the purchase state?
As for “restoreCompleted”, if you call restore() you get flooded with every purchase transaction. For most apps that may be 1 or 2. But for something like a monthly subscription, you’ll get EVERY transaction which could be dozens and dozens (one for every month). So the restoreCompleted transaction comes in at the end, to essentially tell you that it’s sent everything it can find.
Not sure on “pending”. Our subscription code only looks for “purchased”, “cancelled”, or “failed” and anything else it just ignores.
I have a strange problem with my code: I am using the same purchase code from another game where it is working perfectly. I have looked through the code 10 times and it really is identical in usage but somehow I now do not get into the part of the transaction listener which is handling the purchased state.
I first thought it would be the new plugin for billing but it also happened with the old one.
Now I wonder if the “new” states like for example “pending” were sent and catched by the transactionListener with the old plugin also?
I am finishing the Transaction Listener for all states… so does this mean with “pending” I am not allowed to close the Listener, right? Maybe this is the reason I don’t get to the “purchased” state?
What is the best practice for handling the new states and when do you close the listener with store.finishTransaction( event.transaction ) ?
Here is my example for the NOT working listener (Products are tested by getting the correct price for each… so the store also is working correctly)… is there something I am missing?
_G.transactionListener = function( event )
local productID
if ( event.name == "init" ) then
if not ( event.transaction.isError ) then
_G.storeinitsuccesfull=1
productID= event.transaction.productIdentifier
else -- Unsuccessful initialization; output error details
local doitnow=performWithDelay(3000,function() removeShopPopup();initstore() end,1)
end
else
productID= event.transaction.productIdentifier;
if event.transaction.state == "purchased" then
-- THIS PART OF CODE IS NOT GETTING ACCESSED IT SEEMS!
elseif event.transaction.state == "refunded" then
-- handle refunds here
elseif event.transaction.state == "cancelled" then
removeShopPopup()
elseif event.transaction.state == "failed" then
removeShopPopup()
else
removeShopPopup()
end
local doitnow=performWithDelay(2200,function() _G.store.finishTransaction( event.transaction );_G.storeinitsuccesfull=0;removeShopPopup();initstore() end,1)
end
end
Is there a reason you have finishTransaction on a delay? That could be causing some issues for sure.
And I don’t do any special handling for “pending”. I actually don’t do anything with that type of transaction, other than calling finishTransaction on it.