In App Purchase examples

I have implemented the IAP module and connectAysnc promise returns a path to a bundle error, no details just a path to cached bundle. I have no idea how to even inspect that bundle from an APK to see what function even failed, I wish someone at expo would have taken the time to publish a functional example app, or tests, because at this point I don’t believe it even works. If anyone reading this has an example somewhere please post.

In the meantime I will be implementing GitHub - dooboolab/react-native-iap: react-native native module for In App Purchase. because they have provided example code

2 Likes

Hey @binah can you tell me more about the error you’re getting? Opening a GitHub issue with more detail and the output of expo diagnostics might help figure out what’s causing it.

Have you followed all of the prerequisite setup steps found in the docs? Expo IAP won’t work unless you configure your app and purchasable items in the App Store Connect/Google Play Console.

There also used to be an example app for IAP (PR introducing it here: Add expo-payments app to test in-app purchases by sergeichestakov · Pull Request #4615 · expo/expo · GitHub), but it must have gotten removed recently. Looking through that PR might help you get a better understanding of how to use the API though.

Actually looks like the example app has been moved. You can find it here.

3 Likes

I’m connected to app store and even retrieving my products list, however, when I finally run purchaseItemAsync I keep instantly getting this error instantly out of the listener:

“WARN: Something went wrong with the purchase. Received response code 2 and errorCode 0”

Any insight? Thank you!

Hey @ddb1,

Error code 0 indicates something went wrong internally. See the error code list in the docs for reference. In this case, you’re seeing IAPErrorCode.UNKNOWN.

Are you running this in a simulator by chance? Make sure you’re using a physical device as IAP won’t work in a simulator and will likely throw this exact error.

Otherwise, if you’re seeing this error on iOS it may be an issue with your iTunes or test user account. See the Apple docs for reference.

Hope that helps.

1 Like

Thank you so much! I have it working out - I was indeed on a simulator :man_facepalming:

am also facing some issues with expoInAppPurchase.in my case await connectAsync(); returns undefined in ios.am using real device(ios 14.4).what should i do?