Class: ActiveMerchant::Billing::ElavonGateway

Inherits:
Gateway
  • Object
show all
Includes:
Empty
Defined in:
lib/active_merchant/billing/gateways/elavon.rb

Constant Summary

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#add_field_to_post_if_present, #add_fields_to_post_if_present, #card_brand, card_brand, #generate_unique_id, inherited, #supported_countries, supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #test?

Methods included from CreditCardFormatting

#expdate, #format, #strftime_yyyymm

Methods included from PostsData

included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request

Constructor Details

#initialize(options = {}) ⇒ ElavonGateway

Returns a new instance of ElavonGateway.



35
36
37
38
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 35

def initialize(options = {})
  requires!(options, :login, :password)
  super
end

Instance Method Details

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



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 60

def authorize(money, payment_method, options = {})
  request = build_xml_request do |xml|
    xml.ssl_vendor_id         @options[:ssl_vendor_id] || options[:ssl_vendor_id]
    xml.ssl_transaction_type  self.actions[:authorize]
    xml.ssl_amount            amount(money)
    add_salestax(xml, options)
    add_invoice(xml, options)
    add_payment(xml, payment_method, options)
    add_currency(xml, money, options)
    add_address(xml, options)
    add_customer_email(xml, options)
    add_test_mode(xml, options)
    add_ip(xml, options)
    add_auth_purchase_params(xml, payment_method, options)
    add_level_3_fields(xml, options) if options[:level_3_data]
  end
  commit(request)
end

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



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 79

def capture(money, authorization, options = {})
  request = build_xml_request do |xml|
    xml.ssl_vendor_id         @options[:ssl_vendor_id] || options[:ssl_vendor_id]

    if options[:credit_card]
      xml.ssl_transaction_type self.actions[:capture]
      xml.ssl_amount amount(money)
      add_salestax(xml, options)
      add_approval_code(xml, authorization)
      add_invoice(xml, options)
      add_creditcard(xml, options[:credit_card], options)
      add_currency(xml, money, options)
      add_address(xml, options)
      add_customer_email(xml, options)
      add_test_mode(xml, options)
    else
      xml.ssl_transaction_type self.actions[:capture_complete]
      xml.ssl_amount amount(money)
      add_currency(xml, money, options)
      add_txn_id(xml, authorization)
      add_partial_shipment_flag(xml, options)
      add_test_mode(xml, options)
    end
  end
  commit(request)
end

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

Raises:

  • (ArgumentError)


128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 128

def credit(money, creditcard, options = {})
  raise ArgumentError, 'Reference credits are not supported. Please supply the original credit card or use the #refund method.' if creditcard.is_a?(String)

  request = build_xml_request do |xml|
    xml.ssl_vendor_id         @options[:ssl_vendor_id] || options[:ssl_vendor_id]
    xml.ssl_transaction_type  self.actions[:credit]
    xml.ssl_amount            amount(money)
    add_invoice(xml, options)
    add_creditcard(xml, creditcard, options)
    add_currency(xml, money, options)
    add_address(xml, options)
    add_customer_email(xml, options)
    add_test_mode(xml, options)
  end
  commit(request)
end

#purchase(money, payment_method, options = {}) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 40

def purchase(money, payment_method, options = {})
  request = build_xml_request do |xml|
    xml.ssl_vendor_id         @options[:ssl_vendor_id] || options[:ssl_vendor_id]
    xml.ssl_transaction_type  self.actions[:purchase]
    xml.ssl_amount            amount(money)

    add_payment(xml, payment_method, options)
    add_invoice(xml, options)
    add_salestax(xml, options)
    add_currency(xml, money, options)
    add_address(xml, options)
    add_customer_email(xml, options)
    add_test_mode(xml, options)
    add_ip(xml, options)
    add_auth_purchase_params(xml, payment_method, options)
    add_level_3_fields(xml, options) if options[:level_3_data]
  end
  commit(request)
end

#refund(money, identification, options = {}) ⇒ Object



106
107
108
109
110
111
112
113
114
115
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 106

def refund(money, identification, options = {})
  request = build_xml_request do |xml|
    xml.ssl_vendor_id         @options[:ssl_vendor_id] || options[:ssl_vendor_id]
    xml.ssl_transaction_type  self.actions[:refund]
    xml.ssl_amount            amount(money)
    add_txn_id(xml, identification)
    add_test_mode(xml, options)
  end
  commit(request)
end

#scrub(transcript) ⇒ Object



188
189
190
191
192
193
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 188

def scrub(transcript)
  transcript.
    gsub(%r((<ssl_pin>)(.*)(</ssl_pin>)), '\1[FILTERED]\3').
    gsub(%r((<ssl_card_number>)(.*)(</ssl_card_number>)), '\1[FILTERED]\3').
    gsub(%r((<ssl_cvv2cvc2>)(.*)(</ssl_cvv2cvc2>)), '\1[FILTERED]\3')
end

#store(creditcard, options = {}) ⇒ Object



157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 157

def store(creditcard, options = {})
  request = build_xml_request do |xml|
    xml.ssl_vendor_id         @options[:ssl_vendor_id] || options[:ssl_vendor_id]
    xml.ssl_transaction_type  self.actions[:store]
    xml.ssl_add_token 'Y'
    add_creditcard(xml, creditcard, options)
    add_address(xml, options)
    add_customer_email(xml, options)
    add_test_mode(xml, options)
    add_verification(xml, options)
  end
  commit(request)
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


184
185
186
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 184

def supports_scrubbing?
  true
end

#update(token, creditcard, options = {}) ⇒ Object



171
172
173
174
175
176
177
178
179
180
181
182
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 171

def update(token, creditcard, options = {})
  request = build_xml_request do |xml|
    xml.ssl_vendor_id         @options[:ssl_vendor_id] || options[:ssl_vendor_id]
    xml.ssl_transaction_type  self.actions[:update]
    xml.ssl_token token
    add_creditcard(xml, creditcard, options)
    add_address(xml, options)
    add_customer_email(xml, options)
    add_test_mode(xml, options)
  end
  commit(request)
end

#verify(credit_card, options = {}) ⇒ Object



145
146
147
148
149
150
151
152
153
154
155
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 145

def verify(credit_card, options = {})
  request = build_xml_request do |xml|
    xml.ssl_vendor_id         @options[:ssl_vendor_id] || options[:ssl_vendor_id]
    xml.ssl_transaction_type  self.actions[:verify]
    add_creditcard(xml, credit_card, options)
    add_address(xml, options)
    add_test_mode(xml, options)
    add_ip(xml, options)
  end
  commit(request)
end

#void(identification, options = {}) ⇒ Object



117
118
119
120
121
122
123
124
125
126
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 117

def void(identification, options = {})
  request = build_xml_request do |xml|
    xml.ssl_vendor_id         @options[:ssl_vendor_id] || options[:ssl_vendor_id]
    xml.ssl_transaction_type  self.actions[:void]

    add_txn_id(xml, identification)
    add_test_mode(xml, options)
  end
  commit(request)
end