使用Expo react-native expo-iap处理内购时返回错误代码8的问题求助
Expo react-native expo-iap处理内购时返回错误代码8的问题求助
我最近在Expo React Native项目里用expo-iap的useIAP hook做内购功能,结果处理购买的时候一直踩坑,具体报错信息如下:
ERROR Error processing purchase: [Error: An unknown or unexpected error has occurred. Please try again later.] ERROR Error processing purchase: [Error: Purchase failed with code: 8]
购买对象能正常打印出来,但调用finishTransaction的时候就会反复抛出这个错误,实在搞不定了来求助!
我的配置情况
- 安卓应用,基于Google Play Billing实现内购
- 内购商品ID为
iap.diamond.600,已经在Play控制台完成配置 - 测试账号已经加入了许可测试者列表
- 使用useIAP hook的
onPurchaseSuccess回调处理购买完成逻辑,代码片段如下:
onPurchaseSuccess: (purchase) => { InteractionManager.runAfterInteractions(async () => { try { await finishTransaction({ purchase, isConsumable: true }); console.log("purchase", purchase); // Alert.alert("Purchase successful", JSON.stringify(purchase)); } catch (error: any) { console.error("Error processing purchase:", error); if (error.userInfo) { // Sometimes more info is here console.error("Error userInfo:", error.userInfo); } } }); }, onPurchaseError: (error) => { InteractionManager.runAfterInteractions(() => { Alert.alert("Purchase Error", getErrorMessage(error)); }); },
我已经尝试过的解决方法
- 确认商品在Play控制台处于激活状态
- 把测试用户正确添加到了许可测试者列表
- 检查过返回的购买对象里
purchaseToken是存在的 - 商品创建完成后已经等待了24小时以上
有没有大佬遇到过类似的问题?求指点迷津,万分感谢!
内容来源于stack exchange
相关产品推荐
相关产品推荐

