All Projects â†’ didww â†’ Credit_card_validations

didww / Credit_card_validations

Licence: mit
💳 ruby gem for validating credit card numbers, generating valid numbers, luhn checks

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Credit card validations

frames-android
Checkout API Client, Payment Form UI and Utilities
Stars: ✭ 26 (-81.43%)
Mutual labels:  validation, credit-card
Credit Card
Credit Card Validation
Stars: ✭ 150 (+7.14%)
Mutual labels:  validation, credit-card
Spree
Open Source headless multi-language/multi-currency/multi-store eCommerce platform
Stars: ✭ 11,571 (+8165%)
Mutual labels:  e-commerce, rails
Email inquire
Validate email for common typos and one-time email providers
Stars: ✭ 257 (+83.57%)
Mutual labels:  validation, rails
Creditcard.js
A simple credit cards validation library in JavaScript
Stars: ✭ 259 (+85%)
Mutual labels:  validation, credit-card
Pycard
A simple credit card validation Python library with no dependencies
Stars: ✭ 40 (-71.43%)
Mutual labels:  validation, credit-card
Mfcard
Easily integrate Credit Card payments module in iOS App. Swift 4.0
Stars: ✭ 356 (+154.29%)
Mutual labels:  validation, credit-card
Validates timeliness
Date and time validation plugin for ActiveModel and Rails. Supports multiple ORMs and allows custom date/time formats.
Stars: ✭ 1,319 (+842.14%)
Mutual labels:  validation, rails
Requirements
PowerShell framework for declaratively defining and idempotently imposing system configurations
Stars: ✭ 134 (-4.29%)
Mutual labels:  validation
Spotlight
Spotlight enables librarians, curators, and others who are responsible for digital collections to create attractive, feature-rich websites that highlight these collections.
Stars: ✭ 137 (-2.14%)
Mutual labels:  rails
Vuelidate Error Extractor
Vuelidate form-group helper that extracts errors easily.
Stars: ✭ 133 (-5%)
Mutual labels:  validation
Aura.filter
Validate and sanitize arrays and objects.
Stars: ✭ 134 (-4.29%)
Mutual labels:  validation
Actioncable Vue
A Vue plugin that makes integrating Rails Action Cable dead-easy.
Stars: ✭ 138 (-1.43%)
Mutual labels:  rails
Super module
SuperModule allows defining class methods and method invocations the same way a super class does without using def included(base). This also succeeds ActiveSupport::Concern by offering lighter syntax
Stars: ✭ 133 (-5%)
Mutual labels:  rails
Octopus
Scala library for boilerplate-free validation
Stars: ✭ 138 (-1.43%)
Mutual labels:  validation
Pwa
Progressive Web Apps for Rails
Stars: ✭ 133 (-5%)
Mutual labels:  rails
Php Banks Db
PHP library for getting bank info (name, brand color etc) by first digits of card's number
Stars: ✭ 133 (-5%)
Mutual labels:  credit-card
Redis web manager
Manage your Redis instance (see keys, memory used, connected client, etc...)
Stars: ✭ 139 (-0.71%)
Mutual labels:  rails
Node Convict
Featureful configuration management library for Node.js
Stars: ✭ 1,855 (+1225%)
Mutual labels:  validation
Kaiju
A drag and drop web editor for React components.
Stars: ✭ 135 (-3.57%)
Mutual labels:  rails

CreditCardValidations

Build Status Coverage Status Gem Version License

Gem adds validator to check whether or not a given number actually falls within the ranges of possible numbers prior to performing such verification, and, as such, CreditCardValidations simply verifies that the credit card number provided is well-formed.

More info about card BIN numbers http://en.wikipedia.org/wiki/Bank_card_number

Installation

Add this line to your application's Gemfile:

$ gem 'credit_card_validations'

And then execute:

$ bundle

Or install it yourself as:

$ gem install credit_card_validations

Usage

The following issuing institutes are accepted:

Name Key
American Express :amex
China UnionPay :unionpay
Dankort :dankort
Diners Club :diners
Elo :elo
Discover :discover
Hipercard :hipercard
JCB :jcb
Maestro :maestro
MasterCard :mastercard
MIR :mir
Rupay :rupay
Solo :solo
Switch :switch
Visa :visa

The following are supported with plugins

Name Key
Diners Club US :diners_us
EnRoute :en_route
Laser :laser

Examples using string monkey patch

require 'credit_card_validations/string'
'5274 5763 9425 9961'.credit_card_brand   #=> :mastercard
'5274 5763 9425 9961'.credit_card_brand_name   #=> "MasterCard"
'5274 5763 9425 9961'.valid_credit_card_brand?(:mastercard, :visa) #=> true
'5274 5763 9425 9961'.valid_credit_card_brand?(:amex) #=> false
'5274 5763 9425 9961'.valid_credit_card_brand?('MasterCard') #=> true

ActiveModel support

only for certain brands

class CreditCardModel
  attr_accessor :number
  include ActiveModel::Validations
  validates :number, credit_card_number: {brands: [:amex, :maestro]}
end

for all known brands

validates :number, presence: true, credit_card_number: true

Examples using CreditCardValidations::Detector class

number = "4111111111111111"
detector = CreditCardValidations::Detector.new(number)
detector.brand #:visa
detector.visa? #true
detector.valid?(:mastercard,:maestro) #false
detector.valid?(:visa, :mastercard) #true
detector.issuer_category  #"Banking and financial"

Also You can add your own brand rules to detect other credit card brands/types

passing name,length(integer/array of integers) and prefix(string/array of strings) Example

CreditCardValidations.add_brand(:voyager, {length: 15, prefixes: '86'})
voyager_test_card_number = '869926275400212'
CreditCardValidations::Detector.new(voyager_test_card_number).brand #:voyager
CreditCardValidations::Detector.new(voyager_test_card_number).voyager? #true

Remove brands also supported

CreditCardValidations::Detector.delete_brand(:maestro)

Check luhn

CreditCardValidations::Detector.new(@credit_card_number).valid_luhn?
#or
CreditCardValidations::Luhn.valid?(@credit_card_number)

Generate credit card numbers that pass validation

CreditCardValidations::Factory.random(:amex)
# => "348051773827666"
CreditCardValidations::Factory.random(:maestro)
# => "6010430241237266856"

Plugins

require 'credit_card_validations/plugins/en_route'
require 'credit_card_validations/plugins/laser'
require 'credit_card_validations/plugins/diners_us'

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].