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

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, creditcard, options = {}) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 65

def authorize(money, 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[:authorize]
    xml.ssl_amount            amount(money)

    add_salestax(xml, options)
    add_invoice(xml, options)
    add_creditcard(xml, creditcard)
    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, options)
    add_level_3_fields(xml, options) if options[:level_3_data]
  end
  commit(request)
end

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



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 85

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


134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 134

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)
    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
59
60
61
62
63
# 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)

    if payment_method.is_a?(String)
      add_token(xml, payment_method)
    else
      add_creditcard(xml, payment_method)
    end

    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, options)
    add_level_3_fields(xml, options) if options[:level_3_data]
  end
  commit(request)
end

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



112
113
114
115
116
117
118
119
120
121
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 112

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



194
195
196
197
198
199
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 194

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



163
164
165
166
167
168
169
170
171
172
173
174
175
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 163

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


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

def supports_scrubbing?
  true
end

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



177
178
179
180
181
182
183
184
185
186
187
188
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 177

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]
    add_token(xml, token)
    add_creditcard(xml, creditcard)
    add_address(xml, options)
    add_customer_email(xml, options)
    add_test_mode(xml, options)
  end
  commit(request)
end

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



151
152
153
154
155
156
157
158
159
160
161
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 151

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)
    add_address(xml, options)
    add_test_mode(xml, options)
    add_ip(xml, options)
  end
  commit(request)
end

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



123
124
125
126
127
128
129
130
131
132
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 123

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