iaphub / react-native-iaphub

The easiest way to implement IAP (In-app purchase) in your React Native app.
https://www.iaphub.com/
MIT License
317 stars 21 forks source link

Issues with anonymous purchases #130

Closed sstimac closed 1 year ago

sstimac commented 1 year ago

Hello :)

We're currently trying to update the lib to the latest version, and we'd like to use anonymous purchases as a part of our in app flow. However, we're running into some issues when trying to purchase a subscription as an anonymous user.

I am using the allowAnonymousPurchase option as suggested, but it doesn't work as intended. To start with, there is a bug in android implementation, where there is probably some copy pasta leftover, incorrectly referencing the allowAnonymousPurchase property.

Once i've resolved that locally, i am presented with server error when trying to purchase the product as an anonymous user. Based on the error, it seems that the native SDKs are trying to fetch anonymous user data, which is logically missing ( as there is no actual user ). On the first glance, it would seem that we're trying to run the same validation flow on the side of native SDKs, that we're doing when the user is actually present.

{"code": "server_error", "message": "The remote server returned an error, code: user_not_found", "params": {"route": "/app/5fb397d56533140e8dfb3226/user/a:dff569fe-2bb4-42e6-8487-267babb56141", "statusCode": "404", "type": "GET"}, "subcode": "user_not_found"}

Appreciate any input you can provide on this. Thanks in advance !!

"react-native": "0.68.2", "react-native-iaphub": "8.2.0",

iaphub commented 1 year ago

Hey @sstimac,

Thanks for noticing this bug with the allowAnonymousPurchase option. We've just deployed a fix in the latest release (8.2.1). Regarding your second issue, I was able to find the cause, it is because you're using the wrong apiKey, you should use the Client Api Key (Not the Server Api Key that should only be used for API calls). After using the right one it should work 🙂

sstimac commented 1 year ago

Dang ! Thanks for the ultra quick response <3 <3