卡 IO phonegap 插件不工作

Card IO phonegap plugin is not working

  .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 中安装了一个 card reader 插件(我使用 ionic 作为框架)我遇到的问题是该插件不起作用。这是我正在使用的插件 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 应用程序,但是当我启动 ionic 模拟器时,只显示输入卡片表单的条目,并且没有加载相机来扫描卡片,这导致我相信相机执行失败。

在我的浏览器上加载有氧运动时,出现以下控制台错误: ReferenceError:未定义 CardIO。

在设备上进行同样的尝试。

我在浏览器上遇到了同样的错误,但它在设备上运行良好。您可以将其视为相机/或联系人选择器插件 - 只能在设备上使用 - 而不能在 sim 卡或浏览器上使用。

所有 cordova 插件在浏览器或模拟器上 运行 时都会抛出错误。始终在设备上和内部使用它们

$ionicPlatform.ready(function() { ... });