Created
December 12, 2010 21:25
-
-
Save cmhobbs/738342 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# convenience file for testing ActiveMerchant objects in | |
# IRB. See billing module and/or ActiveMerchant docs | |
# for creating a gateway and commiting a charge. | |
require 'rubygems' | |
require 'active_support/all' | |
require 'active_merchant' | |
include ActiveMerchant::Billing | |
ActiveMerchant::Billing::Base.mode = :test | |
# add your keys here | |
LOGIN = 'YOUR LOGIN HERE' | |
PASSWORD = 'HOWS ABOUT A PASSWORD' | |
TESTMODE = true | |
def newcard | |
# the credit card object. available testcards: | |
# - American Express Test Card: 370000000000002 | |
# - Discover Test Card: 6011000000000012 | |
# - Visa Test Card: 4007000000027 | |
# - Second Visa Test Card: 4012888818888 | |
# - JCB: 3088000000000017 | |
# - Diners Club/ Carte Blanche: 38000000000006 | |
ActiveMerchant::Billing::CreditCard.new( | |
:first_name => "Bob", | |
:last_name => "Dobbs", | |
:number => "4222222222222", | |
:month => "12", | |
:year => "2012", | |
:verification_value => "123") | |
end | |
def newaddress | |
# for billing_address or shipping_address | |
{ | |
:first_name => "Bob", | |
:last_name => "Dobbs", | |
:address1 => "123 Slack St.", | |
:city => "Subgeniusberg", :state => "CA", | |
:country => 'US', :zip => "90210" } | |
end | |
def amt | |
# set a price to charge (in cents) | |
return 100 | |
end | |
def newgateway | |
ActiveMerchant::Billing::AuthorizeNetGateway.new( | |
:login => LOGIN, | |
:password => PASSWORD, | |
:test => TESTMODE) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment