Skip to content

Instantly share code, notes, and snippets.

@alininja
Created August 18, 2012 10:46
Show Gist options
  • Save alininja/3386038 to your computer and use it in GitHub Desktop.
Save alininja/3386038 to your computer and use it in GitHub Desktop.
Elavon Gateway :test_mode
#app/models/spree/gateway/elavon.rb
module Spree
class Gateway::Elavon < Gateway
preference :login, :string
preference :password, :string
preference :user, :string
attr_accessible :preferred_login, :preferred_password, :preferred_user
def provider_class
ActiveMerchant::Billing::ElavonGateway
end
end
end
require 'rubygems'
require 'active_merchant'
#= Elavon Virtual Merchant Gateway
#== Example use:
ActiveMerchant::Billing::Base.mode = :test
gateway = ActiveMerchant::Billing::ElavonGateway.new(
:login => "123456",#my_virtual_merchant_id
:password => "ABCDEF",#my_virtual_merchant_pin
:user => "123456" # optional,my_virtual_merchant_user_id
)
# set up credit card obj as in main ActiveMerchant example
creditcard = ActiveMerchant::Billing::CreditCard.new(
:brand => 'visa',
:number => '4111111111111111',
:month => 12,
:year => 2013,
:first_name => 'Bob',
:last_name => 'Bobsen',
:verification_value => '123'
)
options = {
:billing_address => {
:address1 => '123 rails road',
:zip => '91234'
},
:email => 'a@aa.com',
:test_mode => false
}
# run request
response = gateway.purchase(1000, creditcard, options) # authorize and capture 10 USD
puts response.success? # Check whether the transaction was successful
puts response.message # Retrieve the message returned by Elavon
puts response.authorization # Retrieve the unique transaction ID returned by Elavon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment