| CLASS info |
| public final class WalletPassApi extends Object |
| Enables a third-party app to initiate the HmsPass service. |
| Return type | Method name |
| WalletPassApiResponse | canAddPass(String appid,String passTypeId) Checks whether a pass can be added. |
| WalletPassApiResponse | addPass(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. |
| Method |
| public WalletPassApiResponse canAddPass(String appid, String passType) |
| Checks whether the type of pass can be added by the third-party app. |
Parameters
| Parameter name | Parameter desc |
| appid | Mandatory. App ID applied for on the HUAWEI Developer website. |
| passType | Mandatory. Pass type, which uniquely maps to the app ID and is obtained during pass service application on the HUAWEI Developer website. |
Return
| Type | desc |
| WalletPassApiResponse | Object 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 name | Parameter type | Parameter desc |
| hwPassData | String | Mandatory. Base64-encoded pass package to be added. |
Return
| Type | desc |
| WalletPassApiResponse | Object 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 name | Parameter desc |
| passTypeId | Pass type ID entered during pass service application on the HUAWEI Developer website. |
Return
| Type | desc |
| WalletPassApiResponse | Object 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 name | Parameter desc |
| passTypeId | Pass type ID. |
| passId | Pass ID. |
| sign | Certificate-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
| Type | desc |
| WalletPassApiResponse | Object 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 name | Parameter desc |
| passTypeId | Pass type ID. |
| passId | Pass ID. |
| cardParams | Pass 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. |
| reason | Reason 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. |
| sign | Certificate-based signature for the string of pass type ID, pass ID, pass parameters, reason, and access token. |
| callBack | Callback function that is used after the pass modification API is called, through which the callback result will be returned asynchronously. |
Return
| Type | desc |
| WalletPassApiResponse | Object 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 name | Parameter desc |
| passTypeId | Pass type ID. |
| passId | Pass ID. |
| cardParams | The 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. |
| reason | Reason for the query. This field is reserved and can be left empty. |
| sign | Certificate-based signature for the string of pass type ID, pass ID, pass parameters, reason, and access token. |
Return
| Type | desc |
| WalletPassApiResponse | Object returned by the called API. |
| Method |
public WalletPassApiResponse deletePass(String passType, String passId, String sign) |
| Deletes a pass corresponding to PassId. |
Parameters
| Parameter name | Parameter desc |
| passTypeId | Pass type ID. |
| passId | Pass ID. |
| sign | Certificate-based signature for the string of pass type ID and pass ID. |
Return
| Type | desc |
| WalletPassApiResponse | Object returned by the called API. |
| Method |
public WalletPassApiResponse queryPassStatus(String passType, String passId) |
| Queries the status of a pass corresponding to PassId. |
Parameters
| Parameter name | Parameter desc |
| passTypeId | Pass type ID. |
| passId | Pass ID. |
Return
| Type | desc |
| WalletPassApiResponse | Object returned by the called API. |
| Method |
public WalletPassApiResponse requirePassDeviceId() |
| Queries the device ID. |
Parameters
| Parameter name | Parameter desc |
| passTypeId | Pass type ID. |
Return
| Type | desc |
| WalletPassApiResponse | Object returned by the called API. |
| Result Code | Description | Result Code Returned By | Handling Suggestion |
| 0 | Operation successful. | ||
| 90001 | The number of cards to be activated has reached the upper limit. | canAddPass | Prompt the user to delete unused cards in HUAWEI Wallet. |
| 90002 | Failed to check whether the type of pass can be added. | canAddPass | Verify that the type of pass has been registered on the HUAWEI Developer website. |
| 90003 | HUAWEI Wallet version is outdated. | canAddPass | Prompt the user to update to the latest version. |
| 90004 | The number of this type of passes to be added has reached the upper limit registered on the HUAWEI Developer website. | canAddPass | Prompt the user to delete unused cards in HUAWEI Wallet. |
| 90007 | The ROM version of the device is outdated. | canAddPass | Prompt the user to update the device ROM. |
| 90008 | This function is not supported by the device. | canAddPass | Do not use the blank card function on a non-NFC device. |
| 90009 | Exceeded the pass package limit. | addPass | Change the pass package limit. |
| 91001 | Operation failed. | addPass | Prompt the user to try again. |
| 91002 | The pass package is empty or data fields in it are incomplete. | addPass | Verify that data fields in the hwpass.json file are generated according to the rules defined by the pass package. |
| 91003 | File save failed. | addPass | Prompt the user to try again. |
| 91004 | Operation canceled by the user. | addPass | Prompt the user to add the card again. |
| 91008 | The group corresponding to the pass type is empty. | addPass | Verify that the pass type in the pass package is the same as that registered on the HUAWEI Developer website. |
| 91009 | Blank card claim failed. | addPass | Contact Huawei operations staff for support. |
| 91010 | Pass package verification failed. | addPass | Verify that the certificate and private key are the same as those registered on the HUAWEI Developer website. |
| 91011 | Failed to obtain the token and device ID. | addPass | Change the test device or contact Huawei operations staff for support. |
| 91012 | Folder creation failed. | addPass | Prompt the user to try again. |
| 91013 | The pass file already exists. | addPass | Do not add the file again. |
| 92001 | Incorrect signature. | requireAccessCardSec, modifyNFCCard | Verify that the signature obtained based on the mandatory parameters is correct. |
| 92002 | Failed to obtain the temporary public key. | requireAccessCardSec | Verify the parameters. |
| 92003 | Card writing failed. | modifyNFCCard | Contact Huawei operations staff for support. |
| 92004 | The reason must be provided if the card is not written for the first time. | modifyNFCCard | Incorrect parameters. Please specify the reason parameter. |
| 92005 | User authorization not obtained. | modifyNFCCard | Prompt the user to perform authorization again. |
| 93005 | Empty parameter. | Prompt the user to try again. | |
| 93006 | HUAWEI Wallet version is outdated. | Prompt the user to update to the latest version. | |
| 93007 | Not signed in to HUAWEI Wallet. | Prompt the user to sign in to HUAWEI Wallet. | |
| 93008 | HUAWEI Wallet service terms have not been accepted. | Prompt the user to accept the HUAWEI Wallet service terms. | |
| 90099 | Unknown 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. |