MagneFlex Demo Page (JS)
Use this page to request MagneFlex app request
Download MTMagneFlexLib.js
Select a tab that is relevant to your device to send request
Sample Request From JavaScript
Command return data will be here.
Request Data
Use this function to request card swipe.
Request Data
View Sample Code
function requestData()
{
var readerParam = new MTMagneFlexParameter.readerParameter();
readerParam.timeLimit = '3C';
var requestParam = new MTMagneFlexParameter.requestParameter();
requestParam.operation = MagneFlexOp.REQUEST_DATA;
requestParam.httpMethod = HTTPMethod.NONE;
requestParam.customDisplayMessage = 'Please Swipe Card or Scan a Check';
requestParam.fullScreenMode = false;
requestParam.closeDeviceAfter = true;
requestParam.destinationURL = '';
MTMagneFlexLib.requestData(readerParam, requestParam, dataCallBack);
}
Sample return data will be here.
Sample Request From JavaScript
Add Event Listener to User Event
Use this function to open device and listen to user event.
Add Listener
View Sample Code
function startNFCListener() {
MTMagneFlexLib.addEventListener("UserEvent", userEventHandler, function (x) { setElemText("txtAddListenerResponse",x); });
}
addEventListener response data
Clear Data
Function will response following data
Handle User Event
Present/Remove NFC Card
View Sample Code
function userEventHandler(e) {
var msg = "name=" + e.name + ",data=" + e.data;
setElemText("txtUserEvent", msg);
}
User Event Data
Clear Data
User Event will notify following data
Start NFC
Use this function to activate NFC card, then continue NFC command.
Request Start NFC
View Sample Code
function startNFCAccess() {
readerArgument = new MTMagneFlexParameter.readerParameter();
readerArgument.timeLimit = '1E';
readerArgument.hideUI = true; // hide the DynaFlex UI
requestArgument = new MTMagneFlexParameter.requestParameter();
requestArgument.operation = MagneFlexOp.REQUEST_START_NFC;
requestArgument.httpMethod = HTTPMethod.NONE;
requestArgument.closeDeviceAfter = false;
requestArgument.destinationURL = "";
MTMagneFlexLib.requestStartNFC(readerArgument, requestArgument, function (x) { setElemText("txtStartNFCResponse", x);});
}
requestStartNFC Response data :
Clear Data
Sample return data will be here.
requestSendNFCCommand Response data :
Clear Data
Sample return data will be here.
Stop NFC
Only need to stop NFC when NFC is started but card is not presented
Request Stop NFC
View Sample Code
function stopNFCAccess() {
readerArgument = new MTMagneFlexParameter.readerParameter();
readerArgument.timeLimit = '1E';
readerArgument.hideUI = true;
requestArgument = new MTMagneFlexParameter.requestParameter();
requestArgument.operation = MagneFlexOp.REQUEST_STOP_NFC;
requestArgument.httpMethod = HTTPMethod.NONE;
requestArgument.closeDeviceAfter = false;
requestArgument.destinationURL = "";
MTMagneFlexLib.requestStopNFC(readerArgument, requestArgument, function (x) { setElemText("txtStopNFCResponse", x); });
}
requestStopNFC Response data :
Clear Data
Sample return data will be here.
Remove all listener and close device
Use this function to remove all Event Listener and close device.
stopNFCListener
View Sample Code
function stopNFCListener() {
MTMagneFlexLib.removeEventListener("*", userEventHandler);
}
Sample Request From JavaScript
Request Card Swipe
Use this function to request card swipe.
Request Swipe
Request Cancel Card Swipe
Card Swipe Event Message will be displayed here.
View Sample Code
function requestCardSwipe()
{
var readerParam = new MTMagneFlexParameter.readerParameter();
readerParam.timeLimit = '3c';
readerParam.endSession = true;
var requestParam = new MTMagneFlexParameter.requestParameter();
requestParam.operation = MagneFlexOp.REQUEST_CARD_SWIPE;
requestParam.httpMethod = HTTPMethod.NONE;
requestParam.customDisplayMessage = "";
requestParam.fullScreenMode = false;
requestParam.destinationURL = '';
requestParam.closeDeviceAfter = true;
MTMagneFlexLib.requestCardSwipe(readerParam, requestParam, event_CardSwipeCallback);
}
Sample return data will be here.
Command return data will be here.
Command return data will be here.
Request Smart Card Transaction
Use this function to start a Smart Card Transaction.
Transaction Type:
Request EMV Transaction
Request Cancel EMV Transaction
EMV Transaction Event Message will be displayed here.
View Sample Code
Refresh
function requestSmartCard() {
var readerParam = new MTMagneFlexParameter.readerParameter();
readerParam.timeLimit = '3C';
readerParam.endSession = "true";
readerParam.amount = txtTransactionAmount.value;
readerParam.cashBack = txtTransactionCashback.value;
readerParam.option = "00";
readerParam.currencyCode = "0840";
readerParam.cardType = "02";
readerParam.transactionType = "00";
readerParam.sendBatchData = "true";
readerParam.contact = chkReader_Contact.checked ? "true" : "false";
readerParam.contactless = chkReader_Contactless.checked ? "true" : "false";
readerParam.quickChipMode = chkTransactionType_QuickChip.checked ? "true" : "false";
var requestParam = new MTMagneFlexParameter.requestParameter();
requestParam.operation = MagneFlexOp.REQUEST_SMART_CARD_TRANSACTION;
requestParam.httpMethod = HTTPMethod.NONE;
requestParam.fullScreenMode = false;
requestParam.destinationURL = '';
requestParam.closeDeviceAfter = true;
MTMagneFlexLib.requestSmartCard(readerParam, requestParam, arcqDataCallBack, batchDataCallback, displayEMVMessageCallback);
}
Sample ARQC data return data will be here.
Sample Batch data return data will be here.
Request PIN
PINPAD only function
Use this function request PIN from PINPAD.
Request PIN
Request PIN Event Message will be displayed here.
View Sample Code
function requestPINEntry()
{
var readerParam = new MTMagneFlexParameter.readerParameter();
readerParam.endSession = true;
readerParam.timeLimit = "3C";
readerParam.fieldSeparator = "|";
readerParam.maxPinLength = "0C";
readerParam.minPinLength = "04";
readerParam.pinMode = "0";
readerParam.tone = "01";
readerParam.pinOption = "02";
var requestParam = new MTMagneFlexParameter.requestParameter();
requestParam.operation = MagneFlexOp.REQUEST_PIN_ENTRY;
requestParam.httpMethod = HTTPMethod.NONE;
requestParam.fullScreenMode = false;
requestParam.destinationURL = '';
requestParam.closeDeviceAfter = true;
MTMagneFlexLib.requestPinEntry(readerParam, requestParam, pinDataCallback);
}
Encrypted PIN Data will be displayed here.
Request Manual Card Entry
PINPAD only function
Use this function request Manual Card Entry from PINPAD.
Request Manual Entry
View Sample Code
function requestManualEntry()
{
var readerParam = new MTMagneFlexParameter.readerParameter();
readerParam.endSession = true;
readerParam.timeLimit = "3C";
readerParam.tone = "01";
readerParam.option = "08";
var requestParam = new MTMagneFlexParameter.requestParameter();
requestParam.operation = MagneFlexOp.REQUEST_MANUAL_CARD_ENTRY;
requestParam.httpMethod = HTTPMethod.NONE;
requestParam.fullScreenMode = false;
requestParam.destinationURL = '';
requestParam.closeDeviceAfter = true;
MTMagneFlexLib.requestManualEntry(readerParam, requestParam, manualCardDataCallback);
}
Encrypted Card Data will be displayed here.
Scanned Barcode Data will be displayed here.