对接华为HMS Core SDK 应用内支付(In-App Purchases,IAP)(4.0.4.300及更高版本)后,有时候会遇到华为IAP支付无法拉起的情况。
问题现象
发起支付后界面一闪而过某个界面,但是没有拉起支付收银台界面。
定位手段
-
查看HMS SDK返回的错误码,根据官网错误码描述自检。
-
配套抓取客户端全量日志,日志搜索过滤hms_pay关键词,查看异常报错信息。
常见易错点
普通商品(消耗/非消耗商品)没有激活
华为AGC后台创建商品后,默认是失效状态的,没有激活的商品是无法拉起支付的。
-
错误码:HMS Core SDK返回给客户端的错误码:60003,商品信息错误。
-
错误信息:搜索关键词hms_pay后,获得的日志信息如下
2020-09-30 14:48:52.850 21970-17650/? E/hms_pay: hms_pay [Network-Request]parse createOrder, responseCode = 6, subErrCode = 214, responseMessage = Product info cannot be found.
2020-09-30 14:48:52.850 21970-17650/? I/hms_pay: hms_pay baseBiz result:: get result Success
2020-09-30 14:48:52.850 21970-17650/? I/hms_pay: hms_pay createOrder onResponse responseCode:6,responseMessage:Product info cannot be found.
2020-09-30 14:48:52.851 21970-17650/? E/hms_pay: hms_pay createOrder fail, returnCode: 6
订阅型商品没有激活
-
错误码:HMS Core SDK返回给客户端的错误码:-1,通用失败错误码。
-
错误信息:搜索关键词hms_pay后,获取的日志信息如下
2020-09-30 15:20:38.940 21970-22803/? E/hms_pay: hms_pay [Network-Request]parse createOrder, responseCode = 6, subErrCode = 221, responseMessage = product status must 0(online)
2020-09-30 15:20:38.940 21970-22803/? I/hms_pay: hms_pay baseBiz result:: get result Success
2020-09-30 15:20:38.943 21970-22803/? I/hms_pay: hms_pay getCurrentTime error, content is inValid
2020-09-30 15:20:38.945 21970-22803/? I/hms_pay: hms_pay no InAppPurchaseData
2020-09-30 15:20:38.946 21970-22803/? E/hms_pay: hms_pay SubscribeRequestInterceptor createOrder, errorCode: 6
商品ID填写错误
createPurchaseIntent支付接口中需要填写待支付商品ID,如果该商品ID没有在AGC后台配置,自然是无法拉起支付的。
-
错误码:HMS Core SDK返回给客户端的错误码:60003,商品信息错误。
-
错误信息:搜索关键词hms_pay后,获取的日志信息如下
2020-09-30 15:07:59.438 21970-19979/? E/hms_pay: hms_pay [Network-Request]parse createOrder, responseCode = 6, subErrCode = 214, responseMessage = Product info cannot be found.
2020-09-30 15:07:59.439 21970-19979/? I/hms_pay: hms_pay baseBiz result:: get result Success
2020-09-30 15:07:59.447 21970-19979/? I/hms_pay: hms_pay createOrder onResponse responseCode:6,responseMessage:Product info cannot be found.
2020-09-30 15:07:59.448 21970-19979/? E/hms_pay: hms_pay createOrder fail, returnCode: 6
普通商品的商品类型字段(setPriceType)错误
华为AGC后台支持创建:消耗型商品、非消耗型商品和订阅型商品三种类型。createPurchaseIntent支付接口请求中除了填写商品ID,还需要填写该商品的类型setPriceType字段,如果该字段与后台配置的不一致,也无法拉起支付。
-
错误码:HMS Core SDK返回客户端的错误码:60006,查询商品类型与PMS定义不符。
-
错误信息:搜索关键词hms_pay后,获取的日志信息如下
2020-09-30 15:05:08.560 21970-18765/? E/hms_pay: hms_pay [Network-Request]parse createOrder, responseCode = 6, subErrCode = 216, responseMessage = Product type doesn't match that in pms.
2020-09-30 15:05:08.560 21970-18765/? I/hms_pay: hms_pay baseBiz result:: get result Success
2020-09-30 15:05:08.561 21970-18765/? I/hms_pay: hms_pay createOrder onResponse responseCode:6,responseMessage:Product type doesn't match that in pms.
2020-09-30 15:05:08.561 21970-18765/? E/hms_pay: hms_pay createOrder fail, returnCode: 6
订阅型商品类型字段(setPriceType)错误
-
错误码:HMS Core SDK返回给客户端的错误码:-1,通用失败错误码。
-
错误信息:搜索关键词hms_pay后,获取的日志信息如下
2020-09-30 15:24:48.019 21970-23368/? E/hms_pay: hms_pay [Network-Request]parse createOrder, responseCode = 6, subErrCode = , responseMessage = App doesn't exist from pms.
2020-09-30 15:24:48.019 21970-23368/? I/hms_pay: hms_pay baseBiz result:: get result Success
2020-09-30 15:24:48.019 21970-23368/? I/hms_pay: hms_pay createOrder onResponse responseCode:6,responseMessage:App doesn't exist from pms.
2020-09-30 15:24:48.020 21970-23368/? E/hms_pay: hms_pay createOrder fail, returnCode: 6
欲了解更多详情,请参见: