From dd76ca37a29c8f109810f0874fe42d23039a3b24 Mon Sep 17 00:00:00 2001 From: Avner <30798249+avnerh1@users.noreply.github.com> Date: Sun, 18 Jul 2021 22:26:23 +0300 Subject: [PATCH] Update README.md --- plugins/inappstore/README.md | 41 ++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/plugins/inappstore/README.md b/plugins/inappstore/README.md index a2cad0d..022893d 100644 --- a/plugins/inappstore/README.md +++ b/plugins/inappstore/README.md @@ -10,26 +10,35 @@ var _appstore = null func check_events(): while _appstore.get_pending_event_count() > 0: var event = inappstore.pop_pending_event() - match event.type: - 'product_info': - ... - 'purchase': - ... - 'restore': - ... - -func _on_Button_button_down(): - var result = _appstore.restore_purchases() + if event.result=="ok": # other possible values are "progress", "error", "unhandled" + + # print(event.product_id) + match event.type: + 'product_info': + # fields: titles, descriptions, prices, ids, localized_prices, currency_codes, invalid_ids + ... + 'purchase': + # fields: product_id, transaction_id, receipt + ... + 'restore': + # fields: product_id, transaction_id, receipt + ... + +func _on_Purchase_button_down(): + var result = _appstore.restore_purchases() ... var result = _appstore.purchase({'product_id': "product_1"}) ... -... +func _on_Restore_button_down(): # such button is required by Apple for non-consumable products + var result = _appstore.restore_purchases() + ... + func _ready(): - if Engine.has_singleton("InAppStore"): - _appstore = Engine.get_singleton('InAppStore') - var result = _appstore.request_product_info( { "product_ids": ["product_1", "product_2"] } ) + if Engine.has_singleton("InAppStore"): + _appstore = Engine.get_singleton('InAppStore') + var result = _appstore.request_product_info( { "product_ids": ["product_1", "product_2"] } ) if result == OK: print("Successfully started product info request") _appstore.set_auto_finish_transaction(true) @@ -41,8 +50,8 @@ func _ready(): timer.start() else: print("failed requesting product info") - else: - print("no app store plugin") + else: + print("no app store plugin") ``` ## Methods