activemerchant 1.90.0 → 1.99.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +202 -0
- data/README.md +6 -2
- data/lib/active_merchant/billing/avs_result.rb +4 -5
- data/lib/active_merchant/billing/credit_card.rb +8 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +81 -5
- data/lib/active_merchant/billing/gateway.rb +10 -0
- data/lib/active_merchant/billing/gateways/adyen.rb +206 -54
- data/lib/active_merchant/billing/gateways/bambora_apac.rb +226 -0
- data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +43 -10
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +3 -0
- data/lib/active_merchant/billing/gateways/beanstream.rb +11 -6
- data/lib/active_merchant/billing/gateways/blue_pay.rb +10 -8
- data/lib/active_merchant/billing/gateways/blue_snap.rb +211 -36
- data/lib/active_merchant/billing/gateways/bpoint.rb +4 -4
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +79 -18
- data/lib/active_merchant/billing/gateways/card_connect.rb +6 -1
- data/lib/active_merchant/billing/gateways/cecabank.rb +20 -9
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +98 -61
- data/lib/active_merchant/billing/gateways/credorax.rb +69 -4
- data/lib/active_merchant/billing/gateways/cyber_source.rb +85 -14
- data/lib/active_merchant/billing/gateways/d_local.rb +3 -3
- data/lib/active_merchant/billing/gateways/decidir.rb +245 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +9 -0
- data/lib/active_merchant/billing/gateways/epay.rb +13 -2
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +42 -12
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +26 -7
- data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +42 -3
- data/lib/active_merchant/billing/gateways/global_collect.rb +3 -7
- data/lib/active_merchant/billing/gateways/hps.rb +46 -1
- data/lib/active_merchant/billing/gateways/ipp.rb +1 -0
- data/lib/active_merchant/billing/gateways/kushki.rb +1 -1
- data/lib/active_merchant/billing/gateways/litle.rb +61 -3
- data/lib/active_merchant/billing/gateways/mastercard.rb +30 -5
- data/lib/active_merchant/billing/gateways/mercado_pago.rb +1 -1
- data/lib/active_merchant/billing/gateways/migs.rb +8 -0
- data/lib/active_merchant/billing/gateways/monei.rb +31 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +3 -4
- data/lib/active_merchant/billing/gateways/mundipagg.rb +37 -9
- data/lib/active_merchant/billing/gateways/nab_transact.rb +1 -1
- data/lib/active_merchant/billing/gateways/netbanx.rb +4 -0
- data/lib/active_merchant/billing/gateways/nmi.rb +45 -5
- data/lib/active_merchant/billing/gateways/openpay.rb +1 -1
- data/lib/active_merchant/billing/gateways/opp.rb +20 -1
- data/lib/active_merchant/billing/gateways/orbital.rb +92 -11
- data/lib/active_merchant/billing/gateways/payflow.rb +64 -14
- data/lib/active_merchant/billing/gateways/payment_express.rb +7 -0
- data/lib/active_merchant/billing/gateways/paymentez.rb +7 -11
- data/lib/active_merchant/billing/gateways/paymill.rb +5 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +14 -1
- data/lib/active_merchant/billing/gateways/paypal_express.rb +3 -1
- data/lib/active_merchant/billing/gateways/payu_latam.rb +6 -2
- data/lib/active_merchant/billing/gateways/pin.rb +19 -6
- data/lib/active_merchant/billing/gateways/pro_pay.rb +1 -1
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +7 -1
- data/lib/active_merchant/billing/gateways/qvalent.rb +54 -1
- data/lib/active_merchant/billing/gateways/realex.rb +42 -5
- data/lib/active_merchant/billing/gateways/redsys.rb +113 -30
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +43 -29
- data/lib/active_merchant/billing/gateways/stripe.rb +66 -34
- data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +271 -0
- data/lib/active_merchant/billing/gateways/tns.rb +10 -5
- data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +5 -5
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +46 -6
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +19 -8
- data/lib/active_merchant/billing/gateways/visanet_peru.rb +22 -10
- data/lib/active_merchant/billing/gateways/worldpay.rb +237 -34
- data/lib/active_merchant/country.rb +2 -1
- data/lib/active_merchant/version.rb +1 -1
- metadata +20 -4
|
@@ -7,7 +7,7 @@ module ActiveMerchant #:nodoc:
|
|
|
7
7
|
self.default_currency = 'GBP'
|
|
8
8
|
self.money_format = :cents
|
|
9
9
|
self.supported_countries = %w(HK GB AU AD AR BE BR CA CH CN CO CR CY CZ DE DK ES FI FR GI GR HU IE IN IT JP LI LU MC MT MY MX NL NO NZ PA PE PL PT SE SG SI SM TR UM VA)
|
|
10
|
-
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro]
|
|
10
|
+
self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro, :elo, :naranja, :cabal]
|
|
11
11
|
self.currencies_without_fractions = %w(HUF IDR ISK JPY KRW)
|
|
12
12
|
self.currencies_with_three_decimal_places = %w(BHD KWD OMR RSD TND)
|
|
13
13
|
self.homepage_url = 'http://www.worldpay.com/'
|
|
@@ -21,6 +21,30 @@ module ActiveMerchant #:nodoc:
|
|
|
21
21
|
'jcb' => 'JCB-SSL',
|
|
22
22
|
'maestro' => 'MAESTRO-SSL',
|
|
23
23
|
'diners_club' => 'DINERS-SSL',
|
|
24
|
+
'elo' => 'ELO-SSL',
|
|
25
|
+
'naranja' => 'NARANJA-SSL',
|
|
26
|
+
'cabal' => 'CABAL-SSL',
|
|
27
|
+
'unknown' => 'CARD-SSL'
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
AVS_CODE_MAP = {
|
|
31
|
+
'A' => 'M', # Match
|
|
32
|
+
'B' => 'P', # Postcode matches, address not verified
|
|
33
|
+
'C' => 'Z', # Postcode matches, address does not match
|
|
34
|
+
'D' => 'B', # Address matched; postcode not checked
|
|
35
|
+
'E' => 'I', # Address and postal code not checked
|
|
36
|
+
'F' => 'A', # Address matches, postcode does not match
|
|
37
|
+
'G' => 'C', # Address does not match, postcode not checked
|
|
38
|
+
'H' => 'I', # Address and postcode not provided
|
|
39
|
+
'I' => 'C', # Address not checked postcode does not match
|
|
40
|
+
'J' => 'C', # Address and postcode does not match
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
CVC_CODE_MAP = {
|
|
44
|
+
'A' => 'M', # CVV matches
|
|
45
|
+
'B' => 'P', # Not provided
|
|
46
|
+
'C' => 'P', # Not checked
|
|
47
|
+
'D' => 'N', # Does not match
|
|
24
48
|
}
|
|
25
49
|
|
|
26
50
|
def initialize(options = {})
|
|
@@ -37,10 +61,12 @@ module ActiveMerchant #:nodoc:
|
|
|
37
61
|
|
|
38
62
|
def authorize(money, payment_method, options = {})
|
|
39
63
|
requires!(options, :order_id)
|
|
40
|
-
|
|
64
|
+
payment_details = payment_details_from(payment_method)
|
|
65
|
+
authorize_request(money, payment_method, payment_details.merge(options))
|
|
41
66
|
end
|
|
42
67
|
|
|
43
68
|
def capture(money, authorization, options = {})
|
|
69
|
+
authorization = order_id_from_authorization(authorization.to_s)
|
|
44
70
|
MultiResponse.run do |r|
|
|
45
71
|
r.process { inquire_request(authorization, options, 'AUTHORISED') } unless options[:authorization_validated]
|
|
46
72
|
if r.params
|
|
@@ -52,6 +78,7 @@ module ActiveMerchant #:nodoc:
|
|
|
52
78
|
end
|
|
53
79
|
|
|
54
80
|
def void(authorization, options = {})
|
|
81
|
+
authorization = order_id_from_authorization(authorization.to_s)
|
|
55
82
|
MultiResponse.run do |r|
|
|
56
83
|
r.process { inquire_request(authorization, options, 'AUTHORISED') } unless options[:authorization_validated]
|
|
57
84
|
r.process { cancel_request(authorization, options) }
|
|
@@ -59,8 +86,9 @@ module ActiveMerchant #:nodoc:
|
|
|
59
86
|
end
|
|
60
87
|
|
|
61
88
|
def refund(money, authorization, options = {})
|
|
89
|
+
authorization = order_id_from_authorization(authorization.to_s)
|
|
62
90
|
response = MultiResponse.run do |r|
|
|
63
|
-
r.process { inquire_request(authorization, options, 'CAPTURED', 'SETTLED', 'SETTLED_BY_MERCHANT') }
|
|
91
|
+
r.process { inquire_request(authorization, options, 'CAPTURED', 'SETTLED', 'SETTLED_BY_MERCHANT') } unless options[:authorization_validated]
|
|
64
92
|
r.process { refund_request(money, authorization, options) }
|
|
65
93
|
end
|
|
66
94
|
|
|
@@ -75,16 +103,22 @@ module ActiveMerchant #:nodoc:
|
|
|
75
103
|
# and other transactions should be performed on a normal eCom-flagged
|
|
76
104
|
# merchant ID.
|
|
77
105
|
def credit(money, payment_method, options = {})
|
|
78
|
-
|
|
106
|
+
payment_details = payment_details_from(payment_method)
|
|
107
|
+
credit_request(money, payment_method, payment_details.merge(:credit => true, **options))
|
|
79
108
|
end
|
|
80
109
|
|
|
81
|
-
def verify(
|
|
110
|
+
def verify(payment_method, options={})
|
|
82
111
|
MultiResponse.run(:use_first_response) do |r|
|
|
83
|
-
r.process { authorize(100,
|
|
112
|
+
r.process { authorize(100, payment_method, options) }
|
|
84
113
|
r.process(:ignore_result) { void(r.authorization, options.merge(:authorization_validated => true)) }
|
|
85
114
|
end
|
|
86
115
|
end
|
|
87
116
|
|
|
117
|
+
def store(credit_card, options={})
|
|
118
|
+
requires!(options, :customer)
|
|
119
|
+
store_request(credit_card, options)
|
|
120
|
+
end
|
|
121
|
+
|
|
88
122
|
def supports_scrubbing
|
|
89
123
|
true
|
|
90
124
|
end
|
|
@@ -122,6 +156,10 @@ module ActiveMerchant #:nodoc:
|
|
|
122
156
|
commit('credit', build_authorization_request(money, payment_method, options), :ok, 'SENT_FOR_REFUND', options)
|
|
123
157
|
end
|
|
124
158
|
|
|
159
|
+
def store_request(credit_card, options)
|
|
160
|
+
commit('store', build_store_request(credit_card, options), options)
|
|
161
|
+
end
|
|
162
|
+
|
|
125
163
|
def build_request
|
|
126
164
|
xml = Builder::XmlMarkup.new :indent => 2
|
|
127
165
|
xml.instruct! :xml, :encoding => 'UTF-8'
|
|
@@ -162,13 +200,16 @@ module ActiveMerchant #:nodoc:
|
|
|
162
200
|
end
|
|
163
201
|
end
|
|
164
202
|
add_payment_method(xml, money, payment_method, options)
|
|
165
|
-
|
|
203
|
+
add_shopper(xml, options)
|
|
166
204
|
if options[:hcg_additional_data]
|
|
167
205
|
add_hcg_additional_data(xml, options)
|
|
168
206
|
end
|
|
169
207
|
if options[:instalments]
|
|
170
208
|
add_instalments_data(xml, options)
|
|
171
209
|
end
|
|
210
|
+
add_moto_flag(xml, options) if options.dig(:metadata, :manual_entry)
|
|
211
|
+
add_additional_3ds_data(xml, options) if options[:execute_threed] && options[:three_ds_version] && options[:three_ds_version] =~ /^2/
|
|
212
|
+
add_3ds_exemption(xml, options) if options[:exemption_type]
|
|
172
213
|
end
|
|
173
214
|
end
|
|
174
215
|
end
|
|
@@ -202,6 +243,30 @@ module ActiveMerchant #:nodoc:
|
|
|
202
243
|
end
|
|
203
244
|
end
|
|
204
245
|
|
|
246
|
+
def build_store_request(credit_card, options)
|
|
247
|
+
build_request do |xml|
|
|
248
|
+
xml.tag! 'submit' do
|
|
249
|
+
xml.tag! 'paymentTokenCreate' do
|
|
250
|
+
add_authenticated_shopper_id(xml, options)
|
|
251
|
+
xml.tag! 'createToken'
|
|
252
|
+
xml.tag! 'paymentInstrument' do
|
|
253
|
+
xml.tag! 'cardDetails' do
|
|
254
|
+
add_card(xml, credit_card, options)
|
|
255
|
+
end
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
end
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
def add_additional_3ds_data(xml, options)
|
|
263
|
+
xml.tag! 'additional3DSData', 'dfReferenceId' => options[:session_id]
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
def add_3ds_exemption(xml, options)
|
|
267
|
+
xml.tag! 'exemption', 'type' => options[:exemption_type], 'placement' => options[:exemption_placement] || 'AUTHORISATION'
|
|
268
|
+
end
|
|
269
|
+
|
|
205
270
|
def add_amount(xml, money, options)
|
|
206
271
|
currency = options[:currency] || currency(money)
|
|
207
272
|
|
|
@@ -219,7 +284,7 @@ module ActiveMerchant #:nodoc:
|
|
|
219
284
|
end
|
|
220
285
|
|
|
221
286
|
def add_payment_method(xml, amount, payment_method, options)
|
|
222
|
-
if
|
|
287
|
+
if options[:payment_type] == :pay_as_order
|
|
223
288
|
if options[:merchant_code]
|
|
224
289
|
xml.tag! 'payAsOrder', 'orderCode' => payment_method, 'merchantCode' => options[:merchant_code] do
|
|
225
290
|
add_amount(xml, amount, options)
|
|
@@ -231,29 +296,82 @@ module ActiveMerchant #:nodoc:
|
|
|
231
296
|
end
|
|
232
297
|
else
|
|
233
298
|
xml.tag! 'paymentDetails', credit_fund_transfer_attribute(options) do
|
|
234
|
-
|
|
235
|
-
xml.tag! '
|
|
236
|
-
|
|
237
|
-
|
|
299
|
+
if options[:payment_type] == :token
|
|
300
|
+
xml.tag! 'TOKEN-SSL', 'tokenScope' => options[:token_scope] do
|
|
301
|
+
xml.tag! 'paymentTokenID', options[:token_id]
|
|
302
|
+
end
|
|
303
|
+
else
|
|
304
|
+
xml.tag! card_code_for(payment_method) do
|
|
305
|
+
add_card(xml, payment_method, options)
|
|
238
306
|
end
|
|
239
|
-
|
|
240
|
-
xml.tag! 'cardHolderName', options[:execute_threed] ? '3D' : payment_method.name
|
|
241
|
-
xml.tag! 'cvc', payment_method.verification_value
|
|
242
|
-
|
|
243
|
-
add_address(xml, (options[:billing_address] || options[:address]))
|
|
244
307
|
end
|
|
308
|
+
add_stored_credential_options(xml, options)
|
|
245
309
|
if options[:ip] && options[:session_id]
|
|
246
310
|
xml.tag! 'session', 'shopperIPAddress' => options[:ip], 'id' => options[:session_id]
|
|
247
311
|
else
|
|
248
312
|
xml.tag! 'session', 'shopperIPAddress' => options[:ip] if options[:ip]
|
|
249
313
|
xml.tag! 'session', 'id' => options[:session_id] if options[:session_id]
|
|
250
314
|
end
|
|
251
|
-
|
|
315
|
+
|
|
316
|
+
if three_d_secure = options[:three_d_secure]
|
|
317
|
+
add_three_d_secure(three_d_secure, xml)
|
|
318
|
+
end
|
|
319
|
+
end
|
|
320
|
+
end
|
|
321
|
+
end
|
|
322
|
+
|
|
323
|
+
def add_three_d_secure(three_d_secure, xml)
|
|
324
|
+
xml.tag! 'info3DSecure' do
|
|
325
|
+
xml.tag! 'threeDSVersion', three_d_secure[:version]
|
|
326
|
+
if three_d_secure[:version] =~ /^2/
|
|
327
|
+
xml.tag! 'dsTransactionId', three_d_secure[:ds_transaction_id]
|
|
328
|
+
else
|
|
329
|
+
xml.tag! 'xid', three_d_secure[:xid]
|
|
252
330
|
end
|
|
331
|
+
xml.tag! 'cavv', three_d_secure[:cavv]
|
|
332
|
+
xml.tag! 'eci', three_d_secure[:eci]
|
|
333
|
+
end
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
def add_card(xml, payment_method, options)
|
|
337
|
+
xml.tag! 'cardNumber', payment_method.number
|
|
338
|
+
xml.tag! 'expiryDate' do
|
|
339
|
+
xml.tag! 'date', 'month' => format(payment_method.month, :two_digits), 'year' => format(payment_method.year, :four_digits)
|
|
253
340
|
end
|
|
341
|
+
|
|
342
|
+
xml.tag! 'cardHolderName', options[:execute_threed] && (options[:three_ds_version] =~ /[^2]/).nil? ? '3D' : payment_method.name
|
|
343
|
+
xml.tag! 'cvc', payment_method.verification_value
|
|
344
|
+
|
|
345
|
+
add_address(xml, (options[:billing_address] || options[:address]))
|
|
254
346
|
end
|
|
255
347
|
|
|
256
348
|
def add_stored_credential_options(xml, options={})
|
|
349
|
+
if options[:stored_credential]
|
|
350
|
+
add_stored_credential_using_normalized_fields(xml, options)
|
|
351
|
+
else
|
|
352
|
+
add_stored_credential_using_gateway_specific_fields(xml, options)
|
|
353
|
+
end
|
|
354
|
+
end
|
|
355
|
+
|
|
356
|
+
def add_stored_credential_using_normalized_fields(xml, options)
|
|
357
|
+
if options[:stored_credential][:initial_transaction]
|
|
358
|
+
xml.tag! 'storedCredentials', 'usage' => 'FIRST'
|
|
359
|
+
else
|
|
360
|
+
reason = case options[:stored_credential][:reason_type]
|
|
361
|
+
when 'installment' then 'INSTALMENT'
|
|
362
|
+
when 'recurring' then 'RECURRING'
|
|
363
|
+
when 'unscheduled' then 'UNSCHEDULED'
|
|
364
|
+
end
|
|
365
|
+
|
|
366
|
+
xml.tag! 'storedCredentials', 'usage' => 'USED', 'merchantInitiatedReason' => reason do
|
|
367
|
+
xml.tag! 'schemeTransactionIdentifier', options[:stored_credential][:network_transaction_id] if options[:stored_credential][:network_transaction_id]
|
|
368
|
+
end
|
|
369
|
+
end
|
|
370
|
+
end
|
|
371
|
+
|
|
372
|
+
def add_stored_credential_using_gateway_specific_fields(xml, options)
|
|
373
|
+
return unless options[:stored_credential_usage]
|
|
374
|
+
|
|
257
375
|
if options[:stored_credential_initiated_reason]
|
|
258
376
|
xml.tag! 'storedCredentials', 'usage' => options[:stored_credential_usage], 'merchantInitiatedReason' => options[:stored_credential_initiated_reason] do
|
|
259
377
|
xml.tag! 'schemeTransactionIdentifier', options[:stored_credential_transaction_id] if options[:stored_credential_transaction_id]
|
|
@@ -263,10 +381,11 @@ module ActiveMerchant #:nodoc:
|
|
|
263
381
|
end
|
|
264
382
|
end
|
|
265
383
|
|
|
266
|
-
def
|
|
267
|
-
return unless options[:execute_threed] || options[:email]
|
|
384
|
+
def add_shopper(xml, options)
|
|
385
|
+
return unless options[:execute_threed] || options[:email] || options[:customer]
|
|
268
386
|
xml.tag! 'shopper' do
|
|
269
387
|
xml.tag! 'shopperEmailAddress', options[:email] if options[:email]
|
|
388
|
+
add_authenticated_shopper_id(xml, options)
|
|
270
389
|
xml.tag! 'browser' do
|
|
271
390
|
xml.tag! 'acceptHeader', options[:accept_header]
|
|
272
391
|
xml.tag! 'userAgentHeader', options[:user_agent]
|
|
@@ -274,6 +393,10 @@ module ActiveMerchant #:nodoc:
|
|
|
274
393
|
end
|
|
275
394
|
end
|
|
276
395
|
|
|
396
|
+
def add_authenticated_shopper_id(xml, options)
|
|
397
|
+
xml.tag!('authenticatedShopperID', options[:customer]) if options[:customer]
|
|
398
|
+
end
|
|
399
|
+
|
|
277
400
|
def add_address(xml, address)
|
|
278
401
|
return unless address
|
|
279
402
|
|
|
@@ -311,6 +434,10 @@ module ActiveMerchant #:nodoc:
|
|
|
311
434
|
end
|
|
312
435
|
end
|
|
313
436
|
|
|
437
|
+
def add_moto_flag(xml, options)
|
|
438
|
+
xml.tag! 'dynamicInteractionType', 'type' => 'MOTO'
|
|
439
|
+
end
|
|
440
|
+
|
|
314
441
|
def address_with_defaults(address)
|
|
315
442
|
address ||= {}
|
|
316
443
|
address.delete_if { |_, v| v.blank? }
|
|
@@ -332,14 +459,17 @@ module ActiveMerchant #:nodoc:
|
|
|
332
459
|
end
|
|
333
460
|
|
|
334
461
|
def parse_element(raw, node)
|
|
462
|
+
node_name = node.name.underscore
|
|
335
463
|
node.attributes.each do |k, v|
|
|
336
|
-
raw["#{
|
|
464
|
+
raw["#{node_name}_#{k.underscore}".to_sym] = v
|
|
337
465
|
end
|
|
338
466
|
if node.has_elements?
|
|
339
|
-
raw[
|
|
467
|
+
raw[node_name.to_sym] = true unless node.name.blank?
|
|
340
468
|
node.elements.each { |e| parse_element(raw, e) }
|
|
469
|
+
elsif node.children.count > 1
|
|
470
|
+
raw[node_name.to_sym] = node.children.join(' ').strip
|
|
341
471
|
else
|
|
342
|
-
raw[
|
|
472
|
+
raw[node_name.to_sym] = node.text unless node.text.nil?
|
|
343
473
|
end
|
|
344
474
|
raw
|
|
345
475
|
end
|
|
@@ -361,16 +491,21 @@ module ActiveMerchant #:nodoc:
|
|
|
361
491
|
if options[:execute_threed]
|
|
362
492
|
raw[:cookie] = @cookie
|
|
363
493
|
raw[:session_id] = options[:session_id]
|
|
494
|
+
raw[:is3DSOrder] = true
|
|
364
495
|
end
|
|
365
|
-
success
|
|
496
|
+
success = success_from(action, raw, success_criteria)
|
|
497
|
+
message = message_from(success, raw, success_criteria)
|
|
366
498
|
|
|
367
499
|
Response.new(
|
|
368
500
|
success,
|
|
369
501
|
message,
|
|
370
502
|
raw,
|
|
371
|
-
:authorization => authorization_from(raw),
|
|
503
|
+
:authorization => authorization_from(action, raw, options),
|
|
372
504
|
:error_code => error_code_from(success, raw),
|
|
373
|
-
:test => test
|
|
505
|
+
:test => test?,
|
|
506
|
+
:avs_result => AVSResult.new(code: AVS_CODE_MAP[raw[:avs_result_code_description]]),
|
|
507
|
+
:cvv_result => CVVResult.new(CVC_CODE_MAP[raw[:cvc_result_code_description]])
|
|
508
|
+
)
|
|
374
509
|
rescue ActiveMerchant::ResponseError => e
|
|
375
510
|
if e.response.code.to_s == '401'
|
|
376
511
|
return Response.new(false, 'Invalid credentials', {}, :test => test?)
|
|
@@ -395,19 +530,30 @@ module ActiveMerchant #:nodoc:
|
|
|
395
530
|
end
|
|
396
531
|
end
|
|
397
532
|
|
|
533
|
+
def success_from(action, raw, success_criteria)
|
|
534
|
+
success_criteria_success?(raw, success_criteria) || action_success?(action, raw)
|
|
535
|
+
end
|
|
536
|
+
|
|
537
|
+
def message_from(success, raw, success_criteria)
|
|
538
|
+
return 'SUCCESS' if success
|
|
539
|
+
raw[:iso8583_return_code_description] || raw[:error] || required_status_message(raw, success_criteria)
|
|
540
|
+
end
|
|
541
|
+
|
|
398
542
|
# success_criteria can be:
|
|
399
543
|
# - a string or an array of strings (if one of many responses)
|
|
400
544
|
# - An array of strings if one of many responses could be considered a
|
|
401
545
|
# success.
|
|
402
|
-
def
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
546
|
+
def success_criteria_success?(raw, success_criteria)
|
|
547
|
+
success_criteria.include?(raw[:last_event]) || raw[:ok].present?
|
|
548
|
+
end
|
|
549
|
+
|
|
550
|
+
def action_success?(action, raw)
|
|
551
|
+
case action
|
|
552
|
+
when 'store'
|
|
553
|
+
raw[:token].present?
|
|
406
554
|
else
|
|
407
|
-
|
|
555
|
+
false
|
|
408
556
|
end
|
|
409
|
-
|
|
410
|
-
[ success, message ]
|
|
411
557
|
end
|
|
412
558
|
|
|
413
559
|
def error_code_from(success, raw)
|
|
@@ -422,11 +568,64 @@ module ActiveMerchant #:nodoc:
|
|
|
422
568
|
end
|
|
423
569
|
end
|
|
424
570
|
|
|
425
|
-
def authorization_from(raw)
|
|
571
|
+
def authorization_from(action, raw, options)
|
|
572
|
+
order_id = order_id_from(raw)
|
|
573
|
+
|
|
574
|
+
case action
|
|
575
|
+
when 'store'
|
|
576
|
+
authorization_from_token_details(
|
|
577
|
+
order_id: order_id,
|
|
578
|
+
token_id: raw[:payment_token_id],
|
|
579
|
+
token_scope: 'shopper',
|
|
580
|
+
customer: options[:customer]
|
|
581
|
+
)
|
|
582
|
+
else
|
|
583
|
+
order_id
|
|
584
|
+
end
|
|
585
|
+
end
|
|
586
|
+
|
|
587
|
+
def order_id_from(raw)
|
|
426
588
|
pair = raw.detect { |k, v| k.to_s =~ /_order_code$/ }
|
|
427
589
|
(pair ? pair.last : nil)
|
|
428
590
|
end
|
|
429
591
|
|
|
592
|
+
def authorization_from_token_details(options={})
|
|
593
|
+
[options[:order_id], options[:token_id], options[:token_scope], options[:customer]].join('|')
|
|
594
|
+
end
|
|
595
|
+
|
|
596
|
+
def order_id_from_authorization(authorization)
|
|
597
|
+
token_details_from_authorization(authorization)[:order_id]
|
|
598
|
+
end
|
|
599
|
+
|
|
600
|
+
def token_details_from_authorization(authorization)
|
|
601
|
+
order_id, token_id, token_scope, customer = authorization.split('|')
|
|
602
|
+
|
|
603
|
+
token_details = {}
|
|
604
|
+
token_details[:order_id] = order_id if order_id.present?
|
|
605
|
+
token_details[:token_id] = token_id if token_id.present?
|
|
606
|
+
token_details[:token_scope] = token_scope if token_scope.present?
|
|
607
|
+
token_details[:customer] = customer if customer.present?
|
|
608
|
+
|
|
609
|
+
token_details
|
|
610
|
+
end
|
|
611
|
+
|
|
612
|
+
def payment_details_from(payment_method)
|
|
613
|
+
payment_details = {}
|
|
614
|
+
if payment_method.respond_to?(:number)
|
|
615
|
+
payment_details[:payment_type] = :credit
|
|
616
|
+
else
|
|
617
|
+
token_details = token_details_from_authorization(payment_method)
|
|
618
|
+
payment_details.merge!(token_details)
|
|
619
|
+
if token_details.has_key?(:token_id)
|
|
620
|
+
payment_details[:payment_type] = :token
|
|
621
|
+
else
|
|
622
|
+
payment_details[:payment_type] = :pay_as_order
|
|
623
|
+
end
|
|
624
|
+
end
|
|
625
|
+
|
|
626
|
+
payment_details
|
|
627
|
+
end
|
|
628
|
+
|
|
430
629
|
def credit_fund_transfer_attribute(options)
|
|
431
630
|
return unless options[:credit]
|
|
432
631
|
{'action' => 'REFUND'}
|
|
@@ -442,6 +641,10 @@ module ActiveMerchant #:nodoc:
|
|
|
442
641
|
return 3 if three_decimal_currency?(currency)
|
|
443
642
|
return 2
|
|
444
643
|
end
|
|
644
|
+
|
|
645
|
+
def card_code_for(payment_method)
|
|
646
|
+
CARD_CODES[card_brand(payment_method)] || CARD_CODES['unknown']
|
|
647
|
+
end
|
|
445
648
|
end
|
|
446
649
|
end
|
|
447
650
|
end
|
|
@@ -183,6 +183,7 @@ module ActiveMerchant #:nodoc:
|
|
|
183
183
|
{ alpha2: 'KI', name: 'Kiribati', alpha3: 'KIR', numeric: '296' },
|
|
184
184
|
{ alpha2: 'KP', name: 'Korea, Democratic People\'s Republic of', alpha3: 'PRK', numeric: '408' },
|
|
185
185
|
{ alpha2: 'KR', name: 'Korea, Republic of', alpha3: 'KOR', numeric: '410' },
|
|
186
|
+
{ alpha2: 'XK', name: 'Kosovo', alpha3: 'XKX', numeric: '900' },
|
|
186
187
|
{ alpha2: 'KW', name: 'Kuwait', alpha3: 'KWT', numeric: '414' },
|
|
187
188
|
{ alpha2: 'KG', name: 'Kyrgyzstan', alpha3: 'KGZ', numeric: '417' },
|
|
188
189
|
{ alpha2: 'LA', name: 'Lao People\'s Democratic Republic', alpha3: 'LAO', numeric: '418' },
|
|
@@ -245,8 +246,8 @@ module ActiveMerchant #:nodoc:
|
|
|
245
246
|
{ alpha2: 'PR', name: 'Puerto Rico', alpha3: 'PRI', numeric: '630' },
|
|
246
247
|
{ alpha2: 'QA', name: 'Qatar', alpha3: 'QAT', numeric: '634' },
|
|
247
248
|
{ alpha2: 'RE', name: 'Reunion', alpha3: 'REU', numeric: '638' },
|
|
248
|
-
{ alpha2: 'RO', name: 'Romania', alpha3: 'ROM', numeric: '642' },
|
|
249
249
|
{ alpha2: 'RO', name: 'Romania', alpha3: 'ROU', numeric: '642' },
|
|
250
|
+
{ alpha2: 'RO', name: 'Romania', alpha3: 'ROM', numeric: '642' },
|
|
250
251
|
{ alpha2: 'RU', name: 'Russian Federation', alpha3: 'RUS', numeric: '643' },
|
|
251
252
|
{ alpha2: 'RW', name: 'Rwanda', alpha3: 'RWA', numeric: '646' },
|
|
252
253
|
{ alpha2: 'BL', name: 'Saint Barthélemy', alpha3: 'BLM', numeric: '652' },
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: activemerchant
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.99.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tobias Luetke
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2019-
|
|
11
|
+
date: 2019-09-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -128,6 +128,20 @@ dependencies:
|
|
|
128
128
|
- - ">="
|
|
129
129
|
- !ruby/object:Gem::Version
|
|
130
130
|
version: '0'
|
|
131
|
+
- !ruby/object:Gem::Dependency
|
|
132
|
+
name: pry
|
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
|
134
|
+
requirements:
|
|
135
|
+
- - ">="
|
|
136
|
+
- !ruby/object:Gem::Version
|
|
137
|
+
version: '0'
|
|
138
|
+
type: :development
|
|
139
|
+
prerelease: false
|
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
141
|
+
requirements:
|
|
142
|
+
- - ">="
|
|
143
|
+
- !ruby/object:Gem::Version
|
|
144
|
+
version: '0'
|
|
131
145
|
description: Active Merchant is a simple payment abstraction library used in and sponsored
|
|
132
146
|
by Shopify. It is written by Tobias Luetke, Cody Fauser, and contributors. The aim
|
|
133
147
|
of the project is to feel natural to Ruby users and to abstract as many parts as
|
|
@@ -162,6 +176,7 @@ files:
|
|
|
162
176
|
- lib/active_merchant/billing/gateways/authorize_net_cim.rb
|
|
163
177
|
- lib/active_merchant/billing/gateways/axcessms.rb
|
|
164
178
|
- lib/active_merchant/billing/gateways/balanced.rb
|
|
179
|
+
- lib/active_merchant/billing/gateways/bambora_apac.rb
|
|
165
180
|
- lib/active_merchant/billing/gateways/bank_frick.rb
|
|
166
181
|
- lib/active_merchant/billing/gateways/banwire.rb
|
|
167
182
|
- lib/active_merchant/billing/gateways/barclaycard_smartpay.rb
|
|
@@ -203,6 +218,7 @@ files:
|
|
|
203
218
|
- lib/active_merchant/billing/gateways/cyber_source.rb
|
|
204
219
|
- lib/active_merchant/billing/gateways/d_local.rb
|
|
205
220
|
- lib/active_merchant/billing/gateways/data_cash.rb
|
|
221
|
+
- lib/active_merchant/billing/gateways/decidir.rb
|
|
206
222
|
- lib/active_merchant/billing/gateways/dibs.rb
|
|
207
223
|
- lib/active_merchant/billing/gateways/digitzs.rb
|
|
208
224
|
- lib/active_merchant/billing/gateways/ebanx.rb
|
|
@@ -348,6 +364,7 @@ files:
|
|
|
348
364
|
- lib/active_merchant/billing/gateways/so_easy_pay.rb
|
|
349
365
|
- lib/active_merchant/billing/gateways/spreedly_core.rb
|
|
350
366
|
- lib/active_merchant/billing/gateways/stripe.rb
|
|
367
|
+
- lib/active_merchant/billing/gateways/stripe_payment_intents.rb
|
|
351
368
|
- lib/active_merchant/billing/gateways/swipe_checkout.rb
|
|
352
369
|
- lib/active_merchant/billing/gateways/telr.rb
|
|
353
370
|
- lib/active_merchant/billing/gateways/tns.rb
|
|
@@ -411,8 +428,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
411
428
|
- !ruby/object:Gem::Version
|
|
412
429
|
version: '0'
|
|
413
430
|
requirements: []
|
|
414
|
-
|
|
415
|
-
rubygems_version: 2.7.6
|
|
431
|
+
rubygems_version: 3.0.3
|
|
416
432
|
signing_key:
|
|
417
433
|
specification_version: 4
|
|
418
434
|
summary: Framework and tools for dealing with credit card transactions.
|