Determine if a credit card is valid
edit Gemfile
gem 'activemerchant', '~> 1.31'
bundle install --local
Resolving dependencies...
Using rake 10.4.2
Using i18n 0.7.0
Using json 1.8.2
Using minitest 5.5.1
Using thread_safe 0.3.5
Using tzinfo 1.2.2
Using activesupport 5.0.0.alpha from source at /home/rubys/git/rails
Using builder 3.2.2
Using erubis 2.7.0
Using mini_portile 0.6.2
Using nokogiri 1.6.6.2
Using rails-deprecated_sanitizer 1.0.3
Using rails-dom-testing 1.0.6
Using loofah 2.0.1
Using rails-html-sanitizer 1.0.2
Using actionview 5.0.0.alpha from source at /home/rubys/git/rails
Using rack 1.6.0
Using rack-test 0.6.3
Using actionpack 5.0.0.alpha from source at /home/rubys/git/rails
Using globalid 0.3.3
Using activejob 5.0.0.alpha from source at /home/rubys/git/rails
Using mime-types 2.4.3
Using mail 2.6.3.edge from source at /home/rubys/git/mail
Using actionmailer 5.0.0.alpha from source at /home/rubys/git/rails
Using activemerchant 1.47.0
Using activemodel 5.0.0.alpha from source at /home/rubys/git/rails
Using arel 7.0.0.alpha from source at /home/rubys/git/arel
Using activerecord 5.0.0.alpha from source at /home/rubys/git/rails
Using bcrypt 3.1.10
Using debug_inspector 0.0.2
Using binding_of_caller 0.7.2
Using bundler 1.9.1
Using columnize 0.9.0
Using byebug 4.0.4
Using highline 1.7.1
Using net-ssh 2.9.2
Using net-scp 1.2.1
Using net-sftp 2.1.2
Using net-ssh-gateway 1.2.0
Using capistrano 2.15.5
Using coffee-script-source 1.9.1
Using execjs 2.4.0
Using coffee-script 2.3.0
Using method_source 0.8.2
Using thor 0.19.1
Using railties 5.0.0.alpha from source at /home/rubys/git/rails
Using coffee-rails 4.1.0 from source at /home/rubys/git/coffee-rails
Using hike 1.2.3
Using multi_json 1.11.0
Using jbuilder 2.2.12
Using jquery-rails 4.0.3 from source at /home/rubys/git/jquery-rails
Using jquery-ui-rails 5.0.3
Using mysql2 0.3.18
Using qu 0.2.0 from source at /home/rubys/git/qu-rails
Using qu-rails 0.2.0 from source at /home/rubys/git/qu-rails
Using tilt 1.4.1
Using sprockets 2.12.3
Using sprockets-rails 2.2.4
Using rails 5.0.0.alpha from source at /home/rubys/git/rails
Using rvm-capistrano 1.5.6
Using sass 3.4.13
Using sass-rails 5.0.2
Using spring 1.3.3
Using sqlite3 1.3.10
Using turbolinks 2.5.3
Using uglifier 2.7.1
Using web-console 2.1.2
Bundle complete! 19 Gemfile dependencies, 67 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
DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can access the original method using super. (called from rescue in <class:Exception> at /home/rubys/.rvm/gems/ruby-head-n50123/gems/web-console-2.1.2/lib/web_console/integration/cruby.rb:37)
/home/rubys/.rvm/gems/ruby-head-n50123/gems/activemerchant-1.47.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