目录

Hosting NFC Pass Data

Function

Pushes NFC pass data from your server to the Huawei server for hosting.

Scenario

This API is used to push NFC pass personalized data from your server to the Huawei server for hosting when your server does not support query of personalized data.

The following example describes how this API is called when a hotel developer integrates the loyalty card and NFC capabilities: The hotel server pushes the loyalty card model to the Huawei server. Then a loyalty card instance is generated for a customer through an API of the hotel server and the instance is added to HUAWEI Wallet on the customer's mobile phone. After the customer checks in, the hotel server obtains the NFC data of the customer's room door from the server of the door vendor, and calls this API to push the data to the Huawei server. This API will then return a token. After this, the hotel server calls the API for updating loyalty card instances to add the token to the LinkDevicePass parameter in the customer's loyalty card. When the customer swipes the loyalty card using the NFC capability of the HUAWEI Wallet app, the app sends an NFC operation request to the Huawei server.

Restrictions

You do not need to call this API if you have implemented the APIs described in Implementing NFC Capability APIs on Your Server. To call this API, contact Huawei technical support for development and joint commissioning.

Prototype

Protocol

HTTPS POST

Direction

Developer server -> Huawei server

URL

{url}/hmspass/v1/nfccard/personalizeddata

Set the {url} variable based on the region where the server is located. For details, please refer to Wallet Server Addresses.

Data Format

Request: Content-Type: application/json

Response: Content-Type: application/json

Request Parameters

Request Header

Parameter

Mandatory/Optional

Type

Description

Authorization

Mandatory

String

Authorization code. For details about how to obtain the value, please refer to the Client Credentials mode in OAuth 2.0-based Authentication. In this mode, client_id and client_secret are respectively the App ID and App key of the app that you created in AppGallery Connect. Concatenate the value of access_token to the end of Bearer, with a space in between, to generate the value of Authorization.

Content-Type

Mandatory

String

The value is always application/json;charset=utf-8.

Accept

Mandatory

String

The value is always application/json;charset=utf-8.

Request Body

Parameter

Mandatory/Optional

Type

Description

serviceType

Mandatory

String(32)

Service name, which is provided by Huawei.

transId

Mandatory

String(32)

Transaction ID, which is determined by you. The value must be unique across all transactions with the same serviceType.

personlizedData

Mandatory

String(10240)

NFC pass personalized data.

expireTime

Optional

String(32)

Time when NFC pass data expires. The value is UTC time in yyyy-mm-dd HH:MM:SS format. If this parameter is not set, the default validity period is three months.

appendInfo

Optional

String(2048)

Additional information.

Request Example

POST /hmspass/v1/nfccard/personalizeddata HTTP/1.1
Content-Type: application/json;charset=utf-8
Authorization: Bearer ***
Accept: application/json;charset=utf-8
Host: wallet-passentrust-drcn.cloud.huawei.com.cn
{
  "serviceType": "amber_house",
  "transId": "amberHouse10001",
  "personalizedData": "{\"key1\":\"value1\",\"key2\":\"value2\"}",
  "expireTime": "2021-07-22T09:12:43.083Z"
}

Response Parameters

When the result code is 200:

Parameter

Type

Description

returnCode

String

Return code. The value 0 indicates success.

returnDesc

String

Return description. The value is success when the return code is 0.

token

String

Token, which must be updated to the LinkDevicePass parameter in the corresponding pass instance.

Response Example

HTTP/1.1 200 OK
Content-Type: application/json
{
  "returnCode": "0",
  "returnDesc": "success",
  "token": "5jyilu6km72yfiv8b54trcr90fj5val8"
}

Result Codes

For details, please refer to Common Result Codes in the Common Definition section.

Call Example

public JSONObject postToWalletServer(String urlSegment, String body) {
  // Construct the HTTP header.    
  HttpHeaders header = constructHttpHeaders();    
  // Construct the HTTP URL.    
  String baseUrl = ConfigUtil.instants().getValue("walletServerBaseUrl");    
  String walletServerUrl = baseUrl + urlSegment;    
  // Send the HTTP request and obtain the response.
  HttpEntity<JSONObject> entity = new HttpEntity<>(JSONObject.parseObject(body), header);    
  ResponseEntity<JSONObject> exchange =REST_TEMPLATE.exchange(walletServerUrl, HttpMethod.POST, entity, JSONObject.class);    
  // Return the pushed model or instance or NFC pass personalized data.    
  return exchange.getBody();
}