+1 vote

Hi I am trying to figure out how to implement in App purchases for iOS. I read the documentation like 100 hundred times, here I just can’t get how I can check if a purchase was made. I can buy an item succesful but when closing the app an open it again I have to re purchase it, the docs on Android specify the way to check if an item was purchased but on IOS no.
I am using this code to pirchase an item:

func on_purchase_pressed():
    var result = InAppStore.purchase( { "product_id": "my_product" } )
    if result == OK:
           var timer = Timer.new()
           timer.one_shot = true
           timer.autostart = true
           timer.wait_time = 1

func check_events():
    while InAppStore.get_pending_event_count() > 0:
        var event = InAppStore.pop_pending_event()
        if event.type == "purchase":
            if event.result == "ok":
                print(“item purchased”)
Godot version 3.2.3 windows stable 64bits
in Engine by (156 points)

1 Answer

0 votes
Best answer

Use https://docs.godotengine.org/en/stable/tutorials/platform/services_for_ios.html#restore-purchases on every app start or user login(depending on app). Don't ever store purchases yourself, request them from store or payment provider.

by (889 points)
selected by

Thanks, I had thought to do that but I find it very wrong to restore purchases all the time, and I was thinking of doing it myself

Also, If you have no internet connection the restore can’t be made

From https://docs.godotengine.org/en/stable/tutorials/platform/services_for_ios.html

At the moment, there are two iOS APIs partially implemented

You can try to implement on device validation yourself.

From https://developer.apple.com/documentation/storekit/in-app_purchase/choosing_a_receipt_validation_technique

Validating locally requires code to read and validate a PKCS #7
signature, and code to parse and validate the signed payload.

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 Frequently asked questions and 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 [email protected] with your username.