Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android in app purchase : can not save item that purchased and using iap.consume("pid") #25711

Open
homarox opened this issue Feb 8, 2019 · 3 comments

Comments

@homarox
Copy link

homarox commented Feb 8, 2019

Godot version:

Godot 3.1 beta 3

OS/device including version:

Android

Issue description:

I am using logcat | grep godot to checking the output.
+++
If using iap.purchase("pid1") and return godot : purchase_success : pid1.
But when I exit game then comeback, it's not return has_purchased : pid1 as I expect.
+++
If I set iap.set_auto_consume(false) at the beginning of the game, my purchased item return has_purchased : pid1 after I exit the game.
So if my game has both Consumables and Non-Consumables, how can I save my items purchased.
+++
I try to test iap.consume("pid1") (replace my source code iap.purchase("pid1")), but it's not return anything.
Steps to reproduce:
1/ Set up IAP and set purchase button:
a.
iap.sku_details_query(["pid1"])
iap.connect("has_purchased",self,"iap_has_purchased")
iap.request_purchased()
#iap.set_auto_consume(false)
....
func iap_has_purchased(item_name):
print("iap_has_purchased :: " + str(item_name))
b.
func _on_NoAds_pressed() -> void:
iap.purchase("pid1")
#iap.consume("pid1")
iap.connect("purchase_success",self,"iap_purchase_success")
iap.connect("consume_success",self,"on_consume_success")

2/ Remove comment iap.set_auto_consume(false)

3/ Comment #iap.set_auto_consume(false) and #iap.purchase("pid1")
Remove comment iap.consume("pid1")
=> not return anything.
Minimal reproduction project:

@kubecz3k
Copy link
Contributor

kubecz3k commented Feb 9, 2019

Is this problem new for 3.1?
I haven't used inapp in a while but consume() method is not meant to return anything as far as I remember. You should implement consume_sucess signal. The function linked to this signal is a good place to provide the item to the user. Also as far as I know you can't just consume item just after sending a request to purchase it - because of how network communication works you first need to wait for the purchase_success signal call (before this call client can't know if the item has been purchased successfully)

IAP.connect("consume_success",self,"on_consume_success")
IAP.consume("pid")

func on_consume_success(item):
    PlayerInventory.add(item)
    print(item + " consumed")

https://docs.godotengine.org/en/3.0/tutorials/platform/android_in_app_purchases.html

@homarox
Copy link
Author

homarox commented Feb 11, 2019

Is this problem new for 3.1?
I haven't used inapp in a while but consume() method is not meant to return anything as far as I remember. You should implement consume_sucess signal. The function linked to this signal is a good place to provide the item to the user. Also as far as I know you can't just consume item just after sending a request to purchase it - because of how network communication works you first need to wait for the purchase_success signal call (before this call client can't know if the item has been purchased successfully)

IAP.connect("consume_success",self,"on_consume_success")
IAP.consume("pid")

func on_consume_success(item):
    PlayerInventory.add(item)
    print(item + " consumed")

https://docs.godotengine.org/en/3.0/tutorials/platform/android_in_app_purchases.html

I have not test on other version. The consume() function does not return anything on play.google.com > Order management. With purchase("pid1"), Order management changed status to Charged but when I check on logcat, it's still not return has_purchased : pid1

@giangm9
Copy link

giangm9 commented Dec 17, 2019

did you solved i yet ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants