activemerchant 1.50.0 → 1.51.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +39 -0
- data/README.md +6 -5
- data/lib/active_merchant/billing/credit_card.rb +22 -6
- data/lib/active_merchant/billing/gateway.rb +15 -1
- data/lib/active_merchant/billing/gateways/authorize_net.rb +413 -127
- data/lib/active_merchant/billing/gateways/banwire.rb +2 -2
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +4 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +18 -0
- data/lib/active_merchant/billing/gateways/cenpos.rb +6 -2
- data/lib/active_merchant/billing/gateways/checkout.rb +4 -6
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +200 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +19 -1
- data/lib/active_merchant/billing/gateways/dibs.rb +1 -1
- data/lib/active_merchant/billing/gateways/epay.rb +1 -1
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +5 -5
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +4 -1
- data/lib/active_merchant/billing/gateways/garanti.rb +5 -1
- data/lib/active_merchant/billing/gateways/iats_payments.rb +29 -3
- data/lib/active_merchant/billing/gateways/litle.rb +12 -0
- data/lib/active_merchant/billing/gateways/paystation.rb +19 -23
- data/lib/active_merchant/billing/gateways/payu_in.rb +4 -0
- data/lib/active_merchant/billing/gateways/redsys.rb +4 -3
- data/lib/active_merchant/billing/gateways/s5.rb +3 -3
- data/lib/active_merchant/billing/gateways/sage.rb +8 -10
- data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +7 -5
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +3 -2
- data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +0 -5
- data/lib/active_merchant/billing/gateways/stripe.rb +33 -4
- data/lib/active_merchant/billing/gateways/wepay.rb +13 -6
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +1 -2
- data/lib/active_merchant/version.rb +1 -1
- metadata +3 -2
@@ -35,11 +35,11 @@ module ActiveMerchant #:nodoc:
|
|
35
35
|
def add_customer_data(post, options)
|
36
36
|
post[:user] = @options[:login]
|
37
37
|
post[:phone] = options[:billing_address][:phone]
|
38
|
-
post[:mail] = options[:email]
|
38
|
+
post[:mail] = options[:email] || "unspecified@email.com"
|
39
39
|
end
|
40
40
|
|
41
41
|
def add_order_data(post, options)
|
42
|
-
post[:reference] = options[:order_id]
|
42
|
+
post[:reference] = options[:order_id] || generate_unique_id
|
43
43
|
post[:concept] = options[:description]
|
44
44
|
end
|
45
45
|
|
@@ -109,6 +109,24 @@ module ActiveMerchant #:nodoc:
|
|
109
109
|
commit('REFUND', post)
|
110
110
|
end
|
111
111
|
|
112
|
+
def verify(creditcard, options={})
|
113
|
+
MultiResponse.run(:use_first_response) do |r|
|
114
|
+
r.process { authorize(100, creditcard, options) }
|
115
|
+
r.process(:ignore_result) { void(r.authorization, options) }
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
def supports_scrubbing?
|
120
|
+
true
|
121
|
+
end
|
122
|
+
|
123
|
+
def scrub(transcript)
|
124
|
+
transcript.
|
125
|
+
gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
|
126
|
+
gsub(%r((cardNumber=)\d+), '\1[FILTERED]').
|
127
|
+
gsub(%r((CVV=)\d+), '\1[FILTERED]')
|
128
|
+
end
|
129
|
+
|
112
130
|
private
|
113
131
|
|
114
132
|
def add_amount(post, money, options)
|
@@ -49,6 +49,7 @@ module ActiveMerchant #:nodoc:
|
|
49
49
|
post = {}
|
50
50
|
add_void_required_elements(post)
|
51
51
|
add_reference(post, authorization)
|
52
|
+
add_remembered_amount(post, authorization)
|
52
53
|
add_tax(post, options)
|
53
54
|
|
54
55
|
commit("Void", post)
|
@@ -130,10 +131,13 @@ module ActiveMerchant #:nodoc:
|
|
130
131
|
end
|
131
132
|
|
132
133
|
def add_reference(post, authorization)
|
133
|
-
reference_number, last_four_digits
|
134
|
+
reference_number, last_four_digits = split_authorization(authorization)
|
134
135
|
post[:ReferenceNumber] = reference_number
|
135
136
|
post[:CardLastFourDigits] = last_four_digits
|
136
|
-
|
137
|
+
end
|
138
|
+
|
139
|
+
def add_remembered_amount(post, authorization)
|
140
|
+
post[:Amount] = split_authorization(authorization).last
|
137
141
|
end
|
138
142
|
|
139
143
|
def commit(action, post)
|
@@ -31,12 +31,10 @@ module ActiveMerchant #:nodoc:
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def purchase(amount, payment_method, options)
|
34
|
-
requires!(options, :order_id)
|
35
|
-
|
36
34
|
commit('purchase', amount, options) do |xml|
|
37
35
|
add_credentials(xml, options)
|
38
36
|
add_invoice(xml, amount, options)
|
39
|
-
add_track_id(xml, options[:order_id])
|
37
|
+
add_track_id(xml, options[:order_id] || generate_unique_id)
|
40
38
|
add_payment_method(xml, payment_method)
|
41
39
|
add_billing_info(xml, options)
|
42
40
|
add_shipping_info(xml, options)
|
@@ -46,12 +44,10 @@ module ActiveMerchant #:nodoc:
|
|
46
44
|
end
|
47
45
|
|
48
46
|
def authorize(amount, payment_method, options)
|
49
|
-
requires!(options, :order_id)
|
50
|
-
|
51
47
|
commit('authorize', amount, options) do |xml|
|
52
48
|
add_credentials(xml, options)
|
53
49
|
add_invoice(xml, amount, options)
|
54
|
-
add_track_id(xml, options[:order_id])
|
50
|
+
add_track_id(xml, options[:order_id] || generate_unique_id)
|
55
51
|
add_payment_method(xml, payment_method)
|
56
52
|
add_billing_info(xml, options)
|
57
53
|
add_shipping_info(xml, options)
|
@@ -151,6 +147,8 @@ module ActiveMerchant #:nodoc:
|
|
151
147
|
xml.bill_email_ options[:email]
|
152
148
|
xml.bill_customerip_ options[:ip]
|
153
149
|
xml.merchantcustomerid_ options[:customer]
|
150
|
+
xml.descriptor_name options[:descriptor_name]
|
151
|
+
xml.descriptor_city options[:descriptor_city]
|
154
152
|
end
|
155
153
|
|
156
154
|
def add_reference(xml, authorization)
|
@@ -0,0 +1,200 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class CheckoutV2Gateway < Gateway
|
4
|
+
self.display_name = "Checkout.com V2 Gateway"
|
5
|
+
self.homepage_url = "https://www.checkout.com/"
|
6
|
+
self.test_url = "https://api2.checkout.com/v2"
|
7
|
+
self.live_url = "http://sandbox.checkout.com/api2/v2"
|
8
|
+
|
9
|
+
self.supported_countries = ['AT', 'BE', 'BG', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GR', 'HR', 'HU', 'IE', 'IS', 'IT', 'LI', 'LT', 'LU', 'LV', 'MT', 'MU', 'NL', 'NO', 'PL', 'PT', 'RO', 'SE', 'SI', 'SK', 'US']
|
10
|
+
self.default_currency = "USD"
|
11
|
+
self.money_format = :cents
|
12
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :diners_club]
|
13
|
+
|
14
|
+
def initialize(options={})
|
15
|
+
requires!(options, :secret_key)
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
def purchase(amount, payment_method, options={})
|
20
|
+
MultiResponse.run do |r|
|
21
|
+
r.process { authorize(amount, payment_method, options) }
|
22
|
+
r.process { capture(amount, r.authorization, options) }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def authorize(amount, payment_method, options={})
|
27
|
+
post = {}
|
28
|
+
post[:autoCapture] = "n"
|
29
|
+
add_invoice(post, amount, options)
|
30
|
+
add_payment_method(post, payment_method)
|
31
|
+
add_customer_data(post, options)
|
32
|
+
|
33
|
+
commit(:authorize, post)
|
34
|
+
end
|
35
|
+
|
36
|
+
def capture(amount, authorization, options={})
|
37
|
+
post = {}
|
38
|
+
add_invoice(post, amount, options)
|
39
|
+
add_customer_data(post, options)
|
40
|
+
|
41
|
+
commit(:capture, post, authorization)
|
42
|
+
end
|
43
|
+
|
44
|
+
def void(authorization, options={})
|
45
|
+
post = {}
|
46
|
+
commit(:void, post, authorization)
|
47
|
+
end
|
48
|
+
|
49
|
+
def refund(amount, authorization, options={})
|
50
|
+
post = {}
|
51
|
+
add_invoice(post, amount, options)
|
52
|
+
add_customer_data(post, options)
|
53
|
+
|
54
|
+
commit(:refund, post, authorization)
|
55
|
+
end
|
56
|
+
|
57
|
+
def verify(credit_card, options={})
|
58
|
+
MultiResponse.run(:use_first_response) do |r|
|
59
|
+
r.process { authorize(100, credit_card, options) }
|
60
|
+
r.process(:ignore_result) { void(r.authorization, options) }
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def supports_scrubbing?
|
65
|
+
true
|
66
|
+
end
|
67
|
+
|
68
|
+
def scrub(transcript)
|
69
|
+
transcript.
|
70
|
+
gsub(%r((Authorization: )[^\\]*)i, '\1[FILTERED]').
|
71
|
+
gsub(%r(("number\\":\\")\d+), '\1[FILTERED]').
|
72
|
+
gsub(%r(("cvv\\":\\")\d+), '\1[FILTERED]')
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
|
77
|
+
def add_invoice(post, money, options)
|
78
|
+
post[:value] = amount(money)
|
79
|
+
post[:trackId] = options[:order_id]
|
80
|
+
post[:currency] = options[:currency] || currency(money)
|
81
|
+
end
|
82
|
+
|
83
|
+
def add_payment_method(post, payment_method)
|
84
|
+
post[:card] = {}
|
85
|
+
post[:card][:name] = payment_method.name
|
86
|
+
post[:card][:number] = payment_method.number
|
87
|
+
post[:card][:cvv] = payment_method.verification_value
|
88
|
+
post[:card][:expiryYear] = format(payment_method.year, :four_digits)
|
89
|
+
post[:card][:expiryMonth] = format(payment_method.month, :two_digits)
|
90
|
+
end
|
91
|
+
|
92
|
+
def add_customer_data(post, options)
|
93
|
+
post[:email] = options[:email] || "unspecified@example.com"
|
94
|
+
address = options[:billing_address]
|
95
|
+
if(address && post[:card])
|
96
|
+
post[:card][:billingDetails] = {}
|
97
|
+
post[:card][:billingDetails][:address1] = address[:address1]
|
98
|
+
post[:card][:billingDetails][:address2] = address[:address2]
|
99
|
+
post[:card][:billingDetails][:city] = address[:city]
|
100
|
+
post[:card][:billingDetails][:state] = address[:state]
|
101
|
+
post[:card][:billingDetails][:country] = address[:country]
|
102
|
+
post[:card][:billingDetails][:postcode] = address[:zip]
|
103
|
+
post[:card][:billingDetails][:phone] = { number: address[:phone] }
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def commit(action, post, authorization = nil)
|
108
|
+
begin
|
109
|
+
raw_response = ssl_post(url(post, action, authorization), post.to_json, headers)
|
110
|
+
response = parse(raw_response)
|
111
|
+
rescue ResponseError => e
|
112
|
+
raise unless(e.response.code.to_s =~ /4\d\d/)
|
113
|
+
response = parse(e.response.body)
|
114
|
+
end
|
115
|
+
|
116
|
+
succeeded = success_from(response)
|
117
|
+
Response.new(
|
118
|
+
succeeded,
|
119
|
+
message_from(succeeded, response),
|
120
|
+
response,
|
121
|
+
authorization: authorization_from(response),
|
122
|
+
error_code: error_code_from(succeeded, response),
|
123
|
+
test: test?,
|
124
|
+
avs_result: avs_result(action, response),
|
125
|
+
cvv_result: cvv_result(action, response))
|
126
|
+
end
|
127
|
+
|
128
|
+
def headers
|
129
|
+
{
|
130
|
+
"Authorization" => @options[:secret_key],
|
131
|
+
"Content-Type" => "application/json;charset=UTF-8"
|
132
|
+
}
|
133
|
+
end
|
134
|
+
|
135
|
+
def url(post, action, authorization)
|
136
|
+
if action == :authorize
|
137
|
+
"#{base_url}/charges/card"
|
138
|
+
else
|
139
|
+
"#{base_url}/charges/#{authorization}/#{action}"
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
def base_url
|
144
|
+
test? ? test_url : live_url
|
145
|
+
end
|
146
|
+
|
147
|
+
def avs_result(action, response)
|
148
|
+
action == :purchase ? AVSResult.new(code: response["card"]["avsCheck"]) : nil
|
149
|
+
end
|
150
|
+
|
151
|
+
def cvv_result(action, response)
|
152
|
+
action == :purchase ? CVVResult.new(response["card"]["cvvCheck"]) : nil
|
153
|
+
end
|
154
|
+
|
155
|
+
def parse(body)
|
156
|
+
JSON.parse(body)
|
157
|
+
rescue JSON::ParserError
|
158
|
+
{
|
159
|
+
"message" => "Invalid JSON response received from CheckoutV2Gateway. Please contact CheckoutV2Gateway if you continue to receive this message.",
|
160
|
+
"raw_response" => scrub(body)
|
161
|
+
}
|
162
|
+
end
|
163
|
+
|
164
|
+
def success_from(response)
|
165
|
+
response["responseCode"] == ("10000" || "10100")
|
166
|
+
end
|
167
|
+
|
168
|
+
def message_from(succeeded, response)
|
169
|
+
if succeeded
|
170
|
+
"Succeeded"
|
171
|
+
elsif response["errors"]
|
172
|
+
response["message"] + ": " + response["errors"].first
|
173
|
+
else
|
174
|
+
response["responseMessage"] || response["message"] || "Unable to read error message"
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
STANDARD_ERROR_CODE_MAPPING = {
|
179
|
+
"20014" => STANDARD_ERROR_CODE[:invalid_number],
|
180
|
+
"20100" => STANDARD_ERROR_CODE[:invalid_expiry_date],
|
181
|
+
"20054" => STANDARD_ERROR_CODE[:expired_card],
|
182
|
+
"40104" => STANDARD_ERROR_CODE[:incorrect_cvc],
|
183
|
+
"40108" => STANDARD_ERROR_CODE[:incorrect_zip],
|
184
|
+
"40111" => STANDARD_ERROR_CODE[:incorrect_address],
|
185
|
+
"20005" => STANDARD_ERROR_CODE[:card_declined],
|
186
|
+
"20088" => STANDARD_ERROR_CODE[:processing_error],
|
187
|
+
"20001" => STANDARD_ERROR_CODE[:call_issuer],
|
188
|
+
"30004" => STANDARD_ERROR_CODE[:pickup_card]
|
189
|
+
}
|
190
|
+
|
191
|
+
def authorization_from(raw)
|
192
|
+
raw["id"]
|
193
|
+
end
|
194
|
+
|
195
|
+
def error_code_from(succeeded, response)
|
196
|
+
succeeded ? nil : STANDARD_ERROR_CODE_MAPPING[response["responseCode"]]
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
@@ -27,7 +27,7 @@ module ActiveMerchant #:nodoc:
|
|
27
27
|
# * To process pinless debit cards through the pinless debit card
|
28
28
|
# network, your Cybersource merchant account must accept pinless
|
29
29
|
# debit card payments.
|
30
|
-
# * The order of the XML elements does matter, make sure to follow the order in
|
30
|
+
# * The order of the XML elements does matter, make sure to follow the order in
|
31
31
|
# the documentation exactly.
|
32
32
|
class CyberSourceGateway < Gateway
|
33
33
|
self.test_url = 'https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor'
|
@@ -231,6 +231,24 @@ module ActiveMerchant #:nodoc:
|
|
231
231
|
commit(build_validate_pinless_debit_request(creditcard,options), options)
|
232
232
|
end
|
233
233
|
|
234
|
+
def supports_scrubbing?
|
235
|
+
true
|
236
|
+
end
|
237
|
+
|
238
|
+
def scrub(transcript)
|
239
|
+
transcript.
|
240
|
+
gsub(%r((<wsse:Password [^>]*>)[^<]*(</wsse:Password>))i, '\1[FILTERED]\2').
|
241
|
+
gsub(%r((<accountNumber>)[^<]*(</accountNumber>))i, '\1[FILTERED]\2').
|
242
|
+
gsub(%r((<cvNumber>)[^<]*(</cvNumber>))i, '\1[FILTERED]\2').
|
243
|
+
gsub(%r((<cavv>)[^<]*(</cavv>))i, '\1[FILTERED]\2').
|
244
|
+
gsub(%r((<xid>)[^<]*(</xid>))i, '\1[FILTERED]\2').
|
245
|
+
gsub(%r((<authenticationData>)[^<]*(</authenticationData>))i, '\1[FILTERED]\2')
|
246
|
+
end
|
247
|
+
|
248
|
+
def supports_network_tokenization?
|
249
|
+
true
|
250
|
+
end
|
251
|
+
|
234
252
|
private
|
235
253
|
|
236
254
|
# Create all address hash key value pairs so that we still function if we
|
@@ -108,7 +108,7 @@ module ActiveMerchant #:nodoc:
|
|
108
108
|
|
109
109
|
def add_payment_method(post, payment_method, options)
|
110
110
|
post[:cardNumber] = payment_method.number
|
111
|
-
post[:cvc] = payment_method.verification_value
|
111
|
+
post[:cvc] = payment_method.verification_value if payment_method.verification_value
|
112
112
|
post[:expYear] = format(payment_method.year, :two_digits)
|
113
113
|
post[:expMonth] = payment_method.month
|
114
114
|
|
@@ -186,7 +186,7 @@ module ActiveMerchant #:nodoc:
|
|
186
186
|
# Authorize gives the response back by redirecting with the values in
|
187
187
|
# the URL query
|
188
188
|
if location = response['Location']
|
189
|
-
query = CGI::parse(URI.parse(location.gsub(' ', '%20')).query)
|
189
|
+
query = CGI::parse(URI.parse(location.gsub(' ', '%20').gsub('<', '%3C').gsub('>', '%3E')).query)
|
190
190
|
else
|
191
191
|
return {
|
192
192
|
'accept' => '0',
|
@@ -7,7 +7,7 @@ module ActiveMerchant #:nodoc:
|
|
7
7
|
self.live_url = "https://api.ewaypayments.com/"
|
8
8
|
|
9
9
|
self.money_format = :cents
|
10
|
-
self.supported_countries = ['AU', 'NZ', 'GB', 'SG']
|
10
|
+
self.supported_countries = ['AU', 'NZ', 'GB', 'SG', 'MY', 'HK']
|
11
11
|
self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb]
|
12
12
|
self.homepage_url = "http://www.eway.com.au/"
|
13
13
|
self.display_name = "eWAY Rapid 3.1"
|
@@ -42,7 +42,7 @@ module ActiveMerchant #:nodoc:
|
|
42
42
|
# transaction (optional).
|
43
43
|
# :application_id - A string identifying the application
|
44
44
|
# submitting the transaction
|
45
|
-
# (default: "https://github.com/
|
45
|
+
# (default: "https://github.com/activemerchant/active_merchant")
|
46
46
|
#
|
47
47
|
# Returns an ActiveMerchant::Billing::Response object where authorization is the Transaction ID on success
|
48
48
|
def purchase(amount, payment_method, options={})
|
@@ -99,7 +99,7 @@ module ActiveMerchant #:nodoc:
|
|
99
99
|
# transaction (optional).
|
100
100
|
# :application_id - A string identifying the application
|
101
101
|
# submitting the transaction
|
102
|
-
# (default: "https://github.com/
|
102
|
+
# (default: "https://github.com/activemerchant/active_merchant")
|
103
103
|
#
|
104
104
|
# Returns an ActiveMerchant::Billing::Response object
|
105
105
|
def refund(amount, identification, options = {})
|
@@ -125,7 +125,7 @@ module ActiveMerchant #:nodoc:
|
|
125
125
|
# transaction (optional).
|
126
126
|
# :application_id - A string identifying the application
|
127
127
|
# submitting the transaction
|
128
|
-
# (default: "https://github.com/
|
128
|
+
# (default: "https://github.com/activemerchant/active_merchant")
|
129
129
|
#
|
130
130
|
# Returns an ActiveMerchant::Billing::Response object where the authorization is the customer_token on success
|
131
131
|
def store(payment_method, options = {})
|
@@ -155,7 +155,7 @@ module ActiveMerchant #:nodoc:
|
|
155
155
|
# transaction (optional).
|
156
156
|
# :application_id - A string identifying the application
|
157
157
|
# submitting the transaction
|
158
|
-
# (default: "https://github.com/
|
158
|
+
# (default: "https://github.com/activemerchant/active_merchant")
|
159
159
|
#
|
160
160
|
# Returns an ActiveMerchant::Billing::Response object where the authorization is the customer_token on success
|
161
161
|
def update(customer_token, payment_method, options = {})
|
@@ -139,6 +139,10 @@ module ActiveMerchant #:nodoc:
|
|
139
139
|
gsub(%r((<VerificationStr2>).+(</VerificationStr2>)), '\1[FILTERED]\2')
|
140
140
|
end
|
141
141
|
|
142
|
+
def supports_network_tokenization?
|
143
|
+
true
|
144
|
+
end
|
145
|
+
|
142
146
|
private
|
143
147
|
|
144
148
|
def build_request(action, body)
|
@@ -410,4 +414,3 @@ module ActiveMerchant #:nodoc:
|
|
410
414
|
end
|
411
415
|
end
|
412
416
|
end
|
413
|
-
|
@@ -230,7 +230,7 @@ module ActiveMerchant #:nodoc:
|
|
230
230
|
end
|
231
231
|
|
232
232
|
def parse(body)
|
233
|
-
xml = REXML::Document.new(body)
|
233
|
+
xml = REXML::Document.new(strip_invalid_xml_chars(body))
|
234
234
|
|
235
235
|
response = {}
|
236
236
|
xml.root.elements.to_a.each do |node|
|
@@ -251,6 +251,10 @@ module ActiveMerchant #:nodoc:
|
|
251
251
|
response[:message] == "Approved"
|
252
252
|
end
|
253
253
|
|
254
|
+
def strip_invalid_xml_chars(xml)
|
255
|
+
xml.gsub(/&(?!(?:[a-z]+|#[0-9]+|x[a-zA-Z0-9]+);)/, '&')
|
256
|
+
end
|
257
|
+
|
254
258
|
end
|
255
259
|
end
|
256
260
|
end
|
@@ -15,7 +15,9 @@ module ActiveMerchant #:nodoc:
|
|
15
15
|
|
16
16
|
ACTIONS = {
|
17
17
|
purchase: "ProcessCreditCardV1",
|
18
|
+
purchase_check: "ProcessACHEFTV1",
|
18
19
|
refund: "ProcessCreditCardRefundWithTransactionIdV1",
|
20
|
+
refund_check: "ProcessACHEFTRefundWithTransactionIdV1",
|
19
21
|
store: "CreateCreditCardCustomerCodeV1",
|
20
22
|
unstore: "DeleteCustomerCodeV1"
|
21
23
|
}
|
@@ -40,17 +42,18 @@ module ActiveMerchant #:nodoc:
|
|
40
42
|
add_ip(post, options)
|
41
43
|
add_description(post, options)
|
42
44
|
|
43
|
-
commit(:purchase, post)
|
45
|
+
commit((payment.is_a?(Check) ? :purchase_check : :purchase), post)
|
44
46
|
end
|
45
47
|
|
46
48
|
def refund(money, authorization, options={})
|
47
49
|
post = {}
|
48
|
-
|
50
|
+
transaction_id, payment_type = split_authorization(authorization)
|
51
|
+
post[:transaction_id] = transaction_id
|
49
52
|
add_invoice(post, -money, options)
|
50
53
|
add_ip(post, options)
|
51
54
|
add_description(post, options)
|
52
55
|
|
53
|
-
commit(:refund, post)
|
56
|
+
commit((payment_type == 'check' ? :refund_check : :refund), post)
|
54
57
|
end
|
55
58
|
|
56
59
|
def store(credit_card, options = {})
|
@@ -98,6 +101,14 @@ module ActiveMerchant #:nodoc:
|
|
98
101
|
end
|
99
102
|
|
100
103
|
def add_payment(post, payment)
|
104
|
+
if payment.is_a?(Check)
|
105
|
+
add_check(post, payment)
|
106
|
+
else
|
107
|
+
add_credit_card(post, payment)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
def add_credit_card(post, payment)
|
101
112
|
post[:first_name] = payment.first_name
|
102
113
|
post[:last_name] = payment.last_name
|
103
114
|
post[:credit_card_num] = payment.number
|
@@ -106,6 +117,13 @@ module ActiveMerchant #:nodoc:
|
|
106
117
|
post[:mop] = creditcard_brand(payment.brand)
|
107
118
|
end
|
108
119
|
|
120
|
+
def add_check(post, payment)
|
121
|
+
post[:first_name] = payment.first_name
|
122
|
+
post[:last_name] = payment.last_name
|
123
|
+
post[:account_num] = "#{payment.routing_number}#{payment.account_number}"
|
124
|
+
post[:account_type] = payment.account_type.upcase
|
125
|
+
end
|
126
|
+
|
109
127
|
def add_store_defaults(post)
|
110
128
|
post[:recurring] = false
|
111
129
|
post[:begin_date] = Time.now.xmlschema
|
@@ -148,7 +166,9 @@ module ActiveMerchant #:nodoc:
|
|
148
166
|
def endpoints
|
149
167
|
{
|
150
168
|
purchase: "ProcessLink.asmx",
|
169
|
+
purchase_check: "ProcessLink.asmx",
|
151
170
|
refund: "ProcessLink.asmx",
|
171
|
+
refund_check: "ProcessLink.asmx",
|
152
172
|
store: "CustomerLink.asmx",
|
153
173
|
unstore: "CustomerLink.asmx"
|
154
174
|
}
|
@@ -212,11 +232,17 @@ module ActiveMerchant #:nodoc:
|
|
212
232
|
def authorization_from(action, response)
|
213
233
|
if [:store, :unstore].include?(action)
|
214
234
|
response[:customercode]
|
235
|
+
elsif [:purchase_check].include?(action)
|
236
|
+
response[:transaction_id] ? "#{response[:transaction_id]}|check" : nil
|
215
237
|
else
|
216
238
|
response[:transaction_id]
|
217
239
|
end
|
218
240
|
end
|
219
241
|
|
242
|
+
def split_authorization(authorization)
|
243
|
+
authorization.split("|")
|
244
|
+
end
|
245
|
+
|
220
246
|
def envelope_namespaces
|
221
247
|
{
|
222
248
|
"xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
|