@@ -135,18 +135,36 @@ func _on_purchase_result(data):
135135revenuecat.fetch_offerings()
136136
137137# Products (for custom UI)
138- revenuecat.fetch_products(["premium_monthly", "premium_yearly"])
139138revenuecat.products.connect(_on_products_received)
139+ revenuecat.fetch_products(["premium_monthly", "premium_yearly"])
140140
141- func _on_products_received(data):
142- if data["error"].is_empty():
143- var products = data["products"]
144- for product in products:
145- print("ID: ", product["id"])
146- print("Title: ", product["title"])
147- print("Price: ", product["price"])
148- else:
149- print("Error: ", data["error"])
141+ func _on_products_received(data: Dictionary):
142+ var error = data.get("error", "")
143+ if error != "":
144+ print("Error: ", error)
145+ return
146+
147+ var raw_products = data.get("products", null)
148+ if raw_products == null:
149+ return
150+
151+ var products_list: Array = []
152+
153+ # ios - native array
154+ if raw_products is Array:
155+ products_list = raw_products
156+
157+ # android - array list
158+ elif raw_products is JavaObject:
159+ var count: int = raw_products.call("size")
160+ for i in range(count):
161+ products_list.append(raw_products.call("get", i))
162+
163+ # process products
164+ for product in products_list:
165+ print("ID: ", product["id"])
166+ print("Title: ", product["title"])
167+ print("Price: ", product["price"])
150168```
151169
152170### Purchases Flows
0 commit comments