public class PaymentDevice extends Object
{@code Example Usage: PaymentDevice paymentDevice = paymentManager.getDevice(DeviceIdentifer.DEFAULT); paymentDevice.addDataListener(this); paymentDevice.enable(); paymentDevice.readCardData();
Modifier and Type | Class and Description |
---|---|
static class |
PaymentDevice.CardEncodeType
List indicates the type of encoding that was found on the card.
|
static class |
PaymentDevice.DataEncryptionType
Lists the type pf Encryption Algorithms applied on the data.
|
static interface |
PaymentDevice.DataListener
An interface for notifying client applications when the payment data and
status available.
|
static class |
PaymentDevice.DownloadType
The payment Device download or update type.
|
static class |
PaymentDevice.HostDecision
Decision indicator from the host response.
|
static class |
PaymentDevice.MerchantDecision
The merchant decision notes additional handling for the EMV request based
on required processor handling.
|
static class |
PaymentDevice.ReadMode
Lists type of read mode supported by the readCardData.
|
Modifier and Type | Method and Description |
---|---|
PaymentResults |
abort()
Abort or cancel previously issued request to device and display welcome
screen on payment device.
|
void |
addDataListener(PaymentDevice.DataListener listener)
The client application can register to get data notification via callbacks.
|
PaymentResults |
authorizeCard(double amount,
double otherAmount,
PaymentDevice.MerchantDecision merchatDecision,
ArrayList<String> tags,
boolean displayResult,
boolean pinTryExceedStatus,
boolean displayAmount,
boolean displayAppExpired,
int timeOut)
Authorizes the EMV transaction amounts using the inserted chip (EMV)
card.
|
PaymentResults |
completeOnlineEmv(PaymentDevice.HostDecision hostDecision,
boolean displayResult,
ArrayList<TagData> tagData)
Completes an online EMV transaction for PIN management.
|
MacData |
createMac(String u8MacData)
This is a required transaction for Canada.
|
void |
disable()
Disables the the payment device for transactions.
|
PaymentResults |
disableKeypad()
Disables the keypad on the payment device.
|
PaymentResults |
downloadFile(PaymentDevice.DownloadType downloadType,
byte[] fileData)
downloadFile is an asynchronous call.
|
PaymentResults |
downloadFile(PaymentDevice.DownloadType downloadType,
String filePath)
downloadFile is an asynchronous call.
|
void |
enable()
This is an asynchronous call and status of the enable method will be returned through the registered
PaymentDevice.DataListener . |
PaymentResults |
enableKeypad()
This method enables the keypad on the payment device.
|
PaymentResults |
enableKeypad(int timeOut)
This method enables the keypad on the payment device.
|
BatteryData |
getBatteryLevel()
Query the battery level of the payment device.
|
PaymentConfig |
getConfig()
Gets payment device configuration settings.
|
String |
getDateTime()
The getDateTime method is blocking (synchronous) call which retrieves the date and time from
the payment device.
|
DeviceInfo |
getDeviceInfo()
Returns information about the payment device.
|
PaymentResults |
getEmvTags(ArrayList<String> emvTags)
Gets tag information from the inserted card.
|
InterfaceConfig |
getInterfaceConfig()
This method provides access to get the interface configurations object.
|
BatteryData |
getLowBatteryThreshold()
Gets the acceptable low battery level.
|
boolean |
isEnabled()
Checks if the connection with the payment device is enabled or not.
|
PaymentResults |
promptAdditionalInfo(double amount,
int langCode,
boolean promptForTip,
boolean cashBack,
double surcharge,
int timeOut)
Requests the user to confirm the amount and surcharge passed by the
application and prompts the user to provide tip and cashback.
|
PaymentResults |
promptMenu(String messageLine1,
String messageLine2,
String choice1,
String choice2,
String choice3,
String choice4,
int timeOut)
Displays two lines of messages on the PAYMENT device and provides a menu
with a maximum of 4 choices.
|
PaymentResults |
promptMessage(String messageLine1,
String messageLine2,
String messageLine3,
String messageLine4,
boolean getUserConfirmation,
int timeOut)
Displays a maximum of 4 lines of messages on the payment device.
|
PaymentResults |
promptPin(String accountNumber,
int minPinLength,
int maxPinLength,
boolean isPinOptional,
int readTimeOut)
Requests for a PIN and gets the encrypted PIN block.
|
PaymentResults |
promptPin(String accountNumber,
int minPinLength,
int maxPinLength,
boolean isPinOptional,
int readTimeOut,
PromptPinMessage promptPinMessage)
Requests for a PIN and gets the encrypted PIN block.
|
PaymentResults |
readCardData(double amount,
double otherAmount,
PaymentDevice.ReadMode readMode,
int readTimeOut)
Reads the card data from the PAYMENT device.
|
PaymentResults |
readCardData(double amount,
double otherAmount,
PaymentDevice.ReadMode readMode,
int readTimeOut,
ReadCardMessage readCardMessage)
Reads the card data from the PAYMENT device.
|
void |
removeCard(String message1,
String message2)
Instruct the user to remove the EMV card inserted in the payment device.
|
void |
removeDataListener(PaymentDevice.DataListener listener)
The client application can un-register to get data notification via callbacks.
|
void |
setConfig(PaymentConfig config)
Sets payment device configuration settings.
|
void |
setDateTime(String dateTime)
The setDateTime method is blocking (synchronous) call which helps to
set the date and time on the payment device.The payment device must
be enabled before calling setDateTime method.
|
PaymentResults |
setEmvTags(ArrayList<TagData> emvTagData)
Sets tag information for the inserted card.
|
void |
setInterfaceConfig(InterfaceConfig interfaceConfig)
This method provides access to set the interface configurations like connect to the payment device.
|
PaymentResults |
setLowBatteryThreshold(int lowThreshold,
String lowBatterMessage)
Sets the acceptable low battery level.
|
PaymentResults |
validateMac(String u8MacBlock,
int langCode,
String u8TpkKey,
String u8TakKey,
String message1,
String message2,
String u8MacData)
Validates the response MAC and displays any authorization messages
returned by the host.
|
public boolean isEnabled()
public DeviceInfo getDeviceInfo()
public void enable() throws PaymentException
PaymentDevice.DataListener
.
This method is used to establish communication with the payment device and enable the payment device to do transactions.
This method does not do any transactions.
The following requirements must satisfy before calling enable method:
- The payment device must paired with the mobile device.
- The paired payment device name or MAC address must be set using PaymentDevice.setInterfaceConfig(InterfaceConfig interfaceConfig)
.
- The clients must implement PaymentDevice.DataListener
and call PaymentDevice.addDataListener(DataListener listener)
Only one session can be enabled at any given time.
The Bluetooth connection will fail if the payment device is not already paired.
The application can call other methods only after successful enabling.
If the same of payment device is used by other application, enable will fail and returns error.
If payment device shows Bluetooth connection status screen ,calling enable method will return communication error.
You must call disable() when you are done the payment transactions,
otherwise it will remain locked and be unavailable to other applications.
enable() returns "device is not paired" status ,when the BT is turned off or does not have any payment devices paired.
Example Usage: PaymentDevice paymentDevice = paymentManager.getDevice(DeviceIdentifer.DEFAULT); paymentDevice.addDataListener(this); paymentDevice.enable();
PaymentException
- The exception will thrown if it fails enable the payment
device.
Possible Error codes: SUCCESS, AUTHORIZATION_FAILED, FAILURE,
AUTHENTICATION_FAILED, ENABLE_FAILED, ALREADY_ENABLED,
INVALID_CONFIGURATION, COMMUNICATION_ERROR, NO_DATA_LISTENER,
DEVICE_IN_USE, CONNECTION_ERROR, DEVICE_NOT_PAIRED,
INVALID_OBJECT, UNDEFINEDpublic void disable() throws PaymentException
Example Usage: paymentDevice.disable();
PaymentException
- The exception will thrown if any unexpected error occurs
during the close call.
Possible Error codes: SUCCESS, FAILURE, COMMUNICATION_ERROR,
CONNECTION_ERROR, ALREADY_CLOSED, PREVIOUS_COMMAND_PENDING,
DISABLE_FAILED, INVALID_OBJECTpublic PaymentConfig getConfig() throws PaymentException
Example Usage: try{ PaymentConfig config = paymentDevice.getConfig(); }catch (PaymentException e) { responseString.append(e.getResult().getDescription()); }
PaymentException
public void setConfig(PaymentConfig config) throws PaymentException
Example Usage: try { PaymentConfig config = paymentDevice.getConfig(); config.idleMessage = "Welcome"; config.sleepModeTimeout =10000; config.getAllEncryptedData = false; config.dataEncryptionType = DataEncryptionType.NONE; paymentDevice.setConfig(config); }catch (PaymentException e) { responseString.append(e.getResult().getDescription()); }
PaymentException
public PaymentResults enableKeypad()
Example Usage: paymentDevice.enableKeypad();
public PaymentResults enableKeypad(int timeOut)
timeOut
- The timeOut specifies how long the payment device's keypad should be in enabled state.
The timeOut value unit is milliseconds.
Example Usage: paymentDevice.enableKeypad(12000);
public PaymentResults disableKeypad()
Example Usage: paymentDevice.disableKeypad();
public PaymentResults readCardData(double amount, double otherAmount, PaymentDevice.ReadMode readMode, int readTimeOut, ReadCardMessage readCardMessage)
amount
- Amount for the transaction; this value is required to enable
EMV contactless transactions. Allowed unto a maximum of 7
digits.otherAmount
- For future use. Any additional amount information for the
transaction; this value is used only used if EMV Contactless
is supported. Allowed upto a maximum of 7 digits.readMode
- Card reading mode (swipe, insert, touch, manual or all)
supported by payment device for reading card.readTimeOut
- Read timeout in milliseconds. Application can set the timeout.
But value must within threshold set by the payment device.readCardMessage
- The ReadCardMessage class provides option configure the messages
displayed on payment device while reading the card data on payment device
Example Usage: readCardMessage = new ReadCardMessage(); readCardMessage.messageTitle ="MessageTitle"; readCardMessage.screen1.message1 = "$2000.00"; readCardMessage.screen1.message2 = "Transaction..."; paymentDevice.readCardData(1, 4, ReadMode.ALL, 2000, readCardMessage);
public PaymentResults readCardData(double amount, double otherAmount, PaymentDevice.ReadMode readMode, int readTimeOut)
amount
- Amount for the transaction; this value is required to enable
EMV contactless transactions. Allowed unto a maximum of 7
digits.otherAmount
- For future use. Any additional amount information for the
transaction; this value is used only used if EMV Contactless
is supported. Allowed upto a maximum of 7 digits.readMode
- Card reading mode (swipe, insert, touch, manual or all)
supported by payment device for reading card.readTimeOut
- Read timeout in milliseconds. Application can set the timeout.
But value must within threshold set by the payment device.
{@code Example Usage: paymentDevice.readCardData(1, 4345, ReadMode.ALL, 8000);
public PaymentResults promptPin(String accountNumber, int minPinLength, int maxPinLength, boolean isPinOptional, int readTimeOut, PromptPinMessage promptPinMessage)
accountNumber
- The account number or masked PAN used with the entered PIN to
create the encrypted PIN Block (8 to 19 numeric digits).minPinLength
- Minimum PIN Length.maxPinLength
- Maximum PIN Length. A maximum length of up to 12 characters is
allowed.isPinOptional
- If this flag is set True, the PIN entry optional. If this flag
is set to false, the PIN entry is mandatory.readTimeOut
- Read timeout in milliseconds. Application can set the timeout.
But value must within threshold set by the payment device.promptPinMessage
- The PromptPinMessage class provides option configure the
messages displayed on the payment device while reading the PIN.
Example Usage: promptPINMessage = new PromptPinMessage(); promptPINMessage.messageTitle ="MessageTitle"; promptPINMessage.screen1.message1 = "Sale $1,000.00"; promptPINMessage.screen1.message2 = "Transaction.."; paymentDevice.promptPin("0123456789012345", 4, 12, true, 2000, promptPinMessage);
public PaymentResults promptPin(String accountNumber, int minPinLength, int maxPinLength, boolean isPinOptional, int readTimeOut)
accountNumber
- The account number or masked PAN used with the entered PIN to create the
encrypted PIN Block (8 to 19 numeric digits).minPinLength
- Minimum PIN Length.maxPinLength
- Maximum PIN Length. A maximum length of up to 12 characters is
allowed.isPinOptional
- If this flag is set True, the PIN entry optional. If this flag
is set to false, the PIN entry is mandatory.readTimeOut
- Read timeout in milliseconds. Application can set the timeout.
But value must within threshold set by the payment device.
Possible Error codes: SUCCESS, FAILURE, DEVICE_NOT_ENABLED, NULL_POINTER, COMMUNICATION_ERROR, CONNECTION_ERROR, INVALID_OBJECT, PREVIOUS_COMMAND_PENDING, TIMED_OUT, OPERATION_CANCELLED, INVALID_PIN_LENGTH, NO_DUKPT_KEY, INVALID_VALUE,LOW_POWER_OPERATION_CANCELLEDExample Usage: paymentDevice.promptPin("0123456789012345", 4, 12, true, 2000);
public PaymentResults promptMenu(String messageLine1, String messageLine2, String choice1, String choice2, String choice3, String choice4, int timeOut)
messageLine1
- Message Line 1 to display on the PINPad screen. Maximum
characters allowed for Choice + Message = 18 characters. For
example, if Choice is 6 characters, maximum message length is
12 characters. Messages longer than maximum message length
will be truncated.messageLine2
- Message Line 2 to display on the PINPad screen. Maximum
characters allowed for Choice + Message = 18 characters. For
example, if Choice is 6 characters, maximum message length is
12 characters. Messages longer than maximum message length
will be truncated.choice1
- Choice text for selection from the PINPad using the function
keys. Choice string can consist of up to 8 characters.choice2
- Choice text for selection from the PINPad using the function
keys. Choice string can consist of up to 8 characters.choice3
- Choice text for selection from the PINPad using the function
keys. Choice string can consist of up to 8 characters.choice4
- Choice text for selection from the PINPad using the function
keys. Choice string can consist of up to 8 characters.timeOut
- Timeout in milliseconds. Application can set the timeout. But
value must within threshold set by the payment device.
Example Usage: paymentDevice.promptMenu("messageLine1","messageLine2","choice1","choice2","choice3","choice4",timeOut);
public PaymentResults promptAdditionalInfo(double amount, int langCode, boolean promptForTip, boolean cashBack, double surcharge, int timeOut)
amount
- Transaction amount value that is to be displayed.langCode
- Numeric value denoting the language code for determining the
displayed language of the pre-defined prompt.promptForTip
- Indicates whether or not to prompt for tip and return the
amount entered.cashBack
- Indicates whether or not to prompt for cashback and return the
amount selected. The user would select the cashback amount
from 4 pre-defined choices - $20, $40, $60 and $100. These
choices cannot be modified.surcharge
- An optional surcharge amount that is to be displayed and
confirmed. A zero amount
will cause this prompt to be bypassedtimeOut
- Read timeout. Application can set the timeout. But value must
within threshold set by the payment device.
Example Usage: paymentDevice.promptAdditionalInfo(1.25, 0,true, true,1.25, 60000);
public PaymentResults promptMessage(String messageLine1, String messageLine2, String messageLine3, String messageLine4, boolean getUserConfirmation, int timeOut)
messageLine1
- A message to display on line 1 of the PINPad screen. May
consist of up to 16 charactersmessageLine2
- A message to display on line 2 of the PINPad screen. May
consist of up to 16 charactersmessageLine3
- A message to display on line 2 of the PINPad screen. May
consist of up to 16 charactersmessageLine4
- A message to display on line 4 of the PINPad screen. May
consist of up to 16 charactersgetUserConfirmation
- True or False. Allows the user to press OK (Enter key), CANCEL
or CORR keys in response to the displayed messages.timeOut
- Read timeout. Application can set the timeout. But value must
within threshold set by the payment device.
Example Usage: paymentDevice.promptMessage("messageLine1","messageLine2","messageLine3","messageLine4",true, timeOut);
public PaymentResults abort()
Example Usage: paymentDevice.abort();
public BatteryData getBatteryLevel()
Example Usage: BatteryData data = paymentDevice.getBatteryLevel(); String batteryLevel = String.valueOf(data.getValue());
public MacData createMac(String u8MacData)
u8MacData
- String of data to be MAC'ed. The length of the key should be
16/32/48 bytes in HEX format.
Example Usage: MacData data = paymentDevice.createMac("1112131415161718");
public PaymentResults validateMac(String u8MacBlock, int langCode, String u8TpkKey, String u8TakKey, String message1, String message2, String u8MacData)
u8MacBlock
- u8-character MAC Block to verifylangCode
- Numeric value denoting the language code for determining the
displayed language of the card entry prompts.u8TpkKey
- PIN (TPK) Keyu8TakKey
- MAC (TAK) Keymessage1
- Message Line 1 (0-16 bytes)message2
- Message Line 2 (0-16 bytes)u8MacData
- Buffer to hold all data to be MAC'ed
Example Usage: paymentDevice.validateMac("u8MacBlock", 0, "", "", "message1", "message2","1112131415161718");
public PaymentResults completeOnlineEmv(PaymentDevice.HostDecision hostDecision, boolean displayResult, ArrayList<TagData> tagData)
hostDecision
- HostDecision enum value which is the decision indicator from
the host response.displayResult
- Indicator to note whether or not to display the final response
message. The valid values are: false - Do not display, true -
DisplaytagData
- List of EMV data which contains EMV tag and its values.
Example Usage: ArrayList<TagData> emvDataList = new ArrayList<TagData>(); emvDataList.add(new TagData("5A085413330089601075")); paymentDevice.completeOnlineEmv(HostDecision.HOST_AUTHORIZED, true, emvDataList );
public PaymentResults getEmvTags(ArrayList<String> emvTags)
ArrayList
-
Example Usage: ArrayList<String> emvTagData = new ArrayList<String>(); emvTagData.add("5F25"); paymentDevice.getEmvTags(emvTagData);
public PaymentResults setEmvTags(ArrayList<TagData> emvTagData)
emvTagData
- List of emv tag ID and its values be set on the inserted card.
Example Usage: ArrayList<TagData> emvTagData = new ArrayList<TagData>(); TagData data = new TagData("5A085413330089601075"); emvTagData.add(data); paymentDevice.setEmvTags(emvTagData);
public PaymentResults authorizeCard(double amount, double otherAmount, PaymentDevice.MerchantDecision merchatDecision, ArrayList<String> tags, boolean displayResult, boolean pinTryExceedStatus, boolean displayAmount, boolean displayAppExpired, int timeOut)
amount
- Transaction amount value.otherAmount
- Other transaction amount value.merchatDecision
- The merchant decision notes additional handling for the EMV
request based on required processor handling.tags
- is an list of EMV tags that is required at this transaction
stage to be retrieved.displayResult
- True or False. True= display result on Payment device display.pinTryExceedStatus.
- True or False. True= displays when PIN tries have been
exceeded on Payment device display.displayAmount
- True or False. True= displays amount on Payment device displaydisplayAppExpired.
- True or False. True= displays if app is expired on Payment
device displaytimeout
- Card authorization timeout. Application must set the timeout.
Example Usage: ArrayListemvTagList = new ArrayList (); for(String tag:tagArray) { emvTagList.add("5A085413330089601075"); } paymentDevice.authorizeCard(999.0, 1.0,MerchantDecision.REQUEST_TC, emvTagList,true, true,true, false,8000);
public BatteryData getLowBatteryThreshold()
Example Usage: BatteryData data = paymentDevice.getLowBatteryThreshold(); String batteryLevel = String.valueOf(data.getValue());
public PaymentResults setLowBatteryThreshold(int lowThreshold, String lowBatterMessage)
lowThreshold
- Below this value, some of the commands will not execute. Note:
The values for PD40-100 device are 0 - Low power, almost 0% 1 -
The battery icon display 1 grid ( 1% to 25%) 2 - The battery
icon display 2 grids (25% to 50 %) 3 - The battery icon
display 3 grids (50% to 75%) 4 - The battery icon display 4
grids (75% to 100%)lowBatterMessage
- The message to be displayed when the battery level goes below
the low threshold.
Note :The battery check will be done only for the following commands:
1. ReadCardData
2. promptPin
3. completeOnlineEmv
4. createMac
5. validateMac
6. getEmvTags
7. setEmvTags
8. authorizeCard
Example Usage: paymentDevice.setLowBatteryThreshold(2,"The power is in battery grid2");
public InterfaceConfig getInterfaceConfig() throws PaymentException
Example Usage: InterfaceConfig interfaceConfig = paymentDevice.getInterfaceConfig();
PaymentException
- will be thrown if any error occurs.
Possible Error codes: SUCCESS, FAILURE, UNDEFINED.public void setInterfaceConfig(InterfaceConfig interfaceConfig) throws PaymentException
Example Usage: InterfaceConfig interfaceConfig = paymentDevice.getInterfaceConfig(); interfaceConfig.macAddress = "8CDE520FE2FE"; paymentDevice.setInterfaceConfig(interfaceConfig); payment.enable();
interfaceConfig
- The Parameters to use for this payment device configurations.PaymentException
- will be thrown if any error occurs.
Possible Error codes: SUCCESS, FAILURE, UNDEFINED.public void removeCard(String message1, String message2) throws PaymentException
message1
- The message which gives the information of type of card.message2
- the message which gives instructions to user for the removal of the card.
Example Usage: paymentDevice.removeCard("EMVCard", "please remove the Card");
PaymentException
- will be thrown if any error occurs.public PaymentResults downloadFile(PaymentDevice.DownloadType downloadType, String filePath)
downloadType
- This indicates the type of File to download either DownloadType.EMVPARA or DownloadType.FIRMARE file.filePath
- This is file location accepted for downloading files.
Example Usage: paymentDevice.downloadFile(DownloadType.EMVPARAM, "//Sdcard//Payment//EmvParam");
public PaymentResults downloadFile(PaymentDevice.DownloadType downloadType, byte[] fileData)
downloadType
- The type of File to download such as EMV parameter ,Firmware file, etc.fileData
- The complete download data.The partial data is not allowed.
Example Usage: in = new FileInputStream("//sdcard//Payment//EmvParam"); int bufferSize = in.available(); byte[] emvParamBuffer = new byte[bufferSize]; while ((byteread = in.read(emvParamBuffer)) != -1) { result = paymentDevice.downloadFile(DownloadType.EMVPARA, emvParamBuffer)); }
public String getDateTime() throws PaymentException
none.
- PaymentException
- The exception will thrown if any unexpected error occurs.
Possible Error codes: SUCCESS, FAILURE, COMMUNICATION_ERROR,
CONNECTION_ERROR, PREVIOUS_COMMAND_PENDING,
INVALID_OBJECT.public void setDateTime(String dateTime) throws PaymentException
dateTime
- - Date and time string in the format "YYYY-MM-DD HH:MM:SS". The date and time can be separated by space.
Where
YYYY = four-digit year.
MM = two-digit month (01=January, etc.).
DD = two-digit day of month (01 through 31).
HH = two digits of hour (00 through 23) (am/pm NOT allowed).
MM = two digits of minute (00 through 59).
SS = two digits of second (00 through 59).PaymentException
- The exception will thrown if any unexpected error occurs.
Possible Error codes: SUCCESS, FAILURE, COMMUNICATION_ERROR,
CONNECTION_ERROR, PREVIOUS_COMMAND_PENDING,
INVALID_OBJECT,INVALID_VALUE,NULL_POINTER.public void addDataListener(PaymentDevice.DataListener listener) throws PaymentException
listener
- The DataListener callabck object.PaymentException
- Exception will be thrown if any error occurs during this
call.public void removeDataListener(PaymentDevice.DataListener listener) throws PaymentException
listener
- PaymentException
- Exception will be thrown if any error occurs during this call.