Some overseas developers asked us a question: I integrated the Huawei in-app payment SDK (test purchase of subscription products) in the application. According to the documentation, when the server went to the server to request verification and purchase the Token interface, it returned {"responseCode":"6 ","responseMessage":"rights invalid"}. This error is mentioned in the document FAQ: It is recommended to first check whether the appid used to obtain the AccessToken and the appid associated with the actual request parameter purchaseToken are the same. I only have one set of projects, one set of client ID and client secret, so the appid should be the same. I don't know where is the problem? How should I configure.

refer to the link for details of the problem: 1612dcc716b4af https://stackoverflow.com/questions/64613379/huawei-in-app-purchase-token-verification-unexpected-error-rights-invalid

solution

  1. According to the code provided by the developer, it shows that his interface is wrong. He used the Order service to purchase the Token verification Subscription service should be used to verify the purchase of the Token .

Order service purchase token verification is only for non-subscription products, including consumable products and non-consumable products. The application can call this interface to verify the purchase token in the payment result to the Huawei payment server to confirm the accuracy of the payment result.

Subscription service verification purchase Token is only for subscription products. This interface is used to verify the purchased goods and determine whether the goods have been successfully purchased and whether they are within the validity period.

An example of a Token purchase request verified by the Order service is as follows:

POST /applications/purchases/tokens/verify
Content-Type: application/json; charset=UTF-8
Authorization: Basic QVQ6Q1YzQ1NPbVlBaGwrZUtRWExtMTBVV2pyWXZHTVF4MmYvcVMya1B0ZElLY3UwaFJrdFNTMmxwdk1FQkIyYldXWGt0REVaR3I4UjFUTTRLMVlmNXdwWU80RG04THdXQWxjaFhEYjBMUjBNTUJtWnFYcGFtazc3THN3UnFJbkhHK28xekdqRzNSMg==
Accept: application/json
Content-Length: 143
{
  "purchaseToken": "00000173741056a37eef310dff9c6a86fec57efafe318ae478e52d9c4261994d64c8f6fc8ea1abbdx5347.5.3089",
  "productId": "prd1"
}

An example of a subscription service verification purchase token request is as follows:

POST /sub/applications/v2/purchases/get
Content-Type: application/json; charset=UTF-8
Authorization: Basic QVQ6Q1YzQ1NPbVlBaGwrZUtRWExtMTBVV2pyWXZHTVF4MmYvcVMya1B0ZElLY3UwaFJrdFNTMmxwdk1FQkIyYldXWGt0REVaR3I4UjFUTTRLMVlmNXdwWU80RG04THdXQWxjaFhEYjBMUjBNTUJtWnFYcGFtazc3THN3UnFJbkhHK28xekdqRzNSMg==
Accept: application/json
Content-Length: 171
{
  "purchaseToken": "00000173741056a37eef310dff9c6a86fec57efafe318ae478e52d9c4261994d64c8f6fc8ea1abbdx5347.5.3089",
  "subscriptionId": "1581789719266.D40972AC.3089"
}
  1. The verification of subscription products is as follows:

parameter : subscriptionId; purchaseToken

Interface Url: {rootUrl}/sub/applications/v2/purchases/get

rootURL

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

German site: https://subscr-dre.iap.hicloud.com

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

Russian site: https://subscr-drru.iap.hicloud.com

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

AppTouch Singapore site: https://subscr-at-dra.iap.dbankcloud.com

The above introduces the solution of returning "rights invalid" when verifying the purchase Token interface after the App integrates the in-app payment SDK. Then someone may ask, what exactly is Huawei's in-app payment? What are the functions?

About HMS IAP Kit

Huawei In-App Purchases (IAP) provides apps with a convenient in-app payment experience and simple access process. App can realize in-app payment by integrating the IAP SDK and then calling the IAP SDK interface to start the IAP cashier. Aggregate multiple payment channels, support global payments, and provide apps with a convenient in-app payment experience. Through in-app payment services, users can purchase various types of goods or services in the app, including ordinary virtual goods and subscription goods and services. Commercial realization of developers.

For quick experience of Huawei in-app payment service tutorials and development examples, please refer to Quick Start Guide .

Stack Overflow and HMS

As the world's largest programming Q&A community, every day on Stack Overflow, developers from different countries around the world ask various programming questions on it. We also opened a column on Stack Overflow: Stack Overflow Welcome everyone to ask questions about various programming problems encountered in the process of integrating HMS Core.

For more details, please refer to:

Huawei In-App Payment Service Official Website

app payment development guide

sample code

Huawei Mobile Services open source warehouse address: GitHub , Gitee

and learn about the latest technical information of HMS Core for the first time~


HarmonyOS_SDK
596 声望11.7k 粉丝

HarmonyOS SDK通过将HarmonyOS系统级能力对外开放,支撑开发者高效打造更纯净、更智能、更精致、更易用的鸿蒙原生应用,和开发者共同成长。