Skip to content

Explore-In-HMS/HuaweiNFCPayWear

Repository files navigation

HCE Payment Watch Application for HarmonyOS ⌚

demo

📸 Screenshots

1 2
3 5

Introduction

Using HMS Wear Engine, you can communicate between Android and the watch app. To make payment via NFC, you can send the tokens you have to the watch with this service and communicate with the POS terminal via the watch.

Core Principles

  • Wear Engine integration for Lite-Wearable
  • Encrypt & Decrypt Keys with HUKS (HarmonyOS Universal KeyStore)
  • NFC Transactions between Watch and POS Terminal

Tech Stack

  • JavaScript programming language
  • HarmonyOS Operating System
  • HMS Wear Engine
  • HarmonyOS Universal KeyStore (HUKS)

Functions Used In The Project

The following functions are used in index.js class.

🔹 initCardEmulation

The initCardEmulation function checks the NFC card emulation capabilities of the device and whether a particular application is the default service for NFC card emulation.

🔹 onReady

  • It provides the necessary prerequisites for NFC card emulation by calling the initCardEmulation function.
  • Initializes NFC card emulation by creating an instance of the cardEmulation.HceService class.
  • Starts NFC card emulation with a specific application name and NFC payment AID via the start method.
  • By adding an "hceCmd" event to the hceService object, the NFC card emulation defines a callback function that will run when a command is sent to the device. This function processes the incoming APDU command by calling the handleApdu function and generates an appropriate response.

🔹 sendResponse

The sendResponse function transmits a response generated by NFC card emulation. This function transmits the generated response to the device via the hceService.transmit method.

🔹 compareArray

This function checks the match between APDU commands received by the NFC card emulation and predefined APDU commands.

🔹 handleApdu

The handleApdu function processes an APDU (Smart Card Commands) command received by the NFC card emulation. This function compares the incoming APDU command with predefined commands and generates an appropriate response.

🔹 switch-case

This is the part where the necessary operations are performed according to the button clicked and a toast message is displayed to the user on the screen according to the result of the operation.

Links