Godot Google Billing Library v 7 add-on

Hi everyone,

I’m excited to announce that I’ve created an addon for the Godot 4.2 game engine that integrates with Google Play Billing Library version 7. This module supports all the public functions provided by the library, handles all error codes, and can work with different pricing plans within subscriptions. It’s open-source and available on GitHub

I hope this addon helps you with your projects. Feedback and contributions are welcome!

You can check it out here: GitHub - code-with-max/godot-google-play-iapp: AndroidIAPP is a plugin for the Godot 4.2+ game engine. It provides an interface to work with Google Play Billing Library version 7. The plugin supports all public functions of the library, passes all error codes, and can work with different subscription plans.

Happy coding!

8 Likes

Hey dude! You’re a good soul, yesterday was looking for a plugin compatible with 4.2 V and you just appears on github few hours ago, good job my friend, do you think can you send me your email to contact you in any help? I’m also looking for a Google Play services plugin on Godot 4.2 that let you selects email, the actual one that exist on github it’s automatically logged in

4 Likes

Hi
I’m not sure how appropriate it is to post an email here. But it’s definitely available on my github profile.
In any case, you are free to ask questions.

1 Like

Any chance you have a 3.5.3 version of the plugin?
The only one I can find uses the older Play Billing Library version 5.2.1.
Google requires v6 as a minimum.

1 Like

Thank you for your interest in my Google Play Billing plugin. Unfortunately, I do not plan to adapt or support this plugin for Godot versions below 4.2. My current focus is on supporting and developing for the latest versions of the engine to ensure compatibility with Google’s latest libraries and requirements.

I recommend considering upgrading your project to a newer version of Godot. If that’s not an option, you’re welcome to fork the existing version of the plugin and adapt it for the version of the engine you need.

Thank you for your understanding, and best of luck with your development!

for godot 3 with godot billing v6 and up:
https://github.com/201949/godot-google-play-billing-6/

Hello.
Which file should we add to the addons folder?
Also, there was a .gdap file in the library I used before, but I didn’t see it here. How can I do that?

1 Like

How we can upgrade this plugin for godot 4.3 ?

Tnx so much for replying, it is working?

Doesn’t for me :thinking:

It is not working in my godot 4.3 project, unfortunately godot mobile community incredibly weak, if godot solve in app purchase problems for mobile, many people will choose godot

Hello.
I want to integrate the library version you have shared into my own project, but when I use the codes I give below, my buttons get and do not work.
I wrote the necessary purchase content in the Store.gd scene and added the main node of the googleplay scene to this scene and then connected the signals to store.gd.
I have used this system before for 5.2.1 but in this new version I am getting errors from the code in the googleplay.gd scene.
I transferred the necessary files to the addons folder and activated them in the project settings.
I adapted the codes you gave me but I guess it didn’t work as I wanted.
Can you help me fix this error?

GooglePlay.gd:

extends Node

@export_category("Products")
@export_multiline var product_ids = "product1,product2"

var billing = null

var recent_product_id
var recent_purchase_type

signal products_ready(product_ids, product_prices)
signal bought_product(product_id: String)

func _ready() -> void:
	if Engine.has_singleton("AndroidIAPP"):
		billing = Engine.get_singleton("AndroidIAPP")
		print("AndroidIAPP singleton loaded")
		
	
		billing.startConnection.connect(_on_start_connection)
		billing.connected.connect(_on_connected)
		billing.query_product_details.connect(_on_product_details_query_completed)
		billing.query_product_details_error.connect(_on_product_details_query_error)
		billing.purchase.connect(_on_purchases_updated)
		billing.purchase_error.connect(_on_purchase_error)
		billing.purchase_acknowledged.connect(_on_purchase_acknowledged)
		billing.purchase_consumed.connect(_on_purchase_consumed)
		
		billing.startConnection() 
	else:
		printerr("AndroidIAPP singleton not found")


func _on_start_connection() -> void:
	print("Billing: start connection started")

func _on_connected() -> void:
	print("Successfully connected")
	billing.queryProductDetails(product_ids.split(","), "inapp")


func _on_product_details_query_completed(response):
	print("Successfully prepared the products")
	var ids = []
	var prices = []
	for product in response["product_details_list"]:
		ids.append(product["product_id"])
		prices.append(product["price"])
	emit_signal("products_ready", ids, prices)


func _on_product_details_query_error(error) -> void:
	print("Failed to prepare the product: ", error)


func buy(product_id, purchase_type):
	recent_product_id = product_id
	recent_purchase_type = purchase_type
	billing.purchase([product_id])


func _on_purchases_updated(response):
	for purchase in response["purchases_list"]:
		process_purchase(purchase)

func process_purchase(purchase):
	if recent_purchase_type == "consumable":
		billing.consumePurchase(purchase["purchase_token"])
	elif recent_purchase_type == "one-time":
		if not purchase["is_acknowledged"]:
			billing.acknowledgePurchase(purchase["purchase_token"])
	emit_signal("bought_product", recent_product_id)
	print("Successfully purchased")


func _on_purchase_error(error):
	print("Failed to purchase: ", error)


func _on_purchase_consumed(response):
	print("Successfully consumed the purchase")


func _on_purchase_acknowledged(response):
	print("Successfully acknowledged the purchase")

Store.gd:

extends Node

@onready var ui_control = preload("res://Scripts/UIControl.gd").new()
@onready var store_panel = $Store/StorePanel
@onready var buyButtons = {
	"one_offer" : $Store/BuyButton,
	
}

var activated_purchase_window = {
	0 : false,
}

const package_names = {
	0 : "one_offer",
}

func purchase_package(product_id: String):
	match product_id:
		package_names[0]:
			Player.coin = ui_control.coin_increase(Player.coin, 2000, "coin")
			print("package " + package_names[0] + " is purchased!")
		

func in_app_purchase(product_id: String):
	if OS.get_name() == "Android":
		$Store/google_play.buy(product_id, "consumable")
		
func reset_purchase_state():
	for i in range(0):
		activated_purchase_window[i] = false

func open_purchase_window():
	store_panel.show()
	
func close_purchase_window():
	store_panel.hide()

func get_prices(product_ids, product_prices):
	for i in buyButtons.size():
		buyButtons[product_ids[i]].text = product_prices[i]
		buyButtons[product_ids[i]].disabled = false 

func _on_one_offer_button_pressed():
	activated_purchase_window[0] = true
	open_purchase_window()
	

func _on_store_no_button_pressed():
	close_purchase_window()
	reset_purchase_state()

func _on_store_yes_button_pressed():
	for i in range(0):
		if activated_purchase_window[i] == true:
			in_app_purchase(package_names[i])
	close_purchase_window()
	reset_purchase_state() 

func _on_google_play_bought_product(product_id):
	purchase_package(product_id)

func _on_google_play_products_ready(product_ids, product_prices):
	print("in app products are ready!")
	get_prices(product_ids, product_prices)
3 Likes

I have the same problem, can anyone answer?

1 Like

Try to remove the purchase_package function or modify it to only update the game state based on the product_id received through the bought_product
signal.

1 Like

Unbelievable :open_mouth: