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'
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
-
#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
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
Returns a new instance of ElementGateway.
20
21
22
23
|
# File 'lib/active_merchant/billing/gateways/element.rb', line 20
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
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/active_merchant/billing/gateways/element.rb', line 41
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)
end
end
commit('CreditCardAuthorization', request, money)
end
|
#capture(money, authorization, options = {}) ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/active_merchant/billing/gateways/element.rb', line 55
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
|
#purchase(money, payment, options = {}) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/active_merchant/billing/gateways/element.rb', line 25
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)
end
end
commit(action, request, money)
end
|
#refund(money, authorization, options = {}) ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/active_merchant/billing/gateways/element.rb', line 70
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
132
133
134
135
136
137
138
139
|
# File 'lib/active_merchant/billing/gateways/element.rb', line 132
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
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/active_merchant/billing/gateways/element.rb', line 100
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
128
129
130
|
# File 'lib/active_merchant/billing/gateways/element.rb', line 128
def supports_scrubbing?
true
end
|
#verify(credit_card, options = {}) ⇒ Object
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
# File 'lib/active_merchant/billing/gateways/element.rb', line 113
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/active_merchant/billing/gateways/element.rb', line 85
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
|