.controller('paymentsController', function ($scope, $localStorage, $log, $state, $window, $ionicModal, Payment, ItemList, SweetAlert) {
$scope.scanCard = function(){
var cardIOResponseFields = [
"card_type",
"redacted_card_number",
"card_number",
"expiry_month",
"expiry_year",
"cvv",
"zip"
];
var onCardIOComplete = function(response) {
for (var i = 0, len = cardIOResponseFields.length; i < len; i++) {
var field = cardIOResponseFields[i];
console.log(field + ": " + response[field]);
}
};
var onCardIOCancel = function() {
console.log("card.io scan cancelled");
};
var onCardIOCheck = function (canScan) {
console.log("card.io canScan? " + canScan);
var scanBtn = angular.element($("#scanBtn")).scope();
//var scanBtn = document.getElementById("scanBtn");
if (!canScan) {
scanBtn.innerHTML = "Manual entry";
}
};
CardIO.scan({
"collect_expiry": true,
"collect_cvv": false,
"collect_zip": false,
"shows_first_use_alert": true,
"disable_manual_entry_buttons": false
},
onCardIOComplete,
onCardIOCancel
);
CardIO.canScan(onCardIOCheck);
};
} 我在我的phonegap中安装了一个读卡器插件(我使用离子作为框架)我遇到的问题是该插件无法正常工作。这是我使用https://github.com/card-io/card.io-iOS-SDK-PhoneGap的插件。
这是我的观点。
<button id="scanBtn" ng-click="scanCard()" class="button button-large button-block button-light">Scan Card</button>
当用户点击#scanBtn时,它会加载此脚本。
var cardIOResponseFields = [
"card_type",
"redacted_card_number",
"card_number",
"expiry_month",
"expiry_year",
"cvv",
"zip"
];
var onCardIOComplete = function(response) {
for (var i = 0, len = cardIOResponseFields.length; i < len; i++) {
var field = cardIOResponseFields[i];
console.log(field + ": " + response[field]);
}
};
var onCardIOCancel = function() {
console.log("card.io scan cancelled");
};
var onCardIOCheck = function (canScan) {
console.log("card.io canScan? " + canScan);
var scanBtn = angular.element($("#scanBtn")).scope();
//var scanBtn = document.getElementById("scanBtn");
if (!canScan) {
scanBtn.innerHTML = "Manual entry";
}
};
CardIO.scan({
"collect_expiry": true,
"collect_cvv": false,
"collect_zip": false,
"shows_first_use_alert": true,
"disable_manual_entry_buttons": false
},
onCardIOComplete,
onCardIOCancel
);
CardIO.canScan(onCardIOCheck);
};
我的应用程序无法在我的浏览器中工作或使用phonegap应用程序,但是当我启动离子模拟器时,只显示输入卡片表单的条目并且没有相机加载来扫描卡片,这导致我相信相机执行失败。
在我的浏览器上加载有氧运动时,我收到以下控制台错误: ReferenceError:未定义CardIO。
答案 0 :(得分:1)
在设备上尝试相同的操作。
我在浏览器上遇到了同样的错误,它在设备上运行良好。您可以将此视为相机/或联系人选择器插件 - 它仅适用于设备 - 而不是在SIM或浏览器上。
答案 1 :(得分:0)
在浏览器或模拟器上运行时,所有cordova插件都会出错。始终在设备上和内部使用它们
$ionicPlatform.ready(function() { ... });