Coder Social home page Coder Social logo

gusfravo / conekta.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from enriquevg/conekta.js

0.0 1.0 0.0 1.15 MB

Tokenization and card validators for Conekta.io

Home Page: https://www.conekta.io/docs/

License: MIT License

JavaScript 73.21% HTML 3.14% CoffeeScript 23.65%

conekta.js's Introduction

alt tag

Conekta.JS 0.5.0

Conekta.js allow you create token with card details on your web apps, by preventing sensitive card data from hitting your server(More information, read PCI compliance).

Install

$ bower install conekta.js --save

Usage

Basic initialization

On your html, before body tag close, include jquery and conekta

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<script type="text/javascript" src="https://conektaapi.s3.amazonaws.com/v0.5.0/js/conekta.js"></script>

Set your public key

Conekta.setPublicKey('key_KJysdbf6PotS2ut2');

Advanced initialization

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

<script type="text/javascript" data-conekta-public-key="key_KJysdbf6PotS2ut2" src="https://conektaapi.s3.amazonaws.com/v0.5.0/js/conekta.js"></script>

Tokenize Card

Tokenize via json

var data = {
  "card": {
    "number": "4242424242424242",
    "name": "Javier Pedreiro",
    "exp_year": "2018",
    "exp_month": "12",
    "cvc": "123"
  }
};

var successHandler = function(token) {
  /* token keys: id, livemode, used, object */
  console.log(token);
};

var errorHandler = function(err) {
  /* err keys: object, type, message, message_to_purchaser, param, code */
  console.log(err);
};

Conekta.Token.create(data, successHandler, errorHandler);

Tokenize via form

<form action="" method="post" id="card-form">
  <span class="card-errors"></span>
  <div class="form-row">
    <label>
      <span>Nombre del tarjetahabiente</span>
      <input type="text" size="20" data-conekta="card[name]"/>
    </label>
  </div>
  <div class="form-row">
    <label>
      <span>Número de tarjeta de crédito</span>
      <input type="text" size="20" data-conekta="card[number]"/>
    </label>
  </div>
  <div class="form-row">
    <label>
      <span>CVC</span>
      <input type="text" size="4" data-conekta="card[cvc]"/>
    </label>
  </div>
  <div class="form-row">
    <label>
      <span>Fecha de expiración (MM/AAAA)</span>
      <input type="text" size="2" data-conekta="card[exp_month]"/>
    </label>
    <span>/</span>
    <input type="text" size="4" data-conekta="card[exp_year]"/>
  </div>
  <button type="submit">Tokenizar!</button>
</form>
var successHandler = function(token) {
  /* token keys: id, livemode, used, object */
  console.log(token);
};

var errorHandler = function(err) {
  /* err keys: object, type, message, message_to_purchaser, param, code */
  console.log(err);
};

Conekta.Token.create($('#card-form'), successHandler, errorHandler);

Documentation

Please see https://www.conekta.io/docs/api for up-to-date documentation.

Library Development and Testing

If you wish to make a pull request you can build and test your changes:

#build
grunt

#test
npm test

To expedite the process you can use a docker with the library and environment preloaded:

docker pull conekta/conekta.js

docker run -ti conekta/conekta.js /bin/bash --login

License

Developed by Conekta. Available with MIT License.

We are hiring

If you are a comfortable working with a range of backend languages (Java, Python, Ruby, PHP, etc) and frameworks, you have solid foundation in data structures, algorithms and software design with strong analytical and debugging skills. Send your CV, github to [email protected]

conekta.js's People

Contributors

leofischer avatar ericksoun avatar netmask avatar julsdelatierra avatar richpeniche avatar andresaraujo avatar

Watchers

Gustavo Efrain Solano Perez avatar

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.