目录

CLASS info
public final class WalletPassApi extends Object
Enables a third-party app to initiate the HmsPass service.

Public Method Summary

Return typeMethod name
WalletPassApiResponsecanAddPass(String appid,String passTypeId) Checks whether a pass can be added.
WalletPassApiResponseaddPass(String hwPassData)
Adds a pass.
WalletPassApiResponse

requireAccessToken(String passTypeId)

Requests a token for interacting with the NFC card.

WalletPassApiResponse

requireAccessCardSec(String passTypeId, String passId, String sign)

Requests a temporary public key for communicating with the NFC card.

WalletPassApiResponse

modifyNFCCard(String passTypeId, String passId, String reason, String cardParams, 

String sign)

Modifies the NFC card (card writing).

WalletPassApiResponse

readNFCCard(String passTypeId, String passId, String cardParams, String reason

, String sign)

Reads the NFC card.

WalletPassApiResponse

deletePass(String passTypeId, String passId, String sign)

Deletes the designated pass.

WalletPassApiResponse

queryPassStatus(String passTypeId, String passId)

Queries the status of the designated pass.

WalletPassApiResponse

requirePassDeviceId(String passTypeId)

Queries the account and unique device ID.

Public Methods

Method
public WalletPassApiResponse canAddPass(String appid, String passType)
Checks whether the type of pass can be added by the third-party app.

Parameters

Parameter nameParameter desc
appidMandatory. App ID applied for on the HUAWEI Developer website.
passTypeMandatory. Pass type, which uniquely maps to the app ID and is obtained during pass service application on the HUAWEI Developer website.


Return

Typedesc
WalletPassApiResponseObject returned by the called API.
Method


public WalletPassApiResponse addPass(String hwPassData)

Adds a pass to HUAWEI Wallet, which will verify the signature of the pass.

Parameters

Parameter nameParameter typeParameter desc
hwPassDataStringMandatory. Base64-encoded pass package to be added.


Return

Typedesc
WalletPassApiResponseObject returned by the called API.
Method


public WalletPassApiResponse requireAccessToken(String passTypeId)

Requests to modify the token of a pass (NFC card only). Upon successful request, a one-time token with a validity period will be returned.

Parameters

Parameter nameParameter desc
passTypeIdPass type ID entered during pass service application on the HUAWEI Developer website.


Return

Typedesc
WalletPassApiResponseObject returned by the called API.
Method


public WalletPassApiResponse requireAccessCardSec(String passTypeId, String passId, String sign)

Requests a temporary public key for communicating with the NFC card. Before making the request, obtain the token for interacting with the NFC card. Then, include the token in the signature for request verification.

Parameters

Parameter nameParameter desc
passTypeIdPass type ID.
passIdPass ID.
signCertificate-based signature for the string of pass type ID, pass ID, and access token. The access token should be obtained by calling the token application API.


Return

Typedesc
WalletPassApiResponseObject returned by the called API.
Method


public void modifyNFCCard(String passTypeId, String passId, String cardParams, String reason, String sign, IpassModifyNFCCardImpl callBack)

Modifies parameters of a pass (NFC card only). Before calling this API, obtain the temporary public key for communicating with the NFC card and encrypt the request parameters.

Parameters

Parameter nameParameter desc
passTypeIdPass type ID.
passIdPass ID.
cardParamsPass parameters (in JSON format) to be modified. The key of each parameter should be specified during card application on the HUAWEI Developer website, while the value of the parameter should be encrypted by using tempAccessSec, the temporary public key for communicating with the card. Note: For details about the format of the cardParams parameter, please refer to the blank card format requirements in Generating and Pushing a Pass Package to HUAWEI Wallet.
reasonReason for card writing. This parameter is optional for the initial API call but is mandatory for subsequent updates. A pop-up should be displayed for the user to acknowledge card writing.
signCertificate-based signature for the string of pass type ID, pass ID, pass parameters, reason, and access token.
callBackCallback function that is used after the pass modification API is called, through which the callback result will be returned asynchronously.


Return

Typedesc
WalletPassApiResponseObject returned by the called API.
Method


public WalletPassApiResponse readNFCCard(String passTypeId, String passId, String cardParams, String reason,String sign)

Queries designated parameters of a pass (NFC card only). The request should contain the specified temporary public key for encrypting the query result.

Parameters

