TransactionListener Sample?

I wonder if there is a new sample code available somewhere for the new version of the TransactionListener with all the changes to the new plugin?

Is anybody having a sample for a correct new TransactionListener and some information on how a purchase now has to be made to really make it work?

Any help welcome!

Is this not what you’re looking for:

Really not much changed in the plug-in (thankfully!), just what’s noted under the “Compatiblity with IAPv3” here:

Is there a specific value/case you’re looking to handle?

I just changed the two lines below from the old sample.


-- [""] = {
[""] = {


-- store = require( "" )
store = require( "" )

Thanks for your fast feedback. I knew the links but missing some explicit samples for those parts:

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.

Thanks for your feedback.

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 ( == "init" ) then
    if not ( event.transaction.isError ) then

        productID= event.transaction.productIdentifier
    else  -- Unsuccessful initialization; output error details

        local doitnow=performWithDelay(3000,function() removeShopPopup();initstore() end,1)


      productID= event.transaction.productIdentifier;

      if event.transaction.state == "purchased" then

      elseif event.transaction.state == "refunded" then
        -- handle refunds here

      elseif event.transaction.state == "cancelled" then


      elseif event.transaction.state == "failed" then        



      local doitnow=performWithDelay(2200,function() event.transaction );_G.storeinitsuccesfull=0;removeShopPopup();initstore() end,1)


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.