Kostya Vasilyev
Kostya Vasilyev

Reputation: 864

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

I'm in the process of implementing InApp purchases (subscriptions) with Huawei In App SDK.

Everything's good except token verification against Huawei's servers.

My code is similar to that here: https://developer.huawei.com/consumer/en/doc/development/HMS-References/iap-api-order-service-purchase-token-verification-v4

I'm using an access token which is obtained like so: https://developer.huawei.com/consumer/en/doc/development/HMS-Guides/38054564 - the same code to obtain access tokens already works with Huawei Push SDK by the way.

For verification, my code sends requests to https://orders-dre.iap.hicloud.com/applications/purchases/tokens/verify with this data:

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

The response comes back as:

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

The FAQ here https://developer.huawei.com/consumer/en/doc/development/HMS-Guides/iap-FAQ recommends:

"You are advised to check whether the app ID used for obtaining AccessToken is the same as the app ID associated with purchaseToken in the request".

Now I only have one project / one set of Client ID / Client Secret, so it matches the app ID, by definition.

What could be wrong?

PS - this is happening with a test subscription, i.e. purchased by a user account that's set up as a test account.

Upvotes: 1

Views: 11281

Answers (1)

zhangxaochen
zhangxaochen

Reputation: 33997

  1. According to the code part you provided, you are using Purchase Token Verification for the Order Service, and you should use API for Verifying the Purchase Token for the Subscription Service.

Purchase Token Verification for the Order Service applies only to non-subscription purchases. It is used to verify the purchase token in the payment result sent from the Huawei IAP server to ensure payment accuracy.

API for Verifying the Purchase Token for the Subscription Service applies only to subscriptions. It is used to check whether a product has been successfully purchased and is within the validity period.

  1. Verifying the Purchase Token for the Subscription Service:

Parameter: subscriptionId;purchaseToken

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

rootURL:

China: https://subscr-drcn.iap.hicloud.com

Germany: https://subscr-dre.iap.hicloud.com

Singapore: https://subscr-dra.iap.hicloud.com

Russia: https://subscr-drru.iap.hicloud.com

AppTouch site of Germany: https://subscr-at-dre.iap.dbankcloud.com

Upvotes: 2

Related Questions