How to Customize the POS Graphical User Interface for PINPAD Input: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
== API == | == API == | ||
=== <big>setupCallbackHandler | === <big>setupCallbackHandler</big>=== | ||
<syntaxhighlight lang="java"> | <syntaxhighlight lang="java">boolean setupCallbackHandler(PinPadCallbackHandler handler)</syntaxhighlight> | ||
Set a callback handler. When an input occurs to PINPAD, the callback handler is called. | Set a callback handler. When an input occurs to PINPAD, the callback handler is called. | ||
Line 18: | Line 18: | ||
! scope="row" colspan="2" | Returns | ! scope="row" colspan="2" | Returns | ||
|- | |- | ||
| | | boolean|| true: success. | ||
|} | |} | ||
=== <big>processCallback of | === <big>processCallback of PinPadCallbackHandler </big>=== | ||
<syntaxhighlight lang="java">void processCallback(byte[] data);</syntaxhighlight> | <syntaxhighlight lang="java">void processCallback(byte[] data);</syntaxhighlight> | ||
The callback method. | The callback method. | ||
Line 37: | Line 37: | ||
== Usage == | == Usage == | ||
The setupcallbackhandler method | The setupcallbackhandler method will set a callback handler. Before calling this method, you should call the open method. After setting the callback handler, the default PINPAD UI will not pop up, the driver will send the inputing PIN count to the callback handler, then the third-app can process the inputing PIN count. | ||
'''Snippet code:''' | |||
<syntaxhighlight lang="java"> | |||
PINPadDevice device = (PINPadDevice) POSTerminal.getInstance(mContext) | |||
.getDevice("cloudpos.device.pinpad"); | |||
device.open(); | |||
device.setupCallbackHandler(new PinPadCallbackHandler() { | |||
@Override | |||
public void processCallback(byte[] data) { | |||
Log.e(TAG, "processCallback "); | |||
mHandler.obtainMessage(PIN_KEY_CALLBACK, data[0]).sendToTarget(); | |||
} | |||
}); | |||
KeyInfo keyInfo = new KeyInfo(PINPadDevice.KEY_TYPE_MK_SK, 0, 0, 4); | |||
String pan = "0123456789012345678"; | |||
OperationResult operationResult = device.waitForPinBlock(keyInfo, pan, false, | |||
TimeConstants.FOREVER); | |||
if (operationResult.getResultCode() == OperationResult.SUCCESS) { | |||
byte[] pinBlock = ((PINPadOperationResult) operationResult).getEncryptedPINBlock(); | |||
sendSuccessLog2("PINBlock = " + StringUtility.byteArray2String(pinBlock)); | |||
} else { | |||
sendFailedLog2(mContext.getString(R.string.operation_failed)); | |||
} | |||
device.close(); | |||
</syntaxhighlight> |
Revision as of 03:04, 14 January 2022
API
setupCallbackHandler
boolean setupCallbackHandler(PinPadCallbackHandler handler)
Set a callback handler. When an input occurs to PINPAD, the callback handler is called.
Parameters | |
---|---|
handler | PinPadCallbackHandler : Not null. |
Returns | |
---|---|
boolean | true: success. |
processCallback of PinPadCallbackHandler
void processCallback(byte[] data);
The callback method.
Parameters | |
---|---|
data | byte[] : date[0] is the count of input pin. |
Usage
The setupcallbackhandler method will set a callback handler. Before calling this method, you should call the open method. After setting the callback handler, the default PINPAD UI will not pop up, the driver will send the inputing PIN count to the callback handler, then the third-app can process the inputing PIN count. Snippet code:
PINPadDevice device = (PINPadDevice) POSTerminal.getInstance(mContext)
.getDevice("cloudpos.device.pinpad");
device.open();
device.setupCallbackHandler(new PinPadCallbackHandler() {
@Override
public void processCallback(byte[] data) {
Log.e(TAG, "processCallback ");
mHandler.obtainMessage(PIN_KEY_CALLBACK, data[0]).sendToTarget();
}
});
KeyInfo keyInfo = new KeyInfo(PINPadDevice.KEY_TYPE_MK_SK, 0, 0, 4);
String pan = "0123456789012345678";
OperationResult operationResult = device.waitForPinBlock(keyInfo, pan, false,
TimeConstants.FOREVER);
if (operationResult.getResultCode() == OperationResult.SUCCESS) {
byte[] pinBlock = ((PINPadOperationResult) operationResult).getEncryptedPINBlock();
sendSuccessLog2("PINBlock = " + StringUtility.byteArray2String(pinBlock));
} else {
sendFailedLog2(mContext.getString(R.string.operation_failed));
}
device.close();