0 votes

I have a game in which a user can buy different amounts of gold as consumable item.

I am confused as of what to do after i initiate var purchase = IAP.purchase['1000_gold]

What I am trying to ask is -

Where does the flow go after .purchase in the previous plug in it was a callback `_on_purchase_success _on_purchase_failed` etc.

I want to set it to consume and add it to a dictionary for gold, I am thinking of doing this in `_on_purchase_aknowledged`

func _on_purchase_acknowledged(purchase_token):

`print("Purchase acknowledged: %s" % purchase_token)`

`var query = payment.queryPurchases("inapp") # Or "subs" for subscriptions`

`if query.status == OK:`

    `for purchase in query.purchases:`

        `if purchase.sku == "1000chips":`

if !purchase.is_acknowledged:

payment.consumePurchase(purchase.purchase_token)

And in purchase_consumed callback

func _on_purchase_consumed(purchase_token):

`print("Purchase consumed successfully: %s" % purchase_token)`

`ChipsManager.chips_info['chips'] += int(1000)`

`ChipsManager.save_data()`

Is this right? Can anyone help?

in Engine by (31 points)

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 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 webmaster@godotengine.org with your username.