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.



31
32
33
34
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 31

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

Instance Method Details

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



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

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

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



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

def capture(money, authorization, options = {})
  form = {}
  if options[:credit_card]
    action = :capture
    add_salestax(form, options)
    add_approval_code(form, authorization)
    add_invoice(form, options)
    add_creditcard(form, options[:credit_card])
    add_currency(form, money, options)
    add_customer_data(form, options)
    add_test_mode(form, options)
  else
    action = :capture_complete
    add_txn_id(form, authorization)
    add_partial_shipment_flag(form, options)
    add_test_mode(form, options)
  end
  commit(action, money, form, options)
end

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



100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 100

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

  form = {}
  add_invoice(form, options)
  add_creditcard(form, creditcard)
  add_currency(form, money, options)
  add_address(form, options)
  add_customer_data(form, options)
  add_test_mode(form, options)
  commit(:credit, money, form, options)
end

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



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 36

def purchase(money, payment_method, options = {})
  form = {}
  add_salestax(form, options)
  add_invoice(form, options)
  if payment_method.is_a?(String)
    add_token(form, payment_method)
  else
    add_creditcard(form, payment_method)
  end
  add_currency(form, money, options)
  add_address(form, options)
  add_customer_data(form, options)
  add_test_mode(form, options)
  add_ip(form, options)
  commit(:purchase, money, form, options)
end

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



86
87
88
89
90
91
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 86

def refund(money, identification, options = {})
  form = {}
  add_txn_id(form, identification)
  add_test_mode(form, options)
  commit(:refund, money, form, options)
end

#scrub(transcript) ⇒ Object



147
148
149
150
151
152
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 147

def scrub(transcript)
  transcript.
    gsub(%r((&?ssl_pin=)[^&]*)i, '\1[FILTERED]').
    gsub(%r((&?ssl_card_number=)[^&\\n\r\n]*)i, '\1[FILTERED]').
    gsub(%r((&?ssl_cvv2cvc2=)[^&]*)i, '\1[FILTERED]')
end

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



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

def store(creditcard, options = {})
  form = {}
  add_creditcard(form, creditcard)
  add_address(form, options)
  add_customer_data(form, options)
  add_test_mode(form, options)
  add_verification(form, options)
  form[:add_token] = 'Y'
  commit(:store, nil, form, options)
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


143
144
145
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 143

def supports_scrubbing?
  true
end

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



133
134
135
136
137
138
139
140
141
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 133

def update(token, creditcard, options = {})
  form = {}
  add_token(form, token)
  add_creditcard(form, creditcard)
  add_address(form, options)
  add_customer_data(form, options)
  add_test_mode(form, options)
  commit(:update, nil, form, options)
end

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



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

def verify(credit_card, options = {})
  MultiResponse.run(:use_first_response) do |r|
    r.process { authorize(100, credit_card, options) }
    r.process(:ignore_result) { void(r.authorization, options) }
  end
end

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



93
94
95
96
97
98
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 93

def void(identification, options = {})
  form = {}
  add_txn_id(form, identification)
  add_test_mode(form, options)
  commit(:void, nil, form, options)
end