Class: ActiveMerchant::Billing::ElementGateway
- Inherits:
-
Gateway
- Object
- Gateway
- ActiveMerchant::Billing::ElementGateway
show all
- Defined in:
- lib/active_merchant/billing/gateways/element.rb
Constant Summary
collapse
- SERVICE_TEST_URL =
'https://certservices.elementexpress.com/express.asmx'
- SERVICE_LIVE_URL =
'https://services.elementexpress.com/express.asmx'
- NETWORK_TOKEN_TYPE =
{
apple_pay: '2',
google_pay: '1'
}
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
-
#authorize(money, payment, options = {}) ⇒ Object
-
#capture(money, authorization, options = {}) ⇒ Object
-
#credit(money, payment, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ ElementGateway
constructor
A new instance of ElementGateway.
-
#purchase(money, payment, options = {}) ⇒ Object
-
#refund(money, authorization, options = {}) ⇒ Object
-
#scrub(transcript) ⇒ Object
-
#store(payment, options = {}) ⇒ Object
-
#supports_scrubbing? ⇒ Boolean
-
#verify(credit_card, options = {}) ⇒ Object
-
#void(authorization, options = {}) ⇒ Object
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?
#expdate, #format, #strftime_yyyymm
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
Returns a new instance of ElementGateway.
25
26
27
28
|
# File 'lib/active_merchant/billing/gateways/element.rb', line 25
def initialize(options = {})
requires!(options, :account_id, :account_token, :application_id, :acceptor_id, :application_name, :application_version)
super
end
|
Instance Method Details
#authorize(money, payment, options = {}) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/active_merchant/billing/gateways/element.rb', line 47
def authorize(money, payment, options = {})
request = build_soap_request do |xml|
xml.CreditCardAuthorization(xmlns: 'https://transaction.elementexpress.com') do
add_credentials(xml)
add_payment_method(xml, payment)
add_transaction(xml, money, options)
add_terminal(xml, options)
add_address(xml, options)
add_lodging(xml, options)
end
end
commit('CreditCardAuthorization', request, money)
end
|
#capture(money, authorization, options = {}) ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/active_merchant/billing/gateways/element.rb', line 62
def capture(money, authorization, options = {})
trans_id, = split_authorization(authorization)
options[:trans_id] = trans_id
request = build_soap_request do |xml|
xml.CreditCardAuthorizationCompletion(xmlns: 'https://transaction.elementexpress.com') do
add_credentials(xml)
add_transaction(xml, money, options)
add_terminal(xml, options)
end
end
commit('CreditCardAuthorizationCompletion', request, money)
end
|
#credit(money, payment, options = {}) ⇒ Object
92
93
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/active_merchant/billing/gateways/element.rb', line 92
def credit(money, payment, options = {})
request = build_soap_request do |xml|
xml.CreditCardCredit(xmlns: 'https://transaction.elementexpress.com') do
add_credentials(xml)
add_payment_method(xml, payment)
add_transaction(xml, money, options)
add_terminal(xml, options)
end
end
commit('CreditCardCredit', request, money)
end
|
#purchase(money, payment, options = {}) ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/active_merchant/billing/gateways/element.rb', line 30
def purchase(money, payment, options = {})
action = payment.is_a?(Check) ? 'CheckSale' : 'CreditCardSale'
request = build_soap_request do |xml|
xml.send(action, xmlns: 'https://transaction.elementexpress.com') do
add_credentials(xml)
add_payment_method(xml, payment)
add_transaction(xml, money, options)
add_terminal(xml, options)
add_address(xml, options)
add_lodging(xml, options)
end
end
commit(action, request, money)
end
|
#refund(money, authorization, options = {}) ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/active_merchant/billing/gateways/element.rb', line 77
def refund(money, authorization, options = {})
trans_id, = split_authorization(authorization)
options[:trans_id] = trans_id
request = build_soap_request do |xml|
xml.CreditCardReturn(xmlns: 'https://transaction.elementexpress.com') do
add_credentials(xml)
add_transaction(xml, money, options)
add_terminal(xml, options)
end
end
commit('CreditCardReturn', request, money)
end
|
#scrub(transcript) ⇒ Object
152
153
154
155
156
157
158
159
|
# File 'lib/active_merchant/billing/gateways/element.rb', line 152
def scrub(transcript)
transcript.
gsub(%r((<AccountToken>).+?(</AccountToken>))i, '\1[FILTERED]\2').
gsub(%r((<CardNumber>).+?(</CardNumber>))i, '\1[FILTERED]\2').
gsub(%r((<CVV>).+?(</CVV>))i, '\1[FILTERED]\2').
gsub(%r((<AccountNumber>).+?(</AccountNumber>))i, '\1[FILTERED]\2').
gsub(%r((<RoutingNumber>).+?(</RoutingNumber>))i, '\1[FILTERED]\2')
end
|
#store(payment, options = {}) ⇒ Object
120
121
122
123
124
125
126
127
128
129
130
131
|
# File 'lib/active_merchant/billing/gateways/element.rb', line 120
def store(payment, options = {})
request = build_soap_request do |xml|
xml.PaymentAccountCreate(xmlns: 'https://services.elementexpress.com') do
add_credentials(xml)
add_payment_method(xml, payment)
add_payment_account(xml, payment, options[:payment_account_reference_number] || SecureRandom.hex(20))
add_address(xml, options)
end
end
commit('PaymentAccountCreate', request, nil)
end
|
#supports_scrubbing? ⇒ Boolean
148
149
150
|
# File 'lib/active_merchant/billing/gateways/element.rb', line 148
def supports_scrubbing?
true
end
|
#verify(credit_card, options = {}) ⇒ Object
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
# File 'lib/active_merchant/billing/gateways/element.rb', line 133
def verify(credit_card, options = {})
request = build_soap_request do |xml|
xml.CreditCardAVSOnly(xmlns: 'https://transaction.elementexpress.com') do
add_credentials(xml)
add_payment_method(xml, credit_card)
add_transaction(xml, 0, options)
add_terminal(xml, options)
add_address(xml, options)
end
end
commit('CreditCardAVSOnly', request, 0)
end
|
#void(authorization, options = {}) ⇒ Object
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
# File 'lib/active_merchant/billing/gateways/element.rb', line 105
def void(authorization, options = {})
trans_id, trans_amount = split_authorization(authorization)
options.merge!({ trans_id: trans_id, trans_amount: trans_amount, reversal_type: 'Full' })
request = build_soap_request do |xml|
xml.CreditCardReversal(xmlns: 'https://transaction.elementexpress.com') do
add_credentials(xml)
add_transaction(xml, trans_amount, options)
add_terminal(xml, options)
end
end
commit('CreditCardReversal', request, trans_amount)
end
|