1

I downloaded this plugin Magnetic Card Reader thanks to my limited experience I'm having issues. I'm using a square 3.5mm card reader the plugin according to the author is suppose to work with 3.5mm card reader. I have this code to start the card reader according to the documentations.

$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!');
        }

    };

the problem is that after I click the $scope.start and then I proceed to swipe the credit card in the square card reader nothing happens.

I'm wondering what am I doing wrong? or if you guys know any other card reader plugin I can use.

Thank you :)

Millenial2020
  • 2,465
  • 9
  • 38
  • 83
  • Any error trace? cordova.js file included in HTML? Plugin code invoked inside deviceready event? – Gandhi May 13 '16 at 05:54

1 Answers1

0

I had written working code for this, Please Click Here, Currently it is perfectly working for Android, Soon I am going to release for IOS. If you still have any query, please comment below for your queries.

Sunil Kumar
  • 129
  • 1
  • 7