Agile Web Development with Rails, Edition 4

26.1.2 Asset Packager 25.2 rake

26.1 Active Merchant

Determine if a credit card is valid

edit Gemfile
gem 'activemerchant', '~> 1.10.0'
bundle install --local
Resolving dependencies...
Using rake (10.1.1)
Using abstract (1.0.0)
Using activesupport (3.0.20) from source at /home/rubys/git/rails
Using builder (2.1.2)
Using i18n (0.5.3)
Using activemodel (3.0.20) from source at /home/rubys/git/rails
Using erubis (2.6.6)
Using rack (1.2.8)
Using rack-mount (0.6.14)
Using rack-test (0.5.7)
Using tzinfo (0.3.38)
Using actionpack (3.0.20) from source at /home/rubys/git/rails
Using mime-types (1.25.1)
Using polyglot (0.3.3)
Using treetop (1.4.15)
Using mail (2.2.20)
Using actionmailer (3.0.20) from source at /home/rubys/git/rails
Using braintree (2.28.0)
Using activemerchant (1.10.0)
Using arel (2.0.10)
Using activerecord (3.0.20) from source at /home/rubys/git/rails
Using activeresource (3.0.20) from source at /home/rubys/git/rails
Using bundler (1.5.2)
Using highline (1.6.20)
Using net-ssh (2.8.0)
Using net-scp (1.1.2)
Using net-sftp (2.1.2)
Using net-ssh-gateway (1.2.0)
Using capistrano (2.15.5)
Using json (1.8.1)
Using mysql (2.9.1)
Using rdoc (3.12.2)
Using thor (0.14.6)
Using railties (3.0.20) from source at /home/rubys/git/rails
Using rails (3.0.20) from source at /home/rubys/git/rails
Using rvm-capistrano (1.5.1)
Using sqlite3 (1.3.8)
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
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
[deprecated] I18n.enforce_available_locales will default to true in the future. If you really want to skip validation of your locale you can set I18n.enforce_available_locales = false to avoid this message.
Is 4111111111111111 valid?  false

26.1.2 Asset Packager 25.2 rake