activemerchant 1.123.0 → 1.125.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +131 -0
- data/lib/active_merchant/billing/check.rb +5 -8
- data/lib/active_merchant/billing/credit_card.rb +10 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +6 -3
- data/lib/active_merchant/billing/gateway.rb +1 -1
- data/lib/active_merchant/billing/gateways/adyen.rb +61 -9
- data/lib/active_merchant/billing/gateways/card_stream.rb +17 -13
- data/lib/active_merchant/billing/gateways/cashnet.rb +15 -5
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +33 -4
- data/lib/active_merchant/billing/gateways/cyber_source.rb +11 -3
- data/lib/active_merchant/billing/gateways/d_local.rb +12 -6
- data/lib/active_merchant/billing/gateways/decidir_plus.rb +173 -0
- data/lib/active_merchant/billing/gateways/ebanx.rb +16 -1
- data/lib/active_merchant/billing/gateways/elavon.rb +6 -3
- data/lib/active_merchant/billing/gateways/element.rb +20 -2
- data/lib/active_merchant/billing/gateways/global_collect.rb +111 -16
- data/lib/active_merchant/billing/gateways/ipg.rb +416 -0
- data/lib/active_merchant/billing/gateways/kushki.rb +7 -0
- data/lib/active_merchant/billing/gateways/mercado_pago.rb +3 -1
- data/lib/active_merchant/billing/gateways/mit.rb +260 -0
- data/lib/active_merchant/billing/gateways/moka.rb +24 -11
- data/lib/active_merchant/billing/gateways/mundipagg.rb +8 -6
- data/lib/active_merchant/billing/gateways/nmi.rb +15 -1
- data/lib/active_merchant/billing/gateways/orbital.rb +19 -3
- data/lib/active_merchant/billing/gateways/pay_arc.rb +9 -7
- data/lib/active_merchant/billing/gateways/pay_conex.rb +3 -1
- data/lib/active_merchant/billing/gateways/pay_trace.rb +1 -1
- data/lib/active_merchant/billing/gateways/payflow.rb +14 -6
- data/lib/active_merchant/billing/gateways/paymentez.rb +9 -2
- data/lib/active_merchant/billing/gateways/paysafe.rb +144 -23
- data/lib/active_merchant/billing/gateways/payu_latam.rb +6 -1
- data/lib/active_merchant/billing/gateways/payway_dot_com.rb +3 -3
- data/lib/active_merchant/billing/gateways/pin.rb +31 -4
- data/lib/active_merchant/billing/gateways/priority.rb +347 -0
- data/lib/active_merchant/billing/gateways/realex.rb +18 -0
- data/lib/active_merchant/billing/gateways/safe_charge.rb +6 -2
- data/lib/active_merchant/billing/gateways/stripe.rb +27 -7
- data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +96 -38
- data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +2 -1
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +2 -1
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +20 -6
- data/lib/active_merchant/billing/gateways/wompi.rb +193 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +196 -64
- data/lib/active_merchant/billing/network_tokenization_credit_card.rb +1 -1
- data/lib/active_merchant/billing/response.rb +4 -0
- data/lib/active_merchant/version.rb +1 -1
- metadata +7 -2
@@ -0,0 +1,347 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module Billing #:nodoc:
|
3
|
+
class PriorityGateway < Gateway
|
4
|
+
# Sandbox and Production
|
5
|
+
self.test_url = 'https://sandbox.api.mxmerchant.com/checkout/v3/payment'
|
6
|
+
self.live_url = 'https://api.mxmerchant.com/checkout/v3/payment'
|
7
|
+
|
8
|
+
class_attribute :test_url_verify, :live_url_verify, :test_auth, :live_auth, :test_env_verify, :live_env_verify, :test_url_batch, :live_url_batch, :test_url_jwt, :live_url_jwt, :merchant
|
9
|
+
|
10
|
+
# Sandbox and Production - verify card
|
11
|
+
self.test_url_verify = 'https://sandbox-api2.mxmerchant.com/merchant/v1/bin'
|
12
|
+
self.live_url_verify = 'https://api2.mxmerchant.com/merchant/v1/bin'
|
13
|
+
|
14
|
+
# Sandbox and Production - check batch status
|
15
|
+
self.test_url_batch = 'https://sandbox.api.mxmerchant.com/checkout/v3/batch'
|
16
|
+
self.live_url_batch = 'https://api.mxmerchant.com/checkout/v3/batch'
|
17
|
+
|
18
|
+
# Sandbox and Production - generate jwt for verify card url
|
19
|
+
self.test_url_jwt = 'https://sandbox-api2.mxmerchant.com/security/v1/application/merchantId'
|
20
|
+
self.live_url_jwt = 'https://api2.mxmerchant.com/security/v1/application/merchantId'
|
21
|
+
|
22
|
+
self.supported_countries = ['US']
|
23
|
+
self.default_currency = 'USD'
|
24
|
+
self.supported_cardtypes = %i[visa master american_express discover]
|
25
|
+
|
26
|
+
self.homepage_url = 'https://mxmerchant.com/'
|
27
|
+
self.display_name = 'Priority'
|
28
|
+
|
29
|
+
def initialize(options = {})
|
30
|
+
requires!(options, :merchant_id, :key, :secret)
|
31
|
+
super
|
32
|
+
end
|
33
|
+
|
34
|
+
def basic_auth
|
35
|
+
Base64.strict_encode64("#{@options[:key]}:#{@options[:secret]}")
|
36
|
+
end
|
37
|
+
|
38
|
+
def request_headers
|
39
|
+
{
|
40
|
+
'Content-Type' => 'application/json',
|
41
|
+
'Authorization' => "Basic #{basic_auth}"
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
def request_verify_headers(jwt)
|
46
|
+
{
|
47
|
+
'Authorization' => "Bearer #{jwt}"
|
48
|
+
}
|
49
|
+
end
|
50
|
+
|
51
|
+
def purchase(amount, credit_card, options = {})
|
52
|
+
params = {}
|
53
|
+
params['amount'] = localized_amount(amount.to_f, options[:currency])
|
54
|
+
params['authOnly'] = false
|
55
|
+
|
56
|
+
add_credit_card(params, credit_card, 'purchase', options)
|
57
|
+
add_type_merchant_purchase(params, @options[:merchant_id], true, options)
|
58
|
+
commit('purchase', params: params, jwt: options)
|
59
|
+
end
|
60
|
+
|
61
|
+
def authorize(amount, credit_card, options = {})
|
62
|
+
params = {}
|
63
|
+
params['amount'] = localized_amount(amount.to_f, options[:currency])
|
64
|
+
params['authOnly'] = true
|
65
|
+
|
66
|
+
add_credit_card(params, credit_card, 'purchase', options)
|
67
|
+
add_type_merchant_purchase(params, @options[:merchant_id], false, options)
|
68
|
+
commit('purchase', params: params, jwt: options)
|
69
|
+
end
|
70
|
+
|
71
|
+
def refund(amount, authorization, options = {})
|
72
|
+
params = {}
|
73
|
+
params['merchantId'] = @options[:merchant_id]
|
74
|
+
params['paymentToken'] = get_hash(authorization)['payment_token'] || options[:payment_token]
|
75
|
+
# refund amounts must be negative
|
76
|
+
params['amount'] = ('-' + localized_amount(amount.to_f, options[:currency])).to_f
|
77
|
+
commit('refund', params: params, jwt: options)
|
78
|
+
end
|
79
|
+
|
80
|
+
def capture(amount, authorization, options = {})
|
81
|
+
params = {}
|
82
|
+
params['amount'] = localized_amount(amount.to_f, options[:currency])
|
83
|
+
params['authCode'] = options[:authCode]
|
84
|
+
params['merchantId'] = @options[:merchant_id]
|
85
|
+
params['paymentToken'] = get_hash(authorization)['payment_token']
|
86
|
+
params['shouldGetCreditCardLevel'] = true
|
87
|
+
params['source'] = options[:source]
|
88
|
+
params['tenderType'] = 'Card'
|
89
|
+
|
90
|
+
commit('capture', params: params, jwt: options)
|
91
|
+
end
|
92
|
+
|
93
|
+
def void(authorization, options = {})
|
94
|
+
commit('void', iid: get_hash(authorization)['id'], jwt: options)
|
95
|
+
end
|
96
|
+
|
97
|
+
def verify(credit_card, options)
|
98
|
+
jwt = options[:jwt_token]
|
99
|
+
commit('verify', card_number: credit_card.number, jwt: jwt)
|
100
|
+
end
|
101
|
+
|
102
|
+
def supports_scrubbing?
|
103
|
+
true
|
104
|
+
end
|
105
|
+
|
106
|
+
def get_payment_status(batch_id, options)
|
107
|
+
commit('get_payment_status', params: batch_id, jwt: options)
|
108
|
+
end
|
109
|
+
|
110
|
+
def close_batch(batch_id, options)
|
111
|
+
commit('close_batch', params: batch_id, jwt: options)
|
112
|
+
end
|
113
|
+
|
114
|
+
def create_jwt(options)
|
115
|
+
commit('create_jwt', params: @options[:merchant_id], jwt: options)
|
116
|
+
end
|
117
|
+
|
118
|
+
def scrub(transcript)
|
119
|
+
transcript.
|
120
|
+
gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
|
121
|
+
gsub(%r((number\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
|
122
|
+
gsub(%r((cvv\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]')
|
123
|
+
end
|
124
|
+
|
125
|
+
def add_credit_card(params, credit_card, action, options)
|
126
|
+
return unless credit_card&.is_a?(CreditCard)
|
127
|
+
|
128
|
+
card_details = {}
|
129
|
+
|
130
|
+
card_details['expiryMonth'] = format(credit_card.month, :two_digits).to_s
|
131
|
+
card_details['expiryYear'] = format(credit_card.year, :two_digits).to_s
|
132
|
+
card_details['expiryDate'] = exp_date(credit_card)
|
133
|
+
card_details['cardType'] = credit_card.brand
|
134
|
+
card_details['last4'] = credit_card.last_digits
|
135
|
+
card_details['cvv'] = credit_card.verification_value
|
136
|
+
card_details['number'] = credit_card.number
|
137
|
+
|
138
|
+
card_details['entryMode'] = options['entryMode'].blank? ? 'Keyed' : options['entryMode']
|
139
|
+
|
140
|
+
case action
|
141
|
+
when 'purchase'
|
142
|
+
card_details['avsStreet'] = options[:billing_address][:address1] if options[:billing_address]
|
143
|
+
card_details['avsZip'] = options[:billing_address][:zip] if options[:billing_address]
|
144
|
+
when 'refund'
|
145
|
+
card_details['cardId'] = options[:card_id]
|
146
|
+
card_details['cardPresent'] = options[:card_present]
|
147
|
+
card_details['hasContract'] = options[:has_contract]
|
148
|
+
card_details['isCorp'] = options[:is_corp]
|
149
|
+
card_details['isDebit'] = options[:is_debit]
|
150
|
+
card_details['token'] = options[:token]
|
151
|
+
else
|
152
|
+
card_details
|
153
|
+
end
|
154
|
+
|
155
|
+
params['cardAccount'] = card_details
|
156
|
+
end
|
157
|
+
|
158
|
+
def exp_date(credit_card)
|
159
|
+
"#{format(credit_card.month, :two_digits)}/#{format(credit_card.year, :two_digits)}"
|
160
|
+
end
|
161
|
+
|
162
|
+
def purchases
|
163
|
+
[{ taxRate: '0.0000', additionalTaxRate: nil, discountRate: nil }]
|
164
|
+
end
|
165
|
+
|
166
|
+
def add_type_merchant_purchase(params, merchant, is_settle_funds, options)
|
167
|
+
params['cardPresent'] = false
|
168
|
+
params['cardPresentType'] = 'CardNotPresent'
|
169
|
+
params['isAuth'] = true
|
170
|
+
params['isSettleFunds'] = is_settle_funds
|
171
|
+
params['isTicket'] = false
|
172
|
+
|
173
|
+
params['merchantId'] = merchant
|
174
|
+
params['mxAdvantageEnabled'] = false
|
175
|
+
params['paymentType'] = 'Sale'
|
176
|
+
|
177
|
+
params['purchases'] = purchases
|
178
|
+
|
179
|
+
params['shouldGetCreditCardLevel'] = true
|
180
|
+
params['shouldVaultCard'] = true
|
181
|
+
params['source'] = options[:source]
|
182
|
+
params['sourceZip'] = options[:billing_address][:zip] if options[:billing_address]
|
183
|
+
params['taxExempt'] = false
|
184
|
+
params['tenderType'] = 'Card'
|
185
|
+
end
|
186
|
+
|
187
|
+
def commit(action, params: '', iid: '', card_number: nil, jwt: '')
|
188
|
+
response =
|
189
|
+
begin
|
190
|
+
case action
|
191
|
+
when 'void'
|
192
|
+
parse(ssl_request(:delete, url(action, params, ref_number: iid), nil, request_headers))
|
193
|
+
when 'verify'
|
194
|
+
parse(ssl_get(url(action, params, credit_card_number: card_number), request_verify_headers(jwt)))
|
195
|
+
when 'get_payment_status', 'create_jwt'
|
196
|
+
parse(ssl_get(url(action, params, ref_number: iid), request_headers))
|
197
|
+
when 'close_batch'
|
198
|
+
parse(ssl_request(:put, url(action, params, ref_number: iid), nil, request_headers))
|
199
|
+
else
|
200
|
+
parse(ssl_post(url(action, params), post_data(params), request_headers))
|
201
|
+
end
|
202
|
+
rescue ResponseError => e
|
203
|
+
parse(e.response.body)
|
204
|
+
end
|
205
|
+
success = success_from(response, action)
|
206
|
+
response = { 'code' => '204' } if response == ''
|
207
|
+
Response.new(
|
208
|
+
success,
|
209
|
+
message_from(response),
|
210
|
+
response,
|
211
|
+
authorization: success ? authorization_from(response) : nil,
|
212
|
+
error_code: success || response == '' ? nil : error_from(response),
|
213
|
+
test: test?
|
214
|
+
)
|
215
|
+
end
|
216
|
+
|
217
|
+
def handle_response(response)
|
218
|
+
if response.code != '204' && (200...300).cover?(response.code.to_i)
|
219
|
+
response.body
|
220
|
+
elsif response.code == '204' || response == ''
|
221
|
+
response.body = { 'code' => '204' }
|
222
|
+
else
|
223
|
+
raise ResponseError.new(response)
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
def url(action, params, ref_number: '', credit_card_number: nil)
|
228
|
+
case action
|
229
|
+
when 'void'
|
230
|
+
base_url + "/#{ref_number}?force=true"
|
231
|
+
when 'verify'
|
232
|
+
(verify_url + '?search=') + credit_card_number.to_s[0..6]
|
233
|
+
when 'get_payment_status', 'close_batch'
|
234
|
+
batch_url + "/#{params}"
|
235
|
+
when 'create_jwt'
|
236
|
+
jwt_url + "/#{params}/token"
|
237
|
+
else
|
238
|
+
base_url + '?includeCustomerMatches=false&echo=true'
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
def base_url
|
243
|
+
test? ? test_url : live_url
|
244
|
+
end
|
245
|
+
|
246
|
+
def verify_url
|
247
|
+
test? ? self.test_url_verify : self.live_url_verify
|
248
|
+
end
|
249
|
+
|
250
|
+
def jwt_url
|
251
|
+
test? ? self.test_url_jwt : self.live_url_jwt
|
252
|
+
end
|
253
|
+
|
254
|
+
def batch_url
|
255
|
+
test? ? self.test_url_batch : self.live_url_batch
|
256
|
+
end
|
257
|
+
|
258
|
+
def parse(body)
|
259
|
+
return body if body['code'] == '204'
|
260
|
+
|
261
|
+
JSON.parse(body)
|
262
|
+
rescue JSON::ParserError
|
263
|
+
message = 'Invalid JSON response received from Priority Gateway. Please contact Priority Gateway if you continue to receive this message.'
|
264
|
+
message += " (The raw response returned by the API was #{body.inspect})"
|
265
|
+
{
|
266
|
+
'message' => message
|
267
|
+
}
|
268
|
+
end
|
269
|
+
|
270
|
+
def success_from(response, action)
|
271
|
+
success = response['status'] == 'Approved' || response['status'] == 'Open' if response['status']
|
272
|
+
success = response['code'] == '204' if action == 'void'
|
273
|
+
success = !response['bank'].empty? if action == 'verify' && response['bank']
|
274
|
+
success
|
275
|
+
end
|
276
|
+
|
277
|
+
def message_from(response)
|
278
|
+
return response['details'][0] if response['details'] && response['details'][0]
|
279
|
+
|
280
|
+
response['authMessage'] || response['message'] || response['status']
|
281
|
+
end
|
282
|
+
|
283
|
+
def authorization_from(response)
|
284
|
+
{
|
285
|
+
'payment_token' => response['paymentToken'],
|
286
|
+
'id' => response['id']
|
287
|
+
}
|
288
|
+
end
|
289
|
+
|
290
|
+
def error_from(response)
|
291
|
+
response['errorCode'] || response['status']
|
292
|
+
end
|
293
|
+
|
294
|
+
def post_data(params)
|
295
|
+
params.to_json
|
296
|
+
end
|
297
|
+
|
298
|
+
def add_pos_data(options)
|
299
|
+
pos_options = {}
|
300
|
+
pos_options['panCaptureMethod'] = options[:pan_capture_method]
|
301
|
+
|
302
|
+
pos_options
|
303
|
+
end
|
304
|
+
|
305
|
+
def add_purchases_data(options)
|
306
|
+
purchases = {}
|
307
|
+
|
308
|
+
purchases['dateCreated'] = options[:date_created]
|
309
|
+
purchases['iId'] = options[:i_id]
|
310
|
+
purchases['transactionIId'] = options[:transaction_i_id]
|
311
|
+
purchases['transactionId'] = options[:transaction_id]
|
312
|
+
purchases['name'] = options[:name]
|
313
|
+
purchases['description'] = options[:description]
|
314
|
+
purchases['code'] = options[:code]
|
315
|
+
purchases['unitOfMeasure'] = options[:unit_of_measure]
|
316
|
+
purchases['unitPrice'] = options[:unit_price]
|
317
|
+
purchases['quantity'] = options[:quantity]
|
318
|
+
purchases['taxRate'] = options[:tax_rate]
|
319
|
+
purchases['taxAmount'] = options[:tax_amount]
|
320
|
+
purchases['discountRate'] = options[:discount_rate]
|
321
|
+
purchases['discountAmount'] = options[:discount_amt]
|
322
|
+
purchases['extendedAmount'] = options[:extended_amt]
|
323
|
+
purchases['lineItemId'] = options[:line_item_id]
|
324
|
+
|
325
|
+
purchase_arr = []
|
326
|
+
purchase_arr[0] = purchases
|
327
|
+
purchase_arr
|
328
|
+
end
|
329
|
+
|
330
|
+
def add_risk_data(options)
|
331
|
+
risk = {}
|
332
|
+
risk['cvvResponseCode'] = options[:cvv_response_code]
|
333
|
+
risk['cvvResponse'] = options[:cvv_response]
|
334
|
+
risk['cvvMatch'] = options[:cvv_match]
|
335
|
+
risk['avsResponse'] = options[:avs_response]
|
336
|
+
risk['avsAddressMatch'] = options[:avs_address_match]
|
337
|
+
risk['avsZipMatch'] = options[:avs_zip_match]
|
338
|
+
|
339
|
+
risk
|
340
|
+
end
|
341
|
+
|
342
|
+
def get_hash(string)
|
343
|
+
JSON.parse(string.gsub('=>', ':'))
|
344
|
+
end
|
345
|
+
end
|
346
|
+
end
|
347
|
+
end
|
@@ -151,6 +151,7 @@ module ActiveMerchant
|
|
151
151
|
else
|
152
152
|
add_three_d_secure(xml, options)
|
153
153
|
end
|
154
|
+
add_stored_credential(xml, options)
|
154
155
|
add_comments(xml, options)
|
155
156
|
add_address_and_customer_info(xml, options)
|
156
157
|
end
|
@@ -323,6 +324,23 @@ module ActiveMerchant
|
|
323
324
|
end
|
324
325
|
end
|
325
326
|
|
327
|
+
def add_stored_credential(xml, options)
|
328
|
+
return unless stored_credential = options[:stored_credential]
|
329
|
+
|
330
|
+
xml.tag! 'storedcredential' do
|
331
|
+
xml.tag! 'type', stored_credential_type(stored_credential[:reason_type])
|
332
|
+
xml.tag! 'initiator', stored_credential[:initiator]
|
333
|
+
xml.tag! 'sequence', stored_credential[:initial_transaction] ? 'first' : 'subsequent'
|
334
|
+
xml.tag! 'srd', stored_credential[:network_transaction_id]
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
def stored_credential_type(reason)
|
339
|
+
return 'oneoff' if reason == 'unscheduled'
|
340
|
+
|
341
|
+
reason
|
342
|
+
end
|
343
|
+
|
326
344
|
def format_address_code(address)
|
327
345
|
code = [address[:zip].to_s, address[:address1].to_s + address[:address2].to_s]
|
328
346
|
code.collect { |e| e.gsub(/\D/, '') }.reject(&:empty?).join('|')
|
@@ -62,6 +62,7 @@ module ActiveMerchant #:nodoc:
|
|
62
62
|
post[:sg_CCToken] = token
|
63
63
|
post[:sg_ExpMonth] = exp_month
|
64
64
|
post[:sg_ExpYear] = exp_year
|
65
|
+
post[:sg_Email] = options[:email]
|
65
66
|
|
66
67
|
commit(post)
|
67
68
|
end
|
@@ -126,9 +127,11 @@ module ActiveMerchant #:nodoc:
|
|
126
127
|
private
|
127
128
|
|
128
129
|
def add_transaction_data(trans_type, post, money, options)
|
130
|
+
currency = options[:currency] || currency(money)
|
131
|
+
|
129
132
|
post[:sg_TransType] = trans_type
|
130
|
-
post[:sg_Currency] =
|
131
|
-
post[:sg_Amount] =
|
133
|
+
post[:sg_Currency] = currency
|
134
|
+
post[:sg_Amount] = localized_amount(money, currency)
|
132
135
|
post[:sg_ClientLoginID] = @options[:client_login_id]
|
133
136
|
post[:sg_ClientPassword] = @options[:client_password]
|
134
137
|
post[:sg_ResponseFormat] = '4'
|
@@ -144,6 +147,7 @@ module ActiveMerchant #:nodoc:
|
|
144
147
|
post[:sg_MerchantPhoneNumber] = options[:merchant_phone_number] if options[:merchant_phone_number]
|
145
148
|
post[:sg_MerchantName] = options[:merchant_name] if options[:merchant_name]
|
146
149
|
post[:sg_ProductID] = options[:product_id] if options[:product_id]
|
150
|
+
post[:sg_NotUseCVV] = options[:not_use_cvv].to_s == 'true' ? 1 : 0 unless options[:not_use_cvv].nil?
|
147
151
|
end
|
148
152
|
|
149
153
|
def add_payment(post, payment, options = {})
|
@@ -23,9 +23,9 @@ module ActiveMerchant #:nodoc:
|
|
23
23
|
'unchecked' => 'P'
|
24
24
|
}
|
25
25
|
|
26
|
-
DEFAULT_API_VERSION = '
|
26
|
+
DEFAULT_API_VERSION = '2020-08-27'
|
27
27
|
|
28
|
-
self.supported_countries = %w(AT AU BE BG BR CA CH CY CZ DE DK EE ES FI FR GB GR HK IE IT JP LT LU LV MT MX NL NO NZ PL PT RO SE SG SI SK US)
|
28
|
+
self.supported_countries = %w(AE AT AU BE BG BR CA CH CY CZ DE DK EE ES FI FR GB GR HK HU IE IN IT JP LT LU LV MT MX MY NL NO NZ PL PT RO SE SG SI SK US)
|
29
29
|
self.default_currency = 'USD'
|
30
30
|
self.money_format = :cents
|
31
31
|
self.supported_cardtypes = %i[visa master american_express discover jcb diners_club maestro unionpay]
|
@@ -223,9 +223,10 @@ module ActiveMerchant #:nodoc:
|
|
223
223
|
|
224
224
|
post[:default_card] = r.params['id'] if options[:set_default] && r.success? && !r.params['id'].blank?
|
225
225
|
|
226
|
-
r.process { update_customer(options[:customer], post) } if post.count > 0
|
226
|
+
r.process { update_customer(options[:customer], post.merge(expand: [:sources])) } if post.count > 0
|
227
227
|
end
|
228
228
|
else
|
229
|
+
post[:expand] = [:sources]
|
229
230
|
commit(:post, 'customers', post.merge(params), options)
|
230
231
|
end
|
231
232
|
end
|
@@ -286,13 +287,25 @@ module ActiveMerchant #:nodoc:
|
|
286
287
|
gsub(%r(((\[card\]|card)\[encrypted_pin\]=)[^&]+(&?)), '\1[FILTERED]\3').
|
287
288
|
gsub(%r(((\[card\]|card)\[encrypted_pin_key_id\]=)[\w=]+(&?)), '\1[FILTERED]\3').
|
288
289
|
gsub(%r(((\[card\]|card)\[number\]=)\d+), '\1[FILTERED]').
|
289
|
-
gsub(%r(((\[card\]|card)\[swipe_data\]=)[^&]+(&?)), '\1[FILTERED]\3')
|
290
|
+
gsub(%r(((\[card\]|card)\[swipe_data\]=)[^&]+(&?)), '\1[FILTERED]\3').
|
291
|
+
gsub(%r(((\[bank_account\]|bank_account)\[account_number\]=)\d+), '\1[FILTERED]')
|
290
292
|
end
|
291
293
|
|
292
294
|
def supports_network_tokenization?
|
293
295
|
true
|
294
296
|
end
|
295
297
|
|
298
|
+
# Helper method to prevent hitting the external_account limit from remote test runs
|
299
|
+
def delete_latest_test_external_account(account)
|
300
|
+
return unless test?
|
301
|
+
|
302
|
+
auth_header = { 'Authorization': "Bearer #{options[:login]}" }
|
303
|
+
url = "#{live_url}accounts/#{CGI.escape(account)}/external_accounts"
|
304
|
+
accounts_response = JSON.parse(ssl_get("#{url}?limit=100", auth_header))
|
305
|
+
to_delete = accounts_response['data'].reject { |ac| ac['default_for_currency'] }
|
306
|
+
ssl_request(:delete, "#{url}/#{to_delete.first['id']}", nil, auth_header)
|
307
|
+
end
|
308
|
+
|
296
309
|
private
|
297
310
|
|
298
311
|
class StripePaymentToken < PaymentToken
|
@@ -379,6 +392,7 @@ module ActiveMerchant #:nodoc:
|
|
379
392
|
add_destination(post, options)
|
380
393
|
add_level_three(post, options)
|
381
394
|
add_connected_account(post, options)
|
395
|
+
add_radar_data(post, options)
|
382
396
|
post
|
383
397
|
end
|
384
398
|
|
@@ -532,7 +546,6 @@ module ActiveMerchant #:nodoc:
|
|
532
546
|
post[:metadata].merge!(options[:metadata]) if options[:metadata]
|
533
547
|
post[:metadata][:email] = options[:email] if options[:email]
|
534
548
|
post[:metadata][:order_id] = options[:order_id] if options[:order_id]
|
535
|
-
post.delete(:metadata) if post[:metadata].empty?
|
536
549
|
end
|
537
550
|
|
538
551
|
def add_emv_metadata(post, creditcard)
|
@@ -570,6 +583,14 @@ module ActiveMerchant #:nodoc:
|
|
570
583
|
post[:application_fee_amount] = options[:application_fee_amount] if options[:application_fee_amount]
|
571
584
|
end
|
572
585
|
|
586
|
+
def add_radar_data(post, options = {})
|
587
|
+
radar_options = {}
|
588
|
+
radar_options[:session] = options[:radar_session_id] if options[:radar_session_id]
|
589
|
+
radar_options[:skip_rules] = ['all'] if options[:skip_radar_rules]
|
590
|
+
|
591
|
+
post[:radar_options] = radar_options unless radar_options.empty?
|
592
|
+
end
|
593
|
+
|
573
594
|
def parse(body)
|
574
595
|
JSON.parse(body)
|
575
596
|
end
|
@@ -658,7 +679,6 @@ module ActiveMerchant #:nodoc:
|
|
658
679
|
card = card_from_response(response)
|
659
680
|
avs_code = AVS_CODE_TRANSLATOR["line1: #{card['address_line1_check']}, zip: #{card['address_zip_check']}"]
|
660
681
|
cvc_code = CVC_CODE_TRANSLATOR[card['cvc_check']]
|
661
|
-
|
662
682
|
Response.new(success,
|
663
683
|
message_from(success, response),
|
664
684
|
response,
|
@@ -754,7 +774,7 @@ module ActiveMerchant #:nodoc:
|
|
754
774
|
country: 'US',
|
755
775
|
currency: 'usd',
|
756
776
|
routing_number: bank_account.routing_number,
|
757
|
-
|
777
|
+
account_holder_name: bank_account.name,
|
758
778
|
account_holder_type: account_holder_type
|
759
779
|
}
|
760
780
|
}
|