Accept Card Payment
Initialize SDK
private void open(CommunicationMode mode) {
listener = new MyPosListener();
pos = QPOSService.getInstance(OtherActivity.this, mode);
if (pos == null) {
statusEditText.setText("CommunicationMode unknow");
return;
}
Handler handler = new Handler(Looper.myLooper());
pos.initListener(handler, listener);
}
Start Payment
pos.setAmount(amount, cashbackAmount, "156", TransactionType.GOODS);
pos.doTrade(60);
onDoTradeResult
@Override
public void onDoTradeResult(DoTradeResult result, Hashtable<String, String> decodeData) {
...
} else if (result == DoTradeResult.ICC) {
statusEditText.setText(getString(R.string.icc_card_inserted));
TRACE.d("EMV ICC Start")
pos.doEmvApp(EmvOption.START); // Start EMV application processing
}
...
}
EMV Application Selection
@Override
public void onRequestSelectEmvApp(ArrayList<String> appList) {
pos.selectEmvApp(position); // position is the index of the chosen application
// pos.cancelSelectEmvApp(); // Cancel the transaction
}
PIN Entry
@Override
public void onQposRequestPinResult(List<String> dataList, int offlinePinTimes) {
// draw the pin input keyboard, after finish the keyboard, then call the below api
pos.pinMapSync(value, 30); // the value is the keyboard pin coordinate position
}
Online Authorization
@Override
public void onRequestOnlineProcess(String tlv) {
// sending online message tlv data to backend server
response = sendTlvToServer();
...
// send the received online processing result to POS
// response should contain tag 8A (Authorisation Response Code) and tag 91 (Issuer Authentication Data)
pos.sendOnlineProcessResult(response);
}
Confirm Payment
@Override
public void onRequestTransactionResult(TransactionResult transactionResult) {
if (transactionResult == TransactionResult.APPROVED) {
// Transaction approved
} else if (transactionResult == TransactionResult.TERMINATED) {
// Transaction terminated
} else if (transactionResult == TransactionResult.DECLINED) {
// Transaction declined
} else if (transactionResult == TransactionResult.CANCEL) {
// Transaction cancelled
} else if (transactionResult == TransactionResult.CAPK_FAIL) {
// CAPK verification failed
} else if (transactionResult == TransactionResult.NOT_ICC) {
// Not an ICC card
} else if (transactionResult == TransactionResult.SELECT_APP_FAIL) {
// Application selection failed
} else if (transactionResult == TransactionResult.DEVICE_ERROR) {
// Device error
} else if (transactionResult == TransactionResult.CARD_NOT_SUPPORTED) {
// Card not supported
} else if (transactionResult == TransactionResult.MISSING_MANDATORY_DATA) {
// Missing mandatory data
} else if (transactionResult == TransactionResult.CARD_BLOCKED_OR_NO_EMV_APPS) {
// Card blocked or no EMV applications
} else if (transactionResult == TransactionResult.INVALID_ICC_DATA) {
// Invalid ICC data
}
}
Reversal Handling
If the EMV chip card refuses the transaction, but the transaction was approved by the issuer, a reversal procedure should be initiated by the mobile app. The following callback can get the required data for doing reversal:
@Override
public void onReturnReversalData(String tlv) {
// Process reversal data
...
}
Error Notification
@Override
public void onError(Error errorState) {
// Handle error state
}
Enum Value | Description |
---|---|
TIMEOUT | POS return result timed out |
COM_NOT_AVAILABLE | Function is not supported by firmware |
DEVICE_RESET | Reset POS status |
DEVICE_BUSY | Terminal is processing task, you need to wait for the callback result of this task before calling the new function |
INPUT_OUT_OF_RANGE | The length of the input data out of the range |
INPUT_INVALID_FORMAT | The length of the input data does not match the required length |
INPUT_INVALID | The length or format of the input data does not match the requirements |
AMOUNT_OUT_OF_LIMIT | The length of the input data out of the range |
MAC_ERROR | Data error in the sent instruction |