Parameter nameParameter desc
passTypeIdPass type ID.
passIdPass ID.
cardParamsThe value adopts the following format:{“car_key_sn”:”” ,”car_key_group”:””,”read_publickey”:”Temporary public key that is passed to the API, for encrypting the query result. Mandatory.”}After obtaining the parameters, fill the card serial number in car_key_sn and the key group number in car_key_group (separate multiple key group numbers with vertical bars (|). Then, encrypt the entire string using the public key in read_publickey.
reasonReason for the query. This field is reserved and can be left empty.
signCertificate-based signature for the string of pass type ID, pass ID, pass parameters, reason, and access token.


Return

Typedesc
WalletPassApiResponseObject returned by the called API.
Method


public WalletPassApiResponse deletePass(String passType, String passId, String sign)

Deletes a pass corresponding to PassId.

Parameters

Parameter nameParameter desc
passTypeIdPass type ID.
passIdPass ID.
signCertificate-based signature for the string of pass type ID and pass ID.


Return

Typedesc
WalletPassApiResponseObject returned by the called API.
Method


public WalletPassApiResponse queryPassStatus(String passType, String passId)

Queries the status of a pass corresponding to PassId.

Parameters

Parameter nameParameter desc
passTypeIdPass type ID.
passIdPass ID.


Return

Typedesc
WalletPassApiResponseObject returned by the called API.
Method


public WalletPassApiResponse requirePassDeviceId()

Queries the device ID.

Parameters

Parameter nameParameter desc
passTypeIdPass type ID.

Return

Typedesc
WalletPassApiResponseObject returned by the called API.
Result CodeDescriptionResult Code Returned ByHandling Suggestion
0Operation successful.

90001The number of cards to be activated has reached the upper limit.canAddPassPrompt the user to delete unused cards in HUAWEI Wallet.
90002Failed to check whether the type of pass can be added.canAddPassVerify that the type of pass has been registered on the HUAWEI Developer website.
90003HUAWEI Wallet version is outdated.canAddPassPrompt the user to update to the latest version.
90004The number of this type of passes to be added has reached the upper limit registered on the HUAWEI Developer website.canAddPassPrompt the user to delete unused cards in HUAWEI Wallet.
90007The ROM version of the device is outdated.canAddPassPrompt the user to update the device ROM.
90008This function is not supported by the device.canAddPassDo not use the blank card function on a non-NFC device.
90009Exceeded the pass package limit.addPassChange the pass package limit.
91001Operation failed.addPassPrompt the user to try again.
91002The pass package is empty or data fields in it are incomplete.addPassVerify that data fields in the hwpass.json file are generated according to the rules defined by the pass package.
91003File save failed.addPassPrompt the user to try again.
91004Operation canceled by the user.addPassPrompt the user to add the card again.
91008The group corresponding to the pass type is empty.addPassVerify that the pass type in the pass package is the same as that registered on the HUAWEI Developer website.
91009Blank card claim failed.addPassContact Huawei operations staff for support.
91010Pass package verification failed.addPassVerify that the certificate and private key are the same as those registered on the HUAWEI Developer website.
91011Failed to obtain the token and device ID.addPassChange the test device or contact Huawei operations staff for support.
91012Folder creation failed.addPassPrompt the user to try again.
91013The pass file already exists.addPassDo not add the file again.
92001Incorrect signature.requireAccessCardSec, modifyNFCCardVerify that the signature obtained based on the mandatory parameters is correct.
92002Failed to obtain the temporary public key.requireAccessCardSecVerify the parameters.
92003Card writing failed.modifyNFCCardContact Huawei operations staff for support.
92004The reason must be provided if the card is not written for the first time.modifyNFCCardIncorrect parameters. Please specify the reason parameter.
92005User authorization not obtained.modifyNFCCardPrompt the user to perform authorization again.
93005Empty parameter.
Prompt the user to try again.
93006HUAWEI Wallet version is outdated.
Prompt the user to update to the latest version.
93007Not signed in to HUAWEI Wallet.
Prompt the user to sign in to HUAWEI Wallet.
93008HUAWEI Wallet service terms have not been accepted.
Prompt the user to accept the HUAWEI Wallet service terms.
90099Unknown error.
When an unknown error such as an API exception occurs, prompt the user to try again. If the error persists, contact Huawei operations staff for support.