Skip to content

Commit d815465

Browse files
authored
Merge pull request #21 from avnerh1/patch-4
Update README.md
2 parents d02a042 + dd76ca3 commit d815465

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

plugins/inappstore/README.md

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,35 @@ var _appstore = null
1010
func check_events():
1111
while _appstore.get_pending_event_count() > 0:
1212
var event = inappstore.pop_pending_event()
13-
match event.type:
14-
'product_info':
15-
...
16-
'purchase':
17-
...
18-
'restore':
19-
...
20-
21-
func _on_Button_button_down():
22-
var result = _appstore.restore_purchases()
13+
if event.result=="ok": # other possible values are "progress", "error", "unhandled"
14+
15+
# print(event.product_id)
16+
match event.type:
17+
'product_info':
18+
# fields: titles, descriptions, prices, ids, localized_prices, currency_codes, invalid_ids
19+
...
20+
'purchase':
21+
# fields: product_id, transaction_id, receipt
22+
...
23+
'restore':
24+
# fields: product_id, transaction_id, receipt
25+
...
26+
27+
func _on_Purchase_button_down():
28+
var result = _appstore.restore_purchases()
2329
...
2430
2531
var result = _appstore.purchase({'product_id': "product_1"})
2632
...
27-
...
2833
34+
func _on_Restore_button_down(): # such button is required by Apple for non-consumable products
35+
var result = _appstore.restore_purchases()
36+
...
37+
2938
func _ready():
30-
if Engine.has_singleton("InAppStore"):
31-
_appstore = Engine.get_singleton('InAppStore')
32-
var result = _appstore.request_product_info( { "product_ids": ["product_1", "product_2"] } )
39+
if Engine.has_singleton("InAppStore"):
40+
_appstore = Engine.get_singleton('InAppStore')
41+
var result = _appstore.request_product_info( { "product_ids": ["product_1", "product_2"] } )
3342
if result == OK:
3443
print("Successfully started product info request")
3544
_appstore.set_auto_finish_transaction(true)
@@ -41,8 +50,8 @@ func _ready():
4150
timer.start()
4251
else:
4352
print("failed requesting product info")
44-
else:
45-
print("no app store plugin")
53+
else:
54+
print("no app store plugin")
4655
```
4756

4857
## Methods

0 commit comments

Comments
 (0)