Created
April 28, 2010 03:19
-
-
Save teeparham/381679 to your computer and use it in GitHub Desktop.
Rake task to configure Spree Authorize.net gateway
This file contains hidden or 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
# rake yoursite:setup_gateway | |
namespace :yoursite | |
desc "Set up gateway" | |
task :setup_gateway => :environment do | |
Gateway.transaction do | |
auth_net = "Authorize.net" | |
gateway = Gateway.find_by_name_and_environment(auth_net, RAILS_ENV) | |
gateway.destroy unless gateway.nil? | |
gateway = Gateway::AuthorizeNet.create( | |
:name => auth_net, | |
:environment => RAILS_ENV, | |
:description => auth_net, | |
:test_mode => "false", | |
:active => "true", | |
:server => (RAILS_ENV == "production") ? "live" : "test" | |
) | |
if RAILS_ENV == "production" | |
gateway.set_preference(:login, "-- your production key --") | |
gateway.set_preference(:password, "-- your production password --") | |
else | |
gateway.set_preference(:login, "-- your test key --") | |
gateway.set_preference(:password, "-- your test password --") | |
end | |
gateway.save! | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment