public interface PINPadDevice extends Device
The PINPad device object is obtained from the POSTerminal
, its' as follows:
PINPadDevice pinPadDevice = (PINPadDevice) POSTerminal.getInstance().getDevice("com.cloudpos.device.pinpad");Among them, the "com.cloudpos.device.pinpad" string is to identify the PINPad device, defined by the specific implementation.
Uses the PINPad device object to control the operation of the PINPad device.
An app can request permission to access the device, as shown below:
listenForPinBlock(KeyInfo, String, boolean, OperationListener, int)
and waitForPinBlock(KeyInfo, String, boolean, int)
.
calculateMac(KeyInfo, int, byte[])
.
encryptData(KeyInfo, byte[])
.
updateUserKey(int, int, byte[],int, byte[])
and updateUserKey(int, int, byte[])
.
Device
Modifier and Type | Field and Description |
---|---|
static int |
CHECK_TYPE_CUP
check type of check value.
|
static int |
CHECK_TYPE_NONE
check type of check value.
|
static int |
KEY_TYPE_FIX
key type: Fix key
|
static int |
KEY_TYPE_MK_SK
key type: Master/Session key
|
static int |
KEY_TYPE_TDUKPT
key type: TDUKPT
|
static int |
KEY_TYPE_TDUKPT_2009
key type: TDUKPT 2009
|
static int |
USER_KEY_ID_DATA
Data key
|
static int |
USER_KEY_ID_MAC
MAC key
|
static int |
USER_KEY_ID_PIN
PIN key
|
Modifier and Type | Method and Description |
---|---|
byte[] |
calculateMac(KeyInfo keyInfo,
int macFlag,
byte[] plain)
Calculates the MAC using current user key defined in
KeyInfo . |
void |
clearText()
Clears the message in the LCD.
|
byte[] |
encryptData(KeyInfo keyInfo,
byte[] plain)
Encrypts the data using user key defined in
KeyInfo |
byte[] |
encryptData(KeyInfo keyInfo,
byte[] plain,
int mode,
byte[] IV,
int IVLen)
Encrypts the data using user key defined in
KeyInfo |
int |
getDukptStatus(int dukptID,
byte[] KSNBuf)
Get the status of DUKPT Key
|
int |
getMkStatus(int mkId)
Get the status of MK with the specified ID
|
byte[] |
getRandom(int length)
Gets random data.
|
byte[] |
getSessionKeyCheckValue(int masterKeyID,
int userKeyID,
int algoCheckValue)
Get check value for session key.
|
int |
getSkStatus(int mkId,
int skID)
Get the status of SK with the specified MKID and SKID
/*
|
java.lang.String |
getSN()
Gets PINPad serial number.
|
void |
listenForOfflinePin(boolean voicePrompt,
OperationListener listener,
int timeout)
Let the user to wait the offline pin.
|
void |
listenForPinBlock(KeyInfo keyInfo,
java.lang.String pan,
boolean voicePrompt,
OperationListener listener,
int timeout)
Let the user input the PIN and calculate the encrypted pin block.
|
void |
open(int logicalID)
Opens the control of the PINPad.
|
boolean |
setAllowByPass(boolean allow)
Set online bypass pin for EMV.
|
boolean |
setGUIConfiguration(int flag,
byte[] data)
Set PINPAD GUI configuration.
|
boolean |
setGUIConfiguration(java.lang.String key,
java.lang.String value)
Set PINPAD GUI configuration.
|
void |
setPINLength(int minLen,
int maxLen)
Set the length of input PIN.
|
boolean |
setupCallbackHandler(com.cloudpos.jniinterface.PinPadCallbackHandler handler)
Setup callback for customize PINPAD UI.
|
void |
showText(int lineIndex,
java.lang.String message)
Displays message in the LCD.
|
void |
showText(int lineIndex,
java.lang.String message,
boolean voicePrompt)
Displays message in the LCD.
|
void |
updateMasterKey(int masterKeyID,
byte[] oldMasterKey,
byte[] newMasterKey)
Updates master key.
|
void |
updateMasterKeyWithCheck(int masterKeyID,
byte[] cipherNewMasterKey,
byte[] checkValue,
int algoCheckValue)
Updates master key, the master key must be ciphered by transport key.
|
void |
updateUserKey(int masterKeyID,
int userKeyID,
byte[] cipherNewUserKey)
Updates the user key(session key).
|
void |
updateUserKey(int masterKeyID,
int userKeyID,
byte[] cipherNewUserKey,
int checkType,
byte[] checkValue)
Updates the user key(session key).
|
void |
updateUserKey(int masterKeyID,
int userKeyID,
byte[] cipherNewUserKey,
int checkType,
byte[] checkValue,
KeyInfo keyInfo)
Update user key when using Master/Session key type.
|
void |
updateUserKeyWithCheck(int masterKeyID,
int userKeyID,
byte[] cipherNewUserKey,
int userKeyType,
byte[] checkValue,
int algoCheckValue)
Updates the user key(session key).
|
int |
updateUserKeyWithTR31Format(int masterKeyID,
int userKeyID,
byte[] tr31Msg)
Update the user key with check value.
|
boolean |
verifyResponseMac(KeyInfo keyInfo,
byte[] plainData,
int macFlag,
byte[] macData,
int nDirection)
Verify the response of the MAC.
|
PINPadOperationResult |
waitForOfflinePin(boolean voicePrompt,
int timeout)
The synchronous method of
listenForOfflinePin(boolean,OperationListener,int) . |
PINPadOperationResult |
waitForPinBlock(KeyInfo keyInfo,
java.lang.String pan,
boolean voicePrompt,
int timeout)
The synchronous method of
listenForPinBlock(KeyInfo,String,boolean,OperationListener,int) . |
cancelRequest, close, getFailCount, getUsageCount, open
static final int KEY_TYPE_TDUKPT
static final int KEY_TYPE_MK_SK
static final int KEY_TYPE_FIX
static final int KEY_TYPE_TDUKPT_2009
static final int USER_KEY_ID_PIN
Uses when calculate pin block.
static final int USER_KEY_ID_MAC
Uses when calculate MAC.
static final int USER_KEY_ID_DATA
Uses when encrypt data.
static final int CHECK_TYPE_NONE
Uses when update user key with check value.
static final int CHECK_TYPE_CUP
Uses when update user key with check value.
void open(int logicalID) throws DeviceException
logicalID
- logical ID of the device to open.DeviceException
- for the standard reasons that are documented in
DeviceException
.void showText(int lineIndex, java.lang.String message) throws DeviceException
lineIndex
- message
- DeviceException
- for the standard reasons that are documented in
DeviceException
.void showText(int lineIndex, java.lang.String message, boolean voicePrompt) throws DeviceException
lineIndex
- message
- voicePrompt
- DeviceException
- for the standard reasons that are documented in
DeviceException
.void clearText() throws DeviceException
DeviceException
- for the standard reasons that are documented in
DeviceException
.void updateMasterKey(int masterKeyID, byte[] oldMasterKey, byte[] newMasterKey) throws DeviceException
masterKeyID
- the master key index.oldMasterKey
- the original master key.newMasterKey
- the new master key.DeviceException
- for the standard reasons that are documented in
DeviceException
.void updateUserKey(int masterKeyID, int userKeyID, byte[] cipherNewUserKey, int checkType, byte[] checkValue) throws DeviceException
masterKeyID
- Master key index.userKeyID
- User key type.cipherNewUserKey
- Cipher new user key.checkType
- check value type:CHECK_TYPE_NONE
, CHECK_TYPE_CUP
.checkValue
- check value.DeviceException
- for the standard reasons that are documented in
DeviceException
.void updateUserKey(int masterKeyID, int userKeyID, byte[] cipherNewUserKey) throws DeviceException
masterKeyID
- Master key index.userKeyID
- User key index.cipherNewUserKey
- Cipher new user key.DeviceException
- for the standard reasons that are documented in
DeviceException
.byte[] encryptData(KeyInfo keyInfo, byte[] plain) throws DeviceException
KeyInfo
keyInfo
- plain
- Plain data buffer.DeviceException
- for the standard reasons that are documented in
DeviceException
.void listenForPinBlock(KeyInfo keyInfo, java.lang.String pan, boolean voicePrompt, OperationListener listener, int timeout) throws DeviceException
PINPadOperationResult
sent to the handleResult
method of the OperationListener
.
Because this method uses a timeout parameter, the device receiving this request MUST be able to
successfully respond to cancelRequest()
and abort the operation.
In case of a timeout occurring, the operation result will contain code=
ERR_TIMEOUT
, and no information about
pin block will be available.
keyInfo
- The key configuration that used by the PINPad calculate.pan
- the ASCII string of the card number.voicePrompt
- play the audio to notice user.listener
- The operation listener.timeout
- the maximum pending time of the method, in milliseconds.
Note that the timeout will begin when the request begins to be
processed. The timeout
parameter is then only
indicative. There are two special cases for
timeout
, as follows:
DeviceException
- for the standard reasons that are documented in
DeviceException
.PINPadOperationResult waitForPinBlock(KeyInfo keyInfo, java.lang.String pan, boolean voicePrompt, int timeout) throws DeviceException
listenForPinBlock(KeyInfo,String,boolean,OperationListener,int)
.
keyInfo
- The key configuration that used by the PINPad calculate.pan
- the ASCII string of the card number.voicePrompt
- play the audio to notice user.timeout
- the maximum pending time of the method, in milliseconds.
Note that the timeout will begin when the request begins to be
processed. The timeout
parameter is then only
indicative. There are two special cases for
timeout
, as follows:
DeviceException
- for the standard reasons that are documented in
DeviceException
.void listenForOfflinePin(boolean voicePrompt, OperationListener listener, int timeout) throws DeviceException
voicePrompt
- play the audio to notice user.listener
- The operation listener.timeout
- the maximum pending time of the method, in milliseconds.
Note that the timeout will begin when the request begins to be
processed. The timeout
parameter is then only
indicative. There are two special cases for
timeout
, as follows:
DeviceException
PINPadOperationResult waitForOfflinePin(boolean voicePrompt, int timeout) throws DeviceException
listenForOfflinePin(boolean,OperationListener,int)
.voicePrompt
- timeout
- DeviceException
byte[] calculateMac(KeyInfo keyInfo, int macFlag, byte[] plain) throws DeviceException
KeyInfo
.keyInfo
- The key configuration that used by the PINPad calculate.macFlag
- the constants as follows:
plain
- plain data buffer.DeviceException
- for the standard reasons that are documented in
DeviceException
.void setPINLength(int minLen, int maxLen) throws DeviceException
minLen
- The minimum length.maxLen
- The maximum length.DeviceException
- for the standard reasons that are documented in
DeviceException
.java.lang.String getSN() throws DeviceException
DeviceException
- for the standard reasons that are documented in
DeviceException
.byte[] getRandom(int length) throws DeviceException
length
- The length of the random data.DeviceException
- for the standard reasons that are documented in
DeviceException
.void updateUserKeyWithCheck(int masterKeyID, int userKeyID, byte[] cipherNewUserKey, int userKeyType, byte[] checkValue, int algoCheckValue) throws DeviceException
masterKeyID
- index of master keyuserKeyID
- index of user keycipherNewUserKey
- ciphered user keyuserKeyType
- user key type. 0--PIN key;1--MAC key;2--Data keycheckValue
- check value of user keyalgoCheckValue
- ALGO_CHECK_VALUE 0--ALGO_CHECK_VALUE_DEFAULT;1--ALGO_CHECK_VALUE_SE919DeviceException
- for the standard reasons that are documented in
DeviceException
.void updateMasterKeyWithCheck(int masterKeyID, byte[] cipherNewMasterKey, byte[] checkValue, int algoCheckValue) throws DeviceException
masterKeyID
- index of master keycipherNewMasterKey
- ciphed master keycheckValue
- check valuealgoCheckValue
- ALGO_CHECK_VALUE 0--ALGO_CHECK_VALUE_DEFAULT;1--ALGO_CHECK_VALUE_SE919DeviceException
- for the standard reasons that are documented in
DeviceException
.byte[] encryptData(KeyInfo keyInfo, byte[] plain, int mode, byte[] IV, int IVLen) throws DeviceException
KeyInfo
keyInfo
- plain
- plain data buffermode
- 0--PINPAD_ENCRYPT_STRING_MODE_EBC;1--PINPAD_ENCRYPT_STRING_MODE_CBC;2--PINPAD_ENCRYPT_STRING_MODE_CFB;3--PINPAD_ENCRYPT_STRING_MODE_OFB.NoPadding.IV
- initial vectorIVLen
- length of initial vectorDeviceException
- for the standard reasons that are documented in
DeviceException
.void updateUserKey(int masterKeyID, int userKeyID, byte[] cipherNewUserKey, int checkType, byte[] checkValue, KeyInfo keyInfo) throws DeviceException
masterKeyID
- master key index.userKeyID
- user key index:USER_KEY_ID_PIN
, USER_KEY_ID_MAC
, USER_KEY_ID_DATA
.cipherNewUserKey
- ciphered by master keycheckType
- check typeCHECK_TYPE_NONE
, CHECK_TYPE_CUP
.checkValue
- check valuekeyInfo
- DeviceException
- for the standard reasons that are documented in
DeviceException
.int updateUserKeyWithTR31Format(int masterKeyID, int userKeyID, byte[] tr31Msg) throws DeviceException
masterKeyID:
- Master key id.userKeyID:
- User key id.tr31Msg:
- TR31 Message.DeviceException
byte[] getSessionKeyCheckValue(int masterKeyID, int userKeyID, int algoCheckValue) throws DeviceException
masterKeyID
- master key index.userKeyID
- user key index:USER_KEY_ID_PIN
, USER_KEY_ID_MAC
, USER_KEY_ID_DATA
.algoCheckValue
- ALGO_CHECK_VALUE 0--ALGO_CHECK_VALUE_DEFAULT;1--ALGO_CHECK_VALUE_SE919DeviceException
- for the standard reasons that are documented in
DeviceException
.boolean verifyResponseMac(KeyInfo keyInfo, byte[] plainData, int macFlag, byte[] macData, int nDirection) throws DeviceException
keyInfo
- plainData
- datamacFlag
- the constants as follows:
macData
- mac datanDirection
- must be 0, reserved for futureDeviceException
boolean setGUIConfiguration(int flag, byte[] data) throws DeviceException
Set PINPAD GUI configuration.
Use two different flags to set different styles in PINPADUI,if flag is 1, it will set the alignment of the showed asterisk, if flag is 2, it will set the content of title bar.
Please set correct flag and data.
Call this method every time the PINPAD device is opened.
flag
- as follows table.data
- as follows table.
flag | data |
---|---|
1 | 0x00(Left)/0x01(Center)/0x02(Right) |
2 | content of title |
DeviceException
- for the standard reasons that are documented in
DeviceException
.boolean setGUIConfiguration(java.lang.String key, java.lang.String value) throws DeviceException
key
- as follows table.value
- as follows table.
key | value | default |
---|---|---|
style | system | system |
sound | true/false | false |
displaybackcolor | RGB color | #6C8C4F |
inputtextcolor | RGB color | #FFFFFF |
disablebackgrounddarkening | true/false | false |
DeviceException
- for the standard reasons that are documented in
DeviceException
.int getMkStatus(int mkId) throws DeviceException
mkId
- : master key ID
return value < 0 : error code
0 : it does not exist
1 : it existsDeviceException
int getSkStatus(int mkId, int skID) throws DeviceException
mkId
- : master key IDskID
- : session key ID
return value < 0 : error code
0 : it does not exist
1 : it existsDeviceException
int getDukptStatus(int dukptID, byte[] KSNBuf) throws DeviceException
dukptID
- : ID of dukptKSNBuf
- : buffer for saving KSN of this dukpt key
return vlaue < 0 : error code
0 : it does not exist
> 0 : KSN data lengthDeviceException
boolean setAllowByPass(boolean allow) throws DeviceException
allow
- : true for allow, false for not allow.
return vlaueDeviceException
boolean setupCallbackHandler(com.cloudpos.jniinterface.PinPadCallbackHandler handler) throws DeviceException
handler
- : PinPadCallbackHandler.
return vlaue true: success
false: fail.DeviceException