Class Index [+]

Quicksearch

ActiveMerchant::Billing::ElavonGateway

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

Public Instance Methods

authorize(money, creditcard, options = {}) click to toggle source

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.

    # File lib/active_merchant/billing/gateways/elavon.rb, line 56
56:       def authorize(money, creditcard, options = {})
57:         form = {}
58:         add_invoice(form, options)
59:         add_creditcard(form, creditcard)        
60:         add_address(form, options)   
61:         add_customer_data(form, options)
62:         commit(:authorize, money, form)
63:       end
capture(money, authorization, options = {}) click to toggle source

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).

    # File lib/active_merchant/billing/gateways/elavon.rb, line 72
72:       def capture(money, authorization, options = {})
73:         requires!(options, :credit_card)
74:         
75:         form = {}
76:         add_reference(form, authorization)
77:         add_invoice(form, options)
78:         add_creditcard(form, options[:credit_card])
79:         add_customer_data(form, options)
80:         commit(:capture, money, form)
81:       end

Private Instance Methods

add_address(form,options) click to toggle source
     # File lib/active_merchant/billing/gateways/elavon.rb, line 97
 97:       def add_address(form,options)
 98:         billing_address = options[:billing_address] || options[:address] 
 99:         
100:         if billing_address
101:           form[:avs_address]    = billing_address[:address1].to_s.slice(0, 30)
102:           form[:address2]       = billing_address[:address2].to_s.slice(0, 30)
103:           form[:avs_zip]        = billing_address[:zip].to_s.slice(0, 10)
104:           form[:city]           = billing_address[:city].to_s.slice(0, 30)
105:           form[:state]          = billing_address[:state].to_s.slice(0, 10)
106:           form[:company]        = billing_address[:company].to_s.slice(0, 50)
107:           form[:phone]          = billing_address[:phone].to_s.slice(0, 20)
108:           form[:country]        = billing_address[:country].to_s.slice(0, 50)
109:         end
110:                 
111:         if shipping_address = options[:shipping_address]
112:           first_name, last_name = parse_first_and_last_name(shipping_address[:name])
113:           form[:ship_to_first_name]     = first_name.to_s.slice(0, 20)
114:           form[:ship_to_last_name]      = last_name.to_s.slice(0, 30)
115:           form[:ship_to_address1]       = shipping_address[:address1].to_s.slice(0, 30)
116:           form[:ship_to_address2]       = shipping_address[:address2].to_s.slice(0, 30)
117:           form[:ship_to_city]           = shipping_address[:city].to_s.slice(0, 30)
118:           form[:ship_to_state]          = shipping_address[:state].to_s.slice(0, 10)
119:           form[:ship_to_company]        = shipping_address[:company].to_s.slice(0, 50)
120:           form[:ship_to_country]        = shipping_address[:country].to_s.slice(0, 50)
121:           form[:ship_to_zip]            = shipping_address[:zip].to_s.slice(0, 10)
122:         end
123:       end
add_reference(form, authorization) click to toggle source
    # File lib/active_merchant/billing/gateways/elavon.rb, line 84
84:       def add_reference(form, authorization)
85:         form[:approval_code] = authorization
86:       end
add_verification_value(form, creditcard) click to toggle source
    # File lib/active_merchant/billing/gateways/elavon.rb, line 92
92:       def add_verification_value(form, creditcard)
93:         form[:cvv2cvc2] = creditcard.verification_value 
94:         form[:cvv2cvc2_indicator] = '1'
95:       end
authorization_from(response) click to toggle source
    # File lib/active_merchant/billing/gateways/elavon.rb, line 88
88:       def authorization_from(response)
89:         response['approval_code']
90:       end
message_from(response) click to toggle source
     # File lib/active_merchant/billing/gateways/elavon.rb, line 125
125:       def message_from(response)
126:         success?(response) ? response['result_message'] : response['errorMessage']
127:       end
success?(response) click to toggle source
     # File lib/active_merchant/billing/gateways/elavon.rb, line 129
129:       def success?(response)
130:         !response.has_key?('errorMessage')
131:       end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.