godotengine / godot-ios-plugins

MIT License
126 stars 48 forks source link

iOS In-App Purchasing: purchase() returns error 31 #22

Closed GForceProductions closed 2 years ago

GForceProductions commented 2 years ago

Summary: In Godot 3.2.3 with built-in iOS IAP singleton everything worked. In Godot 3.3.2 using the plug-in, calling purchase() returns error with code 31. Using the exact same project.

Steps to reproduce:

naithar commented 2 years ago

31 error is ERR_INVALID_PARAMETER. This means that purchase method hadn't found a purchase with ID you have used. Code responsible for it: https://github.com/godotengine/godot-ios-plugins/blob/master/plugins/inappstore/in_app_store.mm#L104-L130

Godot 3.2.3 and previous InAppStore modules was using deprecated api: https://github.com/godotengine/godot/blob/3.2/platform/iphone/in_app_store.mm#L265-L282 This was fixed in plugin. Right now you are required to make a request_product_info with SKU values before making any purchase. This method should have been called in previous versions too, but it wasn't required due to the way module worked and because of deprecated api.

Plugin's Readme file have an example of how it should be used: https://github.com/godotengine/godot-ios-plugins/blob/master/plugins/inappstore/README.md

GForceProductions commented 2 years ago

Hi Naithar, thanks for the tip. Now I added the request_product_info part. However, in XCode it says the following:

error

From the first three lines, it seems gold and silver have been added. (gold and silver are the product_id's registered in appstoreconnect, which I also used before for purchasing)

The lines below those are what I print myself in Godot. Inside check_events(), I do receive an event of type "product_info", but the result is "error". Any idea what could be the problem?

EDIT: so for completeness, calling purchase still results in error 31

naithar commented 2 years ago

request_product_info produces product_info event and error value should contain localized description taken from native error: https://github.com/godotengine/godot-ios-plugins/blob/master/plugins/inappstore/in_app_store.mm#L137-L146. Are you testing on simulator? Are you using sandbox account or StoreKit configuration file to test an app? Does this issue happen on application uploaded to TestFlight?

EDIT: so for completeness, calling purchase still results in error 31

request_product_info have failed, so purchase will still be unable to find a product by it's ID.

GForceProductions commented 2 years ago

It looks like it does work in the real app through Testflight. Previously, it also worked directly in XCode, so this apparently also changed with the fix. Thank you for all the help!