1
votes

I was trying for server side Canceled api of IAP but I am not able to cancel the subscription using this api. Everytime I am clicking cancel i am getting this error : responseCode:"6","responseMessage":"900030-authorization format invalid"

and the API which I am using is this: https://subscr-dra.iap.hicloud.com/sub/applications/v2/purchases/stop

Can anybody help me with this I am stuck?

3

3 Answers

0
votes

The Extension of AT File is incorrect.

Authentication information is specified based on the request header. The details are as follows: App-level access token: Authorization: Basic Base64(APPAT:atvalue)

  • Example: The app-level access token is thisIsAppAtValue, then APPAT:atvalue is APPAT:thisIsAppAtValue. Therefore, replace APPAT:atvalue in Base64(APPAT:atvalue) with APPAT:thisIsAppAtValue, and value QVBQQVQ6dGhpc0lzQXBwQXRWYWx1ZQ== is obtained. The value of Authorization in the request header is as follows: Basic QVBQQVQ6dGhpc0lzQXBwQXRWYWx1ZQ==

The sample code is as follows:

  /* Build Authorization in Header
     *
     * @param appAt app AccessToken
     * @return headers
     */
    public static Map<String, String> buildAuthorization(String appAt) {
        String oriString = MessageFormat.format("APPAT:{0}", appAt);
        String authorization =
            MessageFormat.format("Basic {0}", Base64.encodeBase64String(oriString.getBytes(StandardCharsets.UTF_8)));
        Map<String, String> headers = new HashMap<>();
        headers.put("Authorization", authorization);
        headers.put("Content-Type", "application/json; charset=UTF-8");
        return headers;
}

HMS In-App Purchases(IAP) Severdemo on Github.

0
votes

The error code that you received – 900030 means your signature verification data format is invalid. The possible causes are: • The token in the request header is not encrypted in Base64 mode. • The character string APPAT is not appended to the beginning of the access token for authorization. The correct access token is in the format of APPAT:thisIsAppAtVaule.

You can read about this error code here

Please make sure that your request follow the format specified in this document

If you still receive the same error, kindly post your request data format here.

0
votes

Check the format of the token you are putting in header as authorization.

Code:

let oriString = 'APPAT:' + app_level_access_token;

let authorizationToken = new Buffer.from(oriString).toString('base64'); // converting the token into Base64.

Now this authorizationToken, you can use it in the header.