Determine if a credit card is valid
edit Gemfile
gem 'activemerchant', '~> 1.31'
bundle install
Resolving dependencies...
Using rake (10.0.4)
Using i18n (0.6.4)
Using minitest (4.7.3)
Using multi_json (1.7.2)
Using atomic (1.1.8)
Using thread_safe (0.1.0)
Using tzinfo (0.3.37)
Using activesupport (4.0.0.beta1) from source at /home/rubys/git/rails
Using builder (3.1.4)
Using erubis (2.7.0)
Using rack (1.5.2)
Using rack-test (0.6.2)
Using actionpack (4.0.0.beta1) from source at /home/rubys/git/rails
Using mime-types (1.23)
Using polyglot (0.3.3)
Using treetop (1.4.12)
Using mail (2.5.3)
Using actionmailer (4.0.0.beta1) from source at /home/rubys/git/rails
Using active_utils (1.0.5)
Using json (1.7.7)
Using money (5.1.1)
Using nokogiri (1.5.9)
Using activemerchant (1.32.1)
Using activemodel (4.0.0.beta1) from source at /home/rubys/git/rails
Using activerecord-deprecated_finders (1.0.1)
Using arel (4.0.0.20130418133826) from source at /home/rubys/git/arel
Using activerecord (4.0.0.beta1) from source at /home/rubys/git/rails
Using bcrypt-ruby (3.0.1)
Using bundler (1.3.5)
Using highline (1.6.18)
Using net-ssh (2.6.7)
Using net-scp (1.1.0)
Using net-sftp (2.1.1)
Using net-ssh-gateway (1.2.0)
Using capistrano (2.15.3)
Using coffee-script-source (1.6.2)
Using execjs (1.4.0)
Using coffee-script (2.2.0)
Using thor (0.18.1)
Using railties (4.0.0.beta1) from source at /home/rubys/git/rails
Using coffee-rails (4.0.0) from source at /home/rubys/git/coffee-rails
Using hike (1.2.2)
Using jbuilder (1.0.2)
Using jquery-rails (2.2.1)
Using mysql2 (0.3.11)
Using tilt (1.3.7)
Using sprockets (2.9.3)
Using sprockets-rails (2.0.0.rc4) from source at /home/rubys/git/sprockets-rails
Using rails (4.0.0.beta1) from source at /home/rubys/git/rails
Using rdoc (3.12.2)
Using rvm-capistrano (1.3.0)
Using sass (3.2.8)
Using sass-rails (4.0.0.rc1) from source at /home/rubys/git/sass-rails
Using sdoc (0.3.20)
Using sqlite3 (1.3.7)
Using turbolinks (1.1.1)
Using uglifier (2.0.1)
Your bundle is complete!
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
Is 4111111111111111 valid? false