Git Product home page Git Product logo

conektamotion's Introduction

ConektaMotion

A Rubymotion gem to help you to tokenize a Bank Card with mexican payment gateway Conekta. This gem is intended to be used with Rubymotion.

Install

  1. gem install conekta-motion
  2. require 'conekta-motion' or add to your Gemfile (gem 'conekta-motion')
  3. rake pod:install

This library depends on AFMotion which is wrapper for AFNetworking.

Usage

ConektaMotion::Card object helps you to collect Bank Card information and perform basic validations before anything is sent via SSL to Conekta.io.

card = CM::Card.new '4242 4242 4242 4242', 'Juan Perez', '090', '02', '18'

All arguments for Card need to be string. Arguments on Card initialization are: number, name, cvc, expiration_month and expiration_year.

Card has a #valid? method that returns true or false base on Bank Card info validation. Validations at this point are related to have required arguments and card number to pass Luhn algorithm.

card.valid?
=> false

If card validation failed then Card's method #error will have detailed information on what is the problem. #error returns a Hash.

In order to send Bank Card information to Conekta.io and get a token that represent that card you must use ConektaMotion::Conekta object.

conekta = CM:Conekta.new API_KEY # this constant needs to be set with Conekta.io API's key.
conekta.tokenize_card card do |token|
  @token = token
end

token is an object from class ConektaMotion::Token. If card was tokenized correctly then #token_id will have the token returned by Conekta.io. If tokenization failed, you must check #error to get the message returned by Conekta.io

conekta.tokenize_card card do |token|
  if token.valid?
    puts "This is your token: #{token.token_id}"
  esle
    puts "We have an error: #{token.error}
  end
end

Sample project

A sample project is included in sample directory.

Bugs and feedback

Use issues at Github to report bugs or give feedback.

Copyright © 2015 Mario Alberto Chávez. This project uses MIT-LICENSE.

conektamotion's People

Contributors

mariochavez avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  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.