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

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By GForce Productions

I am having an issue with implementing the new iOS plugin for in-app purchasing.
Previously in Godot 3.2.3 everything worked perfectly.
Now with the plug-in, if I call purchase, it returns an error, result code 31.
Anyone have experience with this?

Steps to reproduce:

  • Download the release plugins_3.3.zip
  • Copy the inappstore folder from the zip
  • Paste it inside Project_folder/ios/plugins
  • Export the project with the In App Store plugin ticked
  • On an xcode simulator or a real iphone, press a button that calls the purchase() method
  • It will return with an error: 31
:bust_in_silhouette: Reply From: Richard van der Dys

I am getting the exact same error in the same scenario. Were you ever able to solve this issue?

Hi, yes I was able to solve it. I don’t know if you have the same cause, but let me describe my situation in an answer

GForce Productions | 2021-08-29 17:50

:bust_in_silhouette: Reply From: GForce Productions

In my case, the solution was to call

request_product_info()

In Godot 3.2.3 this was not needed, but that was actually not intended.
So now in Godot 3.3.2 they fixed it, and it is required to call the method with your product id’s before you can make a purchase.

Also beware that previously you could directly test it in XCode, but now you will still get the error, you have to use a physical iphone.
(Or maybe set up something with sandbox testing or whatever, I don’t have experience with that)

See also:

Hello,

Can you please explain how you configured XCode to get the InAppStore singleton? I created a .storekit file with one product, accepted all the conditions in Apple Developer Center and added billing details, and I added the “InApp Purchase” plugin in XCode.

However, when I run on a physical phone, Engine.has_singleton(“InAppStore”) is always false…

This is an archived issue so the original author won’t be notified as it’s not connected to a current account