华为应用内购买令牌验证 - 意外错误 "rights invalid"

Huawei In App purchase token verification - unexpected error "rights invalid"

我正在使用华为In App SDK实现InApp购买(订阅)。

一切都很好,除了针对华为服务器的令牌验证。

我的代码与此处的代码类似:https://developer.huawei.com/consumer/en/doc/development/HMS-References/iap-api-order-service-purchase-token-verification-v4

我正在使用这样获得的访问令牌:https://developer.huawei.com/consumer/en/doc/development/HMS-Guides/38054564 - 顺便说一下,获取访问令牌的相同代码已经适用于华为 Push SDK。

为了验证,我的代码使用以下数据向 https://orders-dre.iap.hicloud.com/applications/purchases/tokens/verify 发送请求:

{
"purchaseToken":"00000175799be0e659fc74cb06...5.8.5650",
"productId":"annual"
}

响应返回为:

{"responseCode":"6","responseMessage":"rights invalid"}

此处的常见问题解答 https://developer.huawei.com/consumer/en/doc/development/HMS-Guides/iap-FAQ 建议:

“建议您检查获取AccessToken时使用的app ID是否与请求中关联purchaseToken的app ID相同”。

现在我只有一个项目/一组Client ID / Client Secret,所以根据定义它匹配应用程序ID。

有什么问题吗?

PS - 这发生在测试订阅中,即由设置为测试帐户的用户帐户购买。

  1. 根据您提供的代码部分,您正在使用Purchase Token Verification for the Order Service, and you should use API for Verifying the Purchase Token for the Subscription Service

订单服务的购买令牌验证仅适用于 non-subscription 购买。用于验证华为支付服务器发送的支付结果中的购买令牌,保证支付的准确性。

API 用于验证订阅服务的购买令牌仅适用于订阅。用于查询商品是否购买成功,是否在有效期内。

  1. 验证订阅服务的购买令牌:

参数:subscriptionId;purchaseToken

RequestUrl: {rootUrl}/sub/applications/v2/purchases/get

rootURL:

中国:https://subscr-drcn.iap.hicloud.com

德国:https://subscr-dre.iap.hicloud.com

新加坡:https://subscr-dra.iap.hicloud.com

俄罗斯:https://subscr-drru.iap.hicloud.com

德国的 AppTouch 站点:https://subscr-at-dre.iap.dbankcloud.com