godot-sdk-integrations / godot-google-play-billing

Godot Android plugin for the Google Play Billing library
MIT License
156 stars 50 forks source link

I cant get product name with GodotGooglePlayBilling.2.0.0 (with GodotGooglePlayBilling.1.0.1 I could get it) #39

Closed Biran0 closed 2 years ago

Biran0 commented 2 years ago

Is it normal that

if purchase.products == .. returns always True ?

I have only one product for in app purchase (Full_game). And purchase.products indeed returns "Full_game" but when I try to check

if purchase.products == "what-ever-I-put-here" it returns always True

(I can purchase product fine, and acknowledge purchase fine, I just cant get name of already purchased products)

I tried to get my product name using Purchase.getSkus() but it crashes

..from the notes of the change-log for GodotGooglePlayBilling.2.0.0 , it looks like I should call inside

func _on_query_purchases_response(query_result): var scus = query_result.getSkus()

right?

ps: I also tried
for purchase in query_result.purchases: var scus = purchase.getSkus()

ps2: I'm trying to figure it out (asking in Reddit etc) for almost a month now. (purchases etc work fine , its just very difficult to find out how to get name of already purchased products)

Thank you.

NianoTT commented 2 years ago

purchase.products is a dictionary, so you need to check like that:

if "your_product" in purchase["products"]:

the check itself, performed like that, works for me without issues.

Biran0 commented 2 years ago

Thank you! Indeed if "your_product" in purchase["products"]:
works perfectly! I will update my post on Reddit ,so I wont confuse any people there.