使用react-native-iap 12.10.4实现Google Play订阅时遇E_DEVELOPER_ERROR
React Native IAP 12.10.4 Google Play订阅E_DEVELOPER_ERROR问题排查与解决
问题描述
使用react-native-iap 12.10.4对接Google Play订阅功能时,触发E_DEVELOPER_ERROR,错误提示为:Google is indicating that we have some issue connecting to payment。调用订阅的代码如下:
async subscribe(sku: string, offerToken: string) { let res = null; const init = await initConnection(); console.log(init); try { res = await requestSubscription({ purchaseTokenAndroid: sku, subscriptionOffers: [{sku, offerToken}], }); } catch (err) { console.warn(err.code, err.message); } return res; }
已确认sku与offerToken参数正确,且谷歌账号已加入内部测试人员及许可测试列表,使用内部测试版本时问题仍存在。
排查与解决步骤
修正requestSubscription参数错误
代码中错误地将sku赋值给了purchaseTokenAndroid字段,该字段仅用于恢复已有订阅时传入购买凭证,发起新订阅时不需要传递此参数。正确的调用方式应为:res = await requestSubscription({ subscriptionOffers: [{sku, offerToken}], });参数混淆是触发该错误的高频原因,优先修正此问题。
核对Google Play Console配置
- 确认订阅商品已发布至内部测试轨道,测试包的包名、签名证书需与Console中配置的完全匹配
- 检查许可测试列表中的账号是否准确,测试设备必须使用该账号登录Google Play
- 验证
offerToken对应的优惠方案处于激活状态,未过期或被停用
完善初始化校验
确保IAP连接初始化成功后再发起订阅请求,可增加状态判断:const init = await initConnection(); if (init !== true) { console.error('IAP初始化失败'); return null; }检查设备测试环境
- 测试设备仅保留测试用的Google账号,移除其他无关账号
- 确保设备的Google Play服务为最新版本
- 优先使用真实设备测试,避免依赖模拟器
内容的提问来源于stack exchange,提问作者Nmeer Naji
相关产品推荐
相关产品推荐

