Class: ActiveMerchant::Billing::ElavonGateway

Inherits:
ViaklixGateway show all
Defined in:
lib/active_merchant/billing/gateways/elavon.rb

Overview

Elavon Virtual Merchant Gateway

Example use:

gateway = ActiveMerchant::Billing::ElavonGateway.new(
            :login     => "my_virtual_merchant_id",
            :password  => "my_virtual_merchant_pin",
            :user      => "my_virtual_merchant_user_id" # optional
         )

# set up credit card obj as in main ActiveMerchant example
creditcard = ActiveMerchant::Billing::CreditCard.new(
  :type       => 'visa',
  :number     => '41111111111111111',
  :month      => 10,
  :year       => 2011,
  :first_name => 'Bob',
  :last_name  => 'Bobsen'
)

# run request
response = gateway.purchase(1000, creditcard) # 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

Constant Summary

Constants inherited from ViaklixGateway

ViaklixGateway::APPROVED

Constants inherited from Gateway

Gateway::DEBIT_CARDS

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from ViaklixGateway

#credit, #initialize, #purchase

Methods inherited from Gateway

#card_brand, card_brand, inherited, #initialize, supports?, #test?

Methods included from Utils

generate_unique_id

Methods included from CreditCardFormatting

#format

Methods included from RequiresParameters

#requires!

Methods included from PostsData

included, #ssl_get, #ssl_post

Constructor Details

This class inherits a constructor from ActiveMerchant::Billing::ViaklixGateway

Instance Method Details

#authorize(money, creditcard, options = {}) ⇒ Object

Authorize a credit card for a given amount.

Parameters

  • money - The amount to be authorized as an Integer value in cents.

  • credit_card - The CreditCard details for the transaction.

  • options

    • :billing_address - The billing address for the cardholder.



55
56
57
58
59
60
61
62
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 55

def authorize(money, creditcard, options = {})
  form = {}
  add_invoice(form, options)
  add_creditcard(form, creditcard)        
  add_address(form, options)   
  add_customer_data(form, options)
  commit(:authorize, money, form)
end

#capture(money, authorization, options = {}) ⇒ Object

Capture authorized funds from a credit card.

Parameters

  • money - The amount to be captured as an Integer value in cents.

  • authorization - The approval code returned from the initial authorization.

  • options

    • :credit_card - The CreditCard details from the initial transaction (required).



71
72
73
74
75
76
77
78
79
80
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 71

def capture(money, authorization, options = {})
  requires!(options, :credit_card)
  
  form = {}
  add_reference(form, authorization)
  add_invoice(form, options)
  add_creditcard(form, options[:credit_card])
  add_customer_data(form, options)
  commit(:capture, money, form)
end