Thursday, July 9, 2009

Check Whether a test Credit Card is working.,

require 'rubygems'
require 'active_merchant'

# Use the TrustCommerce test servers
ActiveMerchant::Billing::Base.mode = :test

# ActiveMerchant accepts all amounts as Integer values in cents
# $10.00
amount = 1000

# The card verification value is also known as CVV2, CVC2, or CID
credit_card = ActiveMerchant::Billing::CreditCard.new(
:first_name => 'Bob',
:last_name => 'Bobsen',
:number => '349298720353895',
:month => '8',
:year => '2012',
:verification_value => '1234'
)

puts credit_card.valid?

No comments: