Giter VIP home page Giter VIP logo

cordova-card-flight's People

Contributors

jackrr avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

zarly ajkolean

cordova-card-flight's Issues

Advice on usage

I'm wondering two things:

  1. What is the proper usage of this plugin?
  2. How to use the token with Stripe.

Here is my current flow/assumptions:

  1. Authorize
  2. Start Reader
  3. Listen for reader attach, connecting, connected
  4. Watch for swipe (have to set this part up for every new swipe)
  5. On card read - > tokenize last swipe.
    Result: I get a token.

Example code:

function runCordovaAuthorize() {
    cordova.plugins.cardFlight.authorize('key', 'key', function authSucc() {
        startReader();
    }, function authErr() {
        console.log('error!');
    });
}

function readerAttached() {
    cordova.plugins.cardFlight.onReaderAttached();
}

function readerConnecting() {
    cordova.plugins.cardFlight.onReaderConnecting();
}

function readerConnected() {
    cordova.plugins.cardFlight.onReaderConnected(function () {
        watchForSwipe();
    });
}

function swipeDetected() {
    cordova.plugins.cardFlight.onSwipeDetected();
}

function watchForSwipe() {
    cordova.plugins.cardFlight.watchForSwipe(function() {
        swipeDetected();
        onCardRead();
    });
}

function startReader() {
    cordova.plugins.cardFlight.startReader(function() {
        readerAttached();
        readerConnecting();
        readerConnected();
    });
}

function onCardRead() {
    cordova.plugins.cardFlight.onCardRead(function(data) {
        console.log('CARD READ', data); // gets here fine
        getData();
    });
}

function getData() {
    cordova.plugins.cardFlight.tokenizeLastSwipe(function(data) {
        console.log('HEY THIS IS THE DATA', data); // gets here fine but how do I use this token?
    }, function(err) {
        console.log('Error :(', err);
    });
}

runCordovaAuthorize();

Note: every time I want to set up a new swipe, I have to do watchForSwipe() again.

When providing each of the functions success callbacks they are reached no problem. Cool, everything seems to work.
So my questions are:

  • Is this flow correct?
  • How do I use the token from the getData() call with Stripe?
  • Is there a different way to get the card information?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.