Android In App Billing Issue (SOLVED)

I actually don’t know if it is a bug or not,…but i really need your help to fix this one. I used the given code in In-App-Purchase tutorial in the learn section and apply it to my game…what i can’t figure out is whenever i try to test an order from my game to my IAP in Dev Console,… the Google IAP–API always shows 3 times in a single click to a button in my game (i figured it out coz whenever i tap outside of the google iap API, the first google API will close and then the second google iap API will show, and when i try to tap outside again, the second google iap API will close and then third google iap API will show )…and if i tried to buy from the first google iap-API,…it always crashes and cancelled the whole transaction…but when i try to buy from the second and third google iap-API,…i can actually continue to purchase the test order…why is this always happen?..can you tell and help me how to fix this one?..thanks! :’)

Hmm, ok, so can you make sure that you make the call to iap.buy() only when you get an action.released?

1 Like

im sorry to say this but, can you please give me a simple example on how to use it?..im really confused right now…and i really don’t know how can i implement that action.release in my code…please bear me…

I’m not sure what’s causing the issue you are seeing and I’m not even sure you can trigger more than one purchase dialog at a time, but one thing that is always good practice when you read user input in your UI code is to trigger the action when you see action.released (ie when the user releases the finger from the screen or key). I am in the code below assuming that you initialise the purchase when the user taps on a GUI box node named “purchase_button” in your game:

function on_input(self, action_id, action)
	if action.released and gui.pick_node(gui.get_node("purchase_button"), action.screen_x, action.screen_y) then
		iap.set_listener(function(self, transaction, error)
			if not error then
				print(transaction.ident)
				print(transaction.state)
				print(transaction.date)
				print(transaction.trans_ident) -- only available when state == TRANS_STATE_PURCHASED, TRANS_STATE_UNVERIFIED or TRANS_STATE_RESTORED
				print(transaction.receipt)     -- only available when state == TRANS_STATE_PURCHASED or TRANS_STATE_UNVERIFIED
				print(transaction.request_id)  -- only available for Facebook IAP transactions (and if used in the iap.buy call parameters)
				print(transaction.user_id)     -- only available for Amazon IAP transactions

				-- 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(self, transation)
				end
			else
				print(error.error, error.reason)
			end
		end)
		iap.buy("product_id")
	end
end
2 Likes

@britzl – i actually tried the sample that you gave to me,…but unfortunately, it gives the same result…idk what’s the real cause of it…i only call the iap.buy() once like in the example…but i really don’t know why google IAB always shows multiple API’s…it’s actually okay for me if i can purchase from the first google iab – API but i can’t…it always crashes the transaction…i need to tap outside of the google API just to show the second or third API so i can continue to purchase the test order…if i tried to publish it to prod. the some users try to buy from it,…i’m sure they will find this bug and will give negative comments(which is not good for me)…

Could you please add me (bjorn.ritzl@king.com) to your project so I can take a look?

1 Like

@britzl – great!..no problem sir,… i’ll add you now so you can take a look on it…

Done,…i’ll send you the opt-in link on your email…thanks! :’)

and also i added you to my project sir…

So, what I saw in VIP.gui_script is that in your on_input() function you never check action_id and you have two multi-touch bindings in your input_bindings. This will for each screen touch generate three calls to on_input(), one for the touch (action_id is “touch”) and one for each of your multi-touch bindings (“touch” and “retry_touch”). Unless you are actually making use of multi-touch you should remove the multi-touch bindings. You should also make sure none of them are bound to the “touch” action_id, since this is automatically generated for touch events. And finally, as I’ve already written, check the action_id as well!

2 Likes