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::DEBIT_CARDS, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#card_brand, card_brand, #generate_unique_id, inherited, #scrub, supported_countries, #supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #supports_scrubbing?, #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



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

def authorize(money, creditcard, options = {})
  form = {}
  add_salestax(form, options)
  add_invoice(form, options)
  add_creditcard(form, creditcard)
  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



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

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



97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 97

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_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
# 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_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



83
84
85
86
87
88
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 83

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

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



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

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

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



129
130
131
132
133
134
135
136
137
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 129

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



111
112
113
114
115
116
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 111

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



90
91
92
93
94
95
# File 'lib/active_merchant/billing/gateways/elavon.rb', line 90

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