Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Sep 21st, 2012  |  syntax: None  |  size: 1.05 KB  |  hits: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. require 'rubygems'
  2. require 'active_merchant'
  3. #= Elavon Virtual Merchant Gateway
  4.  
  5. #== Example use:
  6.  
  7. ActiveMerchant::Billing::Base.mode = :test
  8.  
  9. gateway = ActiveMerchant::Billing::ElavonGateway.new(
  10. :login => "123456",#my_virtual_merchant_id
  11. :password => "ABCDEF",#my_virtual_merchant_pin
  12. :user => "123456" # optional,my_virtual_merchant_user_id
  13. )
  14.  
  15. # set up credit card obj as in main ActiveMerchant example
  16. creditcard = ActiveMerchant::Billing::CreditCard.new(
  17. :brand => 'visa',
  18. :number => '4111111111111111',
  19. :month => 12,
  20. :year => 2013,
  21. :first_name => 'Bob',
  22. :last_name => 'Bobsen',
  23. :verification_value => '123'
  24. )
  25.  
  26. options = {
  27. :billing_address => {
  28.   :address1 => '123 rails road',
  29.   :zip      => '91234'
  30. },
  31. :email    => 'a@aa.com',
  32. :test_mode => false
  33. }
  34.  
  35. # run request
  36. response = gateway.purchase(1000, creditcard, options) # authorize and capture 10 USD
  37.  
  38. puts response.success? # Check whether the transaction was successful
  39. puts response.message # Retrieve the message returned by Elavon
  40. puts response.authorization # Retrieve the unique transaction ID returned by Elavon