我下载了这个插件Magnetic Card Reader由于我的经验有限,我遇到了问题。我正在使用 square 3.5mm card reader根据作者的说法,该插件应该与 3.5mm 读卡器配合使用。我有这段代码可以根据文档启动读卡器。
$scope.start = function () {
function cardReaderStart(cardReadSuccess, cardReadFailure) {
console.log("Card reader started!");
window.plugins.CardReaderPlugin.start(cardReadSuccess, cardReadFailure);
}
// If OS is Android
function cardReadSuccess(response) {
console.log("Card number:" + response[0].card_number);
if (typeof response[0].expiry_month != 'undefined' && response[0].expiry_month != null) {
console.log("Expiry month:" + response[0].expiry_month);
}
if (typeof response[0].expiry_year != 'undefined' && response[0].expiry_year != null) {
console.log("Expiry month:" + response[0].expiry_year);
}
}
//If OS is iOS
function cardReadSuccess(response) {
console.log("Card number:" + response['card_number']);
if (typeof response[0].expiry_month != 'undefined' && response[0].expiry_month != null) {
console.log("Expiry month:" + response['expiry_month']);
}
if (typeof response[0].expiry_year != 'undefined' && response[0].expiry_year != null) {
console.log("Expiry month:" + response['expiry_year']);
}
}
function cardReadFailure() {
console.log('Please try again!');
}
};
问题是,当我单击 $scope.start 然后在方形读卡器中刷信用卡时,没有任何反应。
我想知道我做错了什么?或者如果你们知道我可以使用的任何其他读卡器插件。
谢谢:)
最佳答案
我已经为此编写了工作代码,请点击Here ,目前它在Android上完美运行,很快我将发布iOS版。如果您还有任何疑问,请在下面评论您的疑问。
关于javascript - Phonegap读卡器插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37197832/