This API is used by the Huawei server to notify the developer server when a user claims or deletes a pass that has been created on the Huawei server and linked to the user's HUAWEI ID.
Protocol |
HTTPS POST |
|---|---|
Direction |
Huawei server -> Developer server |
URL |
Callback address provided by the developer in AppGallery Connect. |
Data Format |
Request: Content-Type: application/json Response: Content-Type: application/json |
Updates in V2:
1. Added the Version parameter whose value is V2 in the request header.
2. Changed the value of HMSSignType in the request header to SHA256WithRSA/PSS.
3. Changed the value of HMSSign to the signature generated using the SHA256WithRSA/PSS algorithm. For details, please refer to Signature.
4. Added the passTypeIdentifier and sceneType parameters to the request body.
5. Added the values RECEIVE_CARD and TASK_RESULT_NOTIFY for the eventType parameter.
The parameters in V2 are as follows:
Request Header
Parameter |
Mandatory/Optional |
Type |
Description |
|---|---|---|---|
HMSSignType |
Mandatory |
String |
Signing method. The value is always SHA256WithRSA/PSS. |
HMSSign |
Mandatory |
String |
Signature value. |
Version |
Mandatory |
String |
Callback API version. The value is always V2. |
Request Body
Parameter |
Mandatory/Optional |
Type |
Description |
|---|---|---|---|
eventId |
Mandatory |
String(32) |
Event ID. This parameter can be used to deduplicate callback notifications sent from the Huawei server. |
passTypeIdentifier |
Mandatory |
String(64) |
Service ID of a pass. |
modelId |
Mandatory |
String(32) |
Unique identifier of a pass model. It must be unique across all models sharing the same appId. The value contains only letters, digits, dots (.), hyphens (-), and underscores (_). |
instanceId |
Mandatory |
String(32) |
Unique identifier of an instance. It must be unique across all instances sharing the same appId. The value contains only letters, digits, dots (.), hyphens (-), and underscores (_). |
eventTime |
Mandatory |
String(32) |
Event occurrence time, which is UTC time in format of yyyy-MM-dd'T'HH:mm:ss:SSS'Z'. |
eventType |
Mandatory |
String(32) |
Event type. RECEIVE_CARD: A user claims a pass in HUAWEI Wallet. DELETE_CARD: A user deletes a pass from HUAWEI Wallet. TASK_RESULT_NOTIFY: Notify your server of a scheduled task executed by the Huawei server. |
sceneType |
Optional |
String(64) |
Scene type. MODEL_ASYNC_UPDATE_SUCCESS: After a model is updated, passes that use this model are asynchronously updated. |
POST /walletkit/callback/notify HTTP/1.1
Content-Type: application/json;charset=utf-8
HMSSignType: SHA256WithRSA/PSS
HMSSign: ***
Version: V2
Accept: application/json;charset=utf-8
Host: partmer.host.com
{
"eventId": "0a1f133471c4102c8171f845919906f3",
"passTypeIdentifier": "hwpass.com.partner.examplepasstype",
"modelId": "loyaltyModelTest",
"instanceId": "40001",
"eventTime": "2020-04-27T07:40:24.259Z",
"eventType": "RECEIVE_CARD"
}
The parameters in V1 are as follows:
Request Header
Parameter |
Mandatory/Optional |
Type |
Description |
|---|---|---|---|
HMSSignType |
Mandatory |
String |
Signing method. The value is always SHA256WithRSA. |
HMSSign |
Mandatory |
String |
Signature value. |
Request Body
Parameter |
Mandatory/Optional |
Type |
Description |
|---|---|---|---|
eventId |
Mandatory |
String(32) |
Event ID. This parameter can be used to deduplicate callback notifications sent from the Huawei server. |
modelId |
Mandatory |
String(32) |
Unique identifier of a pass model. It must be unique across all models sharing the same appId. The value contains only letters, digits, dots (.), hyphens (-), and underscores (_). |
instanceId |
Mandatory |
String(32) |
Unique identifier of an instance. It must be unique across all instances sharing the same appId. The value contains only letters, digits, dots (.), hyphens (-), and underscores (_). |
eventTime |
Mandatory |
String(32) |
Event time, which is a UTC time in format of yyyy-MM-dd'T'HH:mm:ss:SSS'Z'. |
eventType |
Mandatory |
String(32) |
Event type. RECEIVE_CARD: A user claims a pass in HUAWEI Wallet. DELETE_CARD: A user deletes a pass from HUAWEI Wallet. EXPIRE_CLEAR: Model or instance data expires and is deleted. TASK_RESULT_NOTIFY: Notify your server of a scheduled task executed by the Huawei server. |
POST /walletkit/callback HTTP/1.1
Content-Type: application/json;charset=utf-8
HMSSignType: SHA256WithRSA
HMSSign: ***
Accept: application/json;charset=utf-8
Host: partmer.host.com
{
"eventId": "0a1f133471c4102c8171f845919906f3",
"modelId": "loyaltyModelTest",
"instanceId": "40001",
"eventTime": "2020-04-27T07:40:24.259Z",
"eventType": "RECEIVE_CARD"
}
Parameter |
Type |
Description |
|---|---|---|
returnCode |
String |
Result code. For details, please refer to Common Result Codes in the Common Definition section. |
returnDesc |
String |
Result description. |
HTTP/1.1 200 OK
Content-Type: application/json
{
"returnCode": "0",
"returnDesc": "success",
}
private BaseResponse callbackSp(CallbackRequest requestBody) {
String priKey = "xxx";
Map<String, String> header = new HashMap<>(8);
header.put("Content-Type", "application/json;charset=UTF-8");
header.put("Accept", "application/json;charset=UTF-8");
header.put("HMSSignType", "SHA256WithRSA");
String hmsSign = RSAUtils.signByRSA(ToStringUtil.signString(requestBody), priKey);
header.put("HMSSign", hmsSign);
HttpEntity<CallbackRequest> httpEntity = new HttpEntity(requestBody, header);
return restful.postForObject(whiteCardCallbackTask.getCallbackUrl(), httpEntity, BaseResponse.class);
}