Determine if a credit card is valid
edit Gemfile
gem 'activemerchant', '~> 1.31'
bundle install --local
Resolving dependencies...
Using rake 10.5.0
Using concurrent-ruby 1.0.1
Using i18n 0.7.0
Using minitest 5.3.3
Using thread_safe 0.3.5
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile2 2.0.0
Using json 1.8.3
Using nio4r 1.2.1
Using websocket-extensions 0.1.2
Using mime-types 2.99.1
Using arel 7.0.0
Using bcrypt 3.1.11
Using bundler 1.11.2
Using byebug 8.2.2
Using highline 1.7.8
Using net-ssh 3.0.2
Using coffee-script-source 1.10.0
Using execjs 2.6.0
Using method_source 0.8.2
Using thor 0.19.1
Using debug_inspector 0.0.2
Using multi_json 1.11.2
Using mysql2 0.4.3
Using pg 0.18.4
Using puma 3.1.0
Using qu 0.2.0 from source at `/home/rubys/git/qu-rails`
Using sass 3.4.21 from source at `/home/rubys/git/sass`
Using tilt 2.0.2
Using spring 1.6.4
Using sqlite3 1.3.11
Using tzinfo 1.2.2
Using nokogiri 1.6.7.2
Using rack 2.0.0.alpha
Using websocket-driver 0.6.3
Using mail 2.6.3
Using net-scp 1.2.1
Using net-sftp 2.1.2
Using net-ssh-gateway 1.2.0
Using coffee-script 2.4.1
Using uglifier 2.7.2
Using queue_classic 3.2.0.RC1 from source at `/home/rubys/git/queue_classic`
Using activesupport 5.0.0.beta3 from source at `/home/rubys/git/rails`
Using loofah 2.0.3
Using rack-test 0.6.3
Using sprockets 3.5.2
Using capistrano 2.15.7
Using rails-deprecated_sanitizer 1.0.3
Using globalid 0.3.6
Using activemerchant 1.58.0
Using activemodel 5.0.0.beta3 from source at `/home/rubys/git/rails`
Using jbuilder 2.4.1
Using rails-html-sanitizer 1.0.3
Using rvm-capistrano 1.5.6
Using rails-dom-testing 1.0.7
Using activejob 5.0.0.beta3 from source at `/home/rubys/git/rails`
Using activerecord 5.0.0.beta3 from source at `/home/rubys/git/rails`
Using actionview 5.0.0.beta3 from source at `/home/rubys/git/rails`
Using activemodel-serializers-xml 1.0.0
Using actionpack 5.0.0.beta3 from source at `/home/rubys/git/rails`
Using actioncable 5.0.0.beta3 from source at `/home/rubys/git/rails`
Using actionmailer 5.0.0.beta3 from source at `/home/rubys/git/rails`
Using railties 5.0.0.beta3 from source at `/home/rubys/git/rails`
Using sprockets-rails 3.0.4
Using coffee-rails 4.1.1
Using jquery-rails 4.1.0
Using jquery-ui-rails 5.0.5
Using qu-rails 0.2.0 from source at `/home/rubys/git/qu-rails`
Using web-console 3.1.1 from source at `/home/rubys/git/web-console`
Using rails 5.0.0.beta3 from source at `/home/rubys/git/rails`
Using sass-rails 5.0.4
Using turbolinks 3.0.0 from source at `/home/rubys/git/turbolinks`
Bundle complete! 22 Gemfile dependencies, 73 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
mkdir script
edit script/creditcard.rb
credit_card = ActiveMerchant::Billing::CreditCard.new(
number: '4111111111111111',
month: '8',
year: '2009',
first_name: 'Tobias',
last_name: 'Luetke',
verification_value: '123'
)
puts "Is #{credit_card.number} valid? #{credit_card.valid?}"
rails runner script/creditcard.rb
/home/rubys/.rvm/gems/ruby-2.2.3/gems/activemerchant-1.58.0/lib/active_merchant/billing/compatibility.rb:6:in `valid?': Implicit inclusion of Rails-specific functionality is deprecated. Explicitly require "active_merchant/billing/rails" if you need it.
Is 4111111111111111 valid? false