Am I doing In-app purchases right?

When testing in app purchases the purchase was successful but it failed to register the changes in the game please what is wrong?

1 Like

What do you mean by this? The minimal IAP purchase example from the API docs is:

local function iap_listener(self, transaction, error)
  if error == nil then
    -- purchase is successful.
    print(transaction.date)
    print(transaction.)
    -- required if auto finish transactions is disabled in project settings
    if (transaction.state == iap.TRANS_STATE_PURCHASED) then
      -- do server-side verification of purchase here..
      iap.finish(transaction)
    end
  else
    print(error.error, error.reason)
  end
end

function init(self)
    iap.set_listener(iap_listener)
    iap.buy("my_iap")
end

Do you get a callback to your IAP listener or not?

2 Likes

PS: Please use more descriptive post/question titles than “Am I doing it right?”. I changed yours to “Am I doing In-app purchases right?”

3 Likes

I used the example from the API docs

You didn’t answer my question. What kind of problem are you experiencing with IAPs?

It doesn’t activate the product after the transaction is complete

What do you mean by activate? Is it a normal consumable product you are trying to buy? Android or iOS? What is the response you get from the purchase? pprint() and share here. Please provide as much detail as you can. Preferably more than a single sentence.

2 Likes

OK but I’ll confirm if the problem is with my script first