0 votes

Good morning. I don't understand how I could handle a purchase in my game.

I tried to do everything according to the documentation, but the purchase does not work.

I added the product to Google Play Console.

I added "com.android.vending.BILLING" permisson to my project in Project -> Export -> Android -> Permissions -> Custom Permissions .

I added an iap file from github Godot and I set it up as an autoload in Project -> Project Settings -> AutLoad. It is this file https://github.com/godotengine/godot-demo-projects/blob/master/misc/android_iap/iap.gd

I can normally use references by typing iap in any file.

Could someone show me how to make a in game purchase with Godot?

When I click the " BUY" button, I have this script

func _on_Buy_50_pressed(): # Button pressed
iap.connect("purchase_success", self, "purchase_success_callback") # Connect
iap.purchase("50gold")   # Buy item with id=50gold

And this is my purchasesuccesscallback(item) function

func purchase_success_callback(item):
GOLD += 50
print(item + " has purchased")

Could someone show me how to do it right?

in Engine by (14 points)
recategorized by

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.