activemerchant 1.133.0 → 1.137.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 +240 -0
- data/lib/active_merchant/billing/check.rb +2 -2
- data/lib/active_merchant/billing/compatibility.rb +4 -4
- data/lib/active_merchant/billing/credit_card.rb +11 -8
- data/lib/active_merchant/billing/credit_card_formatting.rb +4 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +59 -6
- data/lib/active_merchant/billing/gateway.rb +9 -0
- data/lib/active_merchant/billing/gateways/adyen.rb +162 -43
- data/lib/active_merchant/billing/gateways/airwallex.rb +26 -12
- data/lib/active_merchant/billing/gateways/alelo.rb +23 -5
- data/lib/active_merchant/billing/gateways/authorize_net.rb +43 -35
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +10 -6
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +1 -3
- data/lib/active_merchant/billing/gateways/axcessms.rb +6 -2
- data/lib/active_merchant/billing/gateways/banwire.rb +4 -2
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +7 -3
- data/lib/active_merchant/billing/gateways/blue_pay.rb +13 -5
- data/lib/active_merchant/billing/gateways/blue_snap.rb +5 -5
- data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +65 -20
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +226 -73
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +1 -1
- data/lib/active_merchant/billing/gateways/card_connect.rb +5 -2
- data/lib/active_merchant/billing/gateways/card_stream.rb +4 -6
- data/lib/active_merchant/billing/gateways/cashnet.rb +1 -1
- data/lib/active_merchant/billing/gateways/cecabank/cecabank_common.rb +36 -0
- data/lib/active_merchant/billing/gateways/cecabank/cecabank_json.rb +316 -0
- data/lib/active_merchant/billing/gateways/cecabank/cecabank_xml.rb +220 -0
- data/lib/active_merchant/billing/gateways/cecabank.rb +7 -240
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +238 -34
- data/lib/active_merchant/billing/gateways/commerce_hub.rb +63 -6
- data/lib/active_merchant/billing/gateways/credorax.rb +3 -5
- data/lib/active_merchant/billing/gateways/cyber_source.rb +185 -47
- data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +102 -58
- data/lib/active_merchant/billing/gateways/d_local.rb +26 -15
- data/lib/active_merchant/billing/gateways/data_cash.rb +21 -17
- data/lib/active_merchant/billing/gateways/datatrans.rb +279 -0
- data/lib/active_merchant/billing/gateways/decidir.rb +53 -18
- data/lib/active_merchant/billing/gateways/decidir_plus.rb +4 -1
- data/lib/active_merchant/billing/gateways/deepstack.rb +382 -0
- data/lib/active_merchant/billing/gateways/ebanx.rb +40 -36
- data/lib/active_merchant/billing/gateways/efsnet.rb +6 -2
- data/lib/active_merchant/billing/gateways/elavon.rb +99 -33
- data/lib/active_merchant/billing/gateways/element.rb +36 -7
- data/lib/active_merchant/billing/gateways/epay.rb +6 -2
- data/lib/active_merchant/billing/gateways/evo_ca.rb +6 -2
- data/lib/active_merchant/billing/gateways/eway.rb +4 -2
- data/lib/active_merchant/billing/gateways/eway_managed.rb +6 -2
- data/lib/active_merchant/billing/gateways/exact.rb +6 -2
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +31 -3
- data/lib/active_merchant/billing/gateways/federated_canada.rb +6 -2
- data/lib/active_merchant/billing/gateways/first_pay/first_pay_common.rb +15 -0
- data/lib/active_merchant/billing/gateways/first_pay/first_pay_json.rb +190 -0
- data/lib/active_merchant/billing/gateways/first_pay/first_pay_xml.rb +183 -0
- data/lib/active_merchant/billing/gateways/first_pay.rb +6 -172
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +6 -2
- data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +7 -3
- data/lib/active_merchant/billing/gateways/flex_charge.rb +347 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +4 -2
- data/lib/active_merchant/billing/gateways/global_collect.rb +45 -37
- data/lib/active_merchant/billing/gateways/hi_pay.rb +286 -0
- data/lib/active_merchant/billing/gateways/hps.rb +1 -1
- data/lib/active_merchant/billing/gateways/iats_payments.rb +7 -2
- data/lib/active_merchant/billing/gateways/inspire.rb +6 -4
- data/lib/active_merchant/billing/gateways/instapay.rb +7 -4
- data/lib/active_merchant/billing/gateways/ipg.rb +9 -5
- data/lib/active_merchant/billing/gateways/iridium.rb +15 -5
- data/lib/active_merchant/billing/gateways/itransact.rb +6 -2
- data/lib/active_merchant/billing/gateways/iveri.rb +3 -3
- data/lib/active_merchant/billing/gateways/ixopay.rb +2 -2
- data/lib/active_merchant/billing/gateways/jetpay.rb +4 -2
- data/lib/active_merchant/billing/gateways/jetpay_v2.rb +4 -2
- data/lib/active_merchant/billing/gateways/kushki.rb +72 -12
- data/lib/active_merchant/billing/gateways/linkpoint.rb +6 -2
- data/lib/active_merchant/billing/gateways/litle.rb +33 -50
- data/lib/active_merchant/billing/gateways/mastercard.rb +4 -4
- data/lib/active_merchant/billing/gateways/maxipago.rb +2 -2
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +8 -5
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +11 -4
- data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +11 -4
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +19 -3
- data/lib/active_merchant/billing/gateways/mercury.rb +6 -2
- data/lib/active_merchant/billing/gateways/metrics_global.rb +8 -6
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +1 -0
- data/lib/active_merchant/billing/gateways/migs.rb +6 -2
- data/lib/active_merchant/billing/gateways/mit.rb +8 -3
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +18 -10
- data/lib/active_merchant/billing/gateways/monei.rb +1 -1
- data/lib/active_merchant/billing/gateways/moneris.rb +9 -3
- data/lib/active_merchant/billing/gateways/money_movers.rb +6 -2
- data/lib/active_merchant/billing/gateways/nab_transact.rb +12 -4
- data/lib/active_merchant/billing/gateways/net_registry.rb +6 -2
- data/lib/active_merchant/billing/gateways/netbanx.rb +1 -3
- data/lib/active_merchant/billing/gateways/netbilling.rb +6 -2
- data/lib/active_merchant/billing/gateways/network_merchants.rb +6 -2
- data/lib/active_merchant/billing/gateways/nmi.rb +18 -6
- data/lib/active_merchant/billing/gateways/ogone.rb +6 -2
- data/lib/active_merchant/billing/gateways/openpay.rb +4 -2
- data/lib/active_merchant/billing/gateways/opp.rb +1 -2
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +6 -2
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +1 -3
- data/lib/active_merchant/billing/gateways/orbital.rb +83 -24
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +7 -4
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +6 -2
- data/lib/active_merchant/billing/gateways/pay_hub.rb +4 -2
- data/lib/active_merchant/billing/gateways/pay_junction.rb +6 -2
- data/lib/active_merchant/billing/gateways/pay_secure.rb +6 -2
- data/lib/active_merchant/billing/gateways/pay_trace.rb +31 -18
- data/lib/active_merchant/billing/gateways/payeezy.rb +19 -8
- data/lib/active_merchant/billing/gateways/payex.rb +4 -2
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -1
- data/lib/active_merchant/billing/gateways/payflow.rb +1 -3
- data/lib/active_merchant/billing/gateways/payment_express.rb +8 -4
- data/lib/active_merchant/billing/gateways/paymentez.rb +23 -11
- data/lib/active_merchant/billing/gateways/paysafe.rb +12 -11
- data/lib/active_merchant/billing/gateways/payscout.rb +7 -4
- data/lib/active_merchant/billing/gateways/paystation.rb +7 -3
- data/lib/active_merchant/billing/gateways/payway.rb +6 -2
- data/lib/active_merchant/billing/gateways/payway_dot_com.rb +2 -2
- data/lib/active_merchant/billing/gateways/pin.rb +22 -4
- data/lib/active_merchant/billing/gateways/plexo.rb +49 -10
- data/lib/active_merchant/billing/gateways/plugnpay.rb +6 -2
- data/lib/active_merchant/billing/gateways/priority.rb +6 -5
- data/lib/active_merchant/billing/gateways/psigate.rb +6 -2
- data/lib/active_merchant/billing/gateways/psl_card.rb +6 -2
- data/lib/active_merchant/billing/gateways/qbms.rb +6 -2
- data/lib/active_merchant/billing/gateways/quantum.rb +6 -2
- data/lib/active_merchant/billing/gateways/quickbooks.rb +6 -5
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +7 -4
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +6 -2
- data/lib/active_merchant/billing/gateways/rapyd.rb +148 -46
- data/lib/active_merchant/billing/gateways/reach.rb +11 -4
- data/lib/active_merchant/billing/gateways/redsys.rb +2 -10
- data/lib/active_merchant/billing/gateways/redsys_rest.rb +507 -0
- data/lib/active_merchant/billing/gateways/s5.rb +3 -3
- data/lib/active_merchant/billing/gateways/safe_charge.rb +36 -16
- data/lib/active_merchant/billing/gateways/sage.rb +12 -4
- data/lib/active_merchant/billing/gateways/sage_pay.rb +79 -5
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +6 -2
- data/lib/active_merchant/billing/gateways/secure_net.rb +6 -2
- data/lib/active_merchant/billing/gateways/secure_pay.rb +8 -6
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +12 -4
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +6 -2
- data/lib/active_merchant/billing/gateways/securion_pay.rb +24 -10
- data/lib/active_merchant/billing/gateways/shift4.rb +17 -20
- data/lib/active_merchant/billing/gateways/shift4_v2.rb +117 -0
- data/lib/active_merchant/billing/gateways/simetrik.rb +17 -11
- data/lib/active_merchant/billing/gateways/skip_jack.rb +6 -2
- data/lib/active_merchant/billing/gateways/smart_ps.rb +7 -4
- data/lib/active_merchant/billing/gateways/so_easy_pay.rb +4 -2
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +2 -4
- data/lib/active_merchant/billing/gateways/stripe.rb +53 -21
- data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +199 -50
- data/lib/active_merchant/billing/gateways/sum_up.rb +223 -0
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +4 -2
- data/lib/active_merchant/billing/gateways/telr.rb +3 -4
- data/lib/active_merchant/billing/gateways/trans_first.rb +1 -2
- data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +8 -16
- data/lib/active_merchant/billing/gateways/transact_pro.rb +1 -1
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +6 -2
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +9 -8
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +6 -2
- data/lib/active_merchant/billing/gateways/vanco.rb +2 -4
- data/lib/active_merchant/billing/gateways/vantiv_express.rb +587 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +6 -2
- data/lib/active_merchant/billing/gateways/viaklix.rb +6 -2
- data/lib/active_merchant/billing/gateways/visanet_peru.rb +2 -2
- data/lib/active_merchant/billing/gateways/vpos.rb +3 -3
- data/lib/active_merchant/billing/gateways/wirecard.rb +7 -3
- data/lib/active_merchant/billing/gateways/wompi.rb +5 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +140 -73
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +13 -10
- data/lib/active_merchant/billing/gateways/xpay.rb +242 -0
- data/lib/active_merchant/billing/network_tokenization_credit_card.rb +1 -1
- data/lib/active_merchant/billing/response.rb +2 -2
- data/lib/active_merchant/connection.rb +3 -17
- data/lib/active_merchant/country.rb +1 -0
- data/lib/active_merchant/errors.rb +10 -0
- data/lib/active_merchant/version.rb +1 -1
- data/lib/support/gateway_support.rb +2 -2
- data/lib/support/ssl_verify.rb +4 -4
- data/lib/support/ssl_version.rb +6 -6
- metadata +30 -9
@@ -75,9 +75,12 @@ module ActiveMerchant #:nodoc:
|
|
75
75
|
@braintree_gateway = Braintree::Gateway.new(@configuration)
|
76
76
|
end
|
77
77
|
|
78
|
-
def setup_purchase
|
78
|
+
def setup_purchase(options = {})
|
79
|
+
post = {}
|
80
|
+
add_merchant_account_id(post, options)
|
81
|
+
|
79
82
|
commit do
|
80
|
-
Response.new(true, 'Client token created', { client_token: @braintree_gateway.client_token.generate })
|
83
|
+
Response.new(true, 'Client token created', { client_token: @braintree_gateway.client_token.generate(post) })
|
81
84
|
end
|
82
85
|
end
|
83
86
|
|
@@ -106,6 +109,8 @@ module ActiveMerchant #:nodoc:
|
|
106
109
|
end
|
107
110
|
|
108
111
|
def credit(money, credit_card_or_vault_id, options = {})
|
112
|
+
return Response.new(false, DIRECT_BANK_ERROR) if credit_card_or_vault_id.is_a? Check
|
113
|
+
|
109
114
|
create_transaction(:credit, money, credit_card_or_vault_id, options)
|
110
115
|
end
|
111
116
|
|
@@ -139,16 +144,25 @@ module ActiveMerchant #:nodoc:
|
|
139
144
|
exp_month = creditcard.month.to_s
|
140
145
|
exp_year = creditcard.year.to_s
|
141
146
|
expiration = "#{exp_month}/#{exp_year}"
|
147
|
+
zip = options[:billing_address].try(:[], :zip)
|
148
|
+
address1 = options[:billing_address].try(:[], :address1)
|
142
149
|
payload = {
|
143
150
|
credit_card: {
|
144
151
|
number: creditcard.number,
|
145
152
|
expiration_date: expiration,
|
146
|
-
cvv: creditcard.verification_value
|
147
|
-
billing_address: {
|
148
|
-
postal_code: options[:billing_address][:zip]
|
149
|
-
}
|
153
|
+
cvv: creditcard.verification_value
|
150
154
|
}
|
151
155
|
}
|
156
|
+
if zip || address1
|
157
|
+
payload[:credit_card][:billing_address] = {}
|
158
|
+
payload[:credit_card][:billing_address][:postal_code] = zip if zip
|
159
|
+
payload[:credit_card][:billing_address][:street_address] = address1 if address1
|
160
|
+
end
|
161
|
+
|
162
|
+
if merchant_account_id = (options[:merchant_account_id] || @merchant_account_id)
|
163
|
+
payload[:options] = { merchant_account_id: merchant_account_id }
|
164
|
+
end
|
165
|
+
|
152
166
|
commit do
|
153
167
|
result = @braintree_gateway.verification.create(payload)
|
154
168
|
response = Response.new(result.success?, message_from_transaction_result(result), response_options(result))
|
@@ -193,15 +207,20 @@ module ActiveMerchant #:nodoc:
|
|
193
207
|
}
|
194
208
|
}, options)[:credit_card]
|
195
209
|
|
196
|
-
result = @braintree_gateway.customer.update(
|
210
|
+
result = @braintree_gateway.customer.update(
|
211
|
+
vault_id,
|
197
212
|
first_name: creditcard.first_name,
|
198
213
|
last_name: creditcard.last_name,
|
199
214
|
email: scrub_email(options[:email]),
|
200
215
|
phone: phone_from(options),
|
201
|
-
credit_card: credit_card_params
|
202
|
-
|
216
|
+
credit_card: credit_card_params
|
217
|
+
)
|
218
|
+
Response.new(
|
219
|
+
result.success?,
|
220
|
+
message_from_result(result),
|
203
221
|
braintree_customer: (customer_hash(@braintree_gateway.customer.find(vault_id), :include_credit_cards) if result.success?),
|
204
|
-
customer_vault_id: (result.customer.id if result.success?)
|
222
|
+
customer_vault_id: (result.customer.id if result.success?)
|
223
|
+
)
|
205
224
|
end
|
206
225
|
end
|
207
226
|
|
@@ -271,13 +290,16 @@ module ActiveMerchant #:nodoc:
|
|
271
290
|
device_data: options[:device_data]
|
272
291
|
}.merge credit_card_params
|
273
292
|
result = @braintree_gateway.customer.create(merge_credit_card_options(parameters, options))
|
274
|
-
Response.new(
|
293
|
+
Response.new(
|
294
|
+
result.success?,
|
295
|
+
message_from_result(result),
|
275
296
|
{
|
276
297
|
braintree_customer: (customer_hash(result.customer, :include_credit_cards) if result.success?),
|
277
298
|
customer_vault_id: (result.customer.id if result.success?),
|
278
299
|
credit_card_token: (result.customer.credit_cards[0].token if result.success?)
|
279
300
|
},
|
280
|
-
authorization: (result.customer.id if result.success?)
|
301
|
+
authorization: (result.customer.id if result.success?)
|
302
|
+
)
|
281
303
|
end
|
282
304
|
end
|
283
305
|
|
@@ -371,8 +393,8 @@ module ActiveMerchant #:nodoc:
|
|
371
393
|
|
372
394
|
def commit(&block)
|
373
395
|
yield
|
374
|
-
rescue Braintree::BraintreeError =>
|
375
|
-
Response.new(false,
|
396
|
+
rescue Braintree::BraintreeError => e
|
397
|
+
Response.new(false, e.class.to_s)
|
376
398
|
end
|
377
399
|
|
378
400
|
def message_from_result(result)
|
@@ -422,6 +444,8 @@ module ActiveMerchant #:nodoc:
|
|
422
444
|
end
|
423
445
|
|
424
446
|
def avs_code_from(transaction)
|
447
|
+
return unless transaction
|
448
|
+
|
425
449
|
transaction.avs_error_response_code ||
|
426
450
|
avs_mapping["street: #{transaction.avs_street_address_response_code}, zip: #{transaction.avs_postal_code_response_code}"]
|
427
451
|
end
|
@@ -486,6 +510,55 @@ module ActiveMerchant #:nodoc:
|
|
486
510
|
result.transaction&.additional_processor_response
|
487
511
|
end
|
488
512
|
|
513
|
+
def payment_instrument_type(result)
|
514
|
+
result&.payment_instrument_type
|
515
|
+
end
|
516
|
+
|
517
|
+
def credit_card_details(result)
|
518
|
+
if result
|
519
|
+
{
|
520
|
+
'masked_number' => result.credit_card_details&.masked_number,
|
521
|
+
'bin' => result.credit_card_details&.bin,
|
522
|
+
'last_4' => result.credit_card_details&.last_4,
|
523
|
+
'card_type' => result.credit_card_details&.card_type,
|
524
|
+
'token' => result.credit_card_details&.token,
|
525
|
+
'debit' => result.credit_card_details&.debit,
|
526
|
+
'prepaid' => result.credit_card_details&.prepaid,
|
527
|
+
'issuing_bank' => result.credit_card_details&.issuing_bank,
|
528
|
+
'country_of_issuance' => result.credit_card_details&.country_of_issuance
|
529
|
+
}
|
530
|
+
end
|
531
|
+
end
|
532
|
+
|
533
|
+
def network_token_details(result)
|
534
|
+
if result
|
535
|
+
{
|
536
|
+
'debit' => result.network_token_details&.debit,
|
537
|
+
'prepaid' => result.network_token_details&.prepaid,
|
538
|
+
'issuing_bank' => result.network_token_details&.issuing_bank
|
539
|
+
}
|
540
|
+
end
|
541
|
+
end
|
542
|
+
|
543
|
+
def google_pay_details(result)
|
544
|
+
if result
|
545
|
+
{
|
546
|
+
'debit' => result.google_pay_details&.debit,
|
547
|
+
'prepaid' => result.google_pay_details&.prepaid
|
548
|
+
}
|
549
|
+
end
|
550
|
+
end
|
551
|
+
|
552
|
+
def apple_pay_details(result)
|
553
|
+
if result
|
554
|
+
{
|
555
|
+
'debit' => result.apple_pay_details&.debit,
|
556
|
+
'prepaid' => result.apple_pay_details&.prepaid,
|
557
|
+
'issuing_bank' => result.apple_pay_details&.issuing_bank
|
558
|
+
}
|
559
|
+
end
|
560
|
+
end
|
561
|
+
|
489
562
|
def create_transaction(transaction_type, money, credit_card_or_vault_id, options)
|
490
563
|
transaction_params = create_transaction_parameters(money, credit_card_or_vault_id, options)
|
491
564
|
commit do
|
@@ -545,7 +618,15 @@ module ActiveMerchant #:nodoc:
|
|
545
618
|
def transaction_hash(result)
|
546
619
|
unless result.success?
|
547
620
|
return { 'processor_response_code' => response_code_from_result(result),
|
548
|
-
'additional_processor_response' => additional_processor_response_from_result(result)
|
621
|
+
'additional_processor_response' => additional_processor_response_from_result(result),
|
622
|
+
'payment_instrument_type' => payment_instrument_type(result.transaction),
|
623
|
+
'credit_card_details' => credit_card_details(result.transaction),
|
624
|
+
'network_token_details' => network_token_details(result.transaction),
|
625
|
+
'google_pay_details' => google_pay_details(result.transaction),
|
626
|
+
'apple_pay_details' => apple_pay_details(result.transaction),
|
627
|
+
'avs_response_code' => avs_code_from(result.transaction),
|
628
|
+
'cvv_response_code' => result.transaction&.cvv_response_code,
|
629
|
+
'gateway_message' => result.message }
|
549
630
|
end
|
550
631
|
|
551
632
|
transaction = result.transaction
|
@@ -561,6 +642,14 @@ module ActiveMerchant #:nodoc:
|
|
561
642
|
vault_customer = nil
|
562
643
|
end
|
563
644
|
|
645
|
+
credit_card_details = credit_card_details(transaction)
|
646
|
+
|
647
|
+
network_token_details = network_token_details(transaction)
|
648
|
+
|
649
|
+
google_pay_details = google_pay_details(transaction)
|
650
|
+
|
651
|
+
apple_pay_details = apple_pay_details(transaction)
|
652
|
+
|
564
653
|
customer_details = {
|
565
654
|
'id' => transaction.customer_details.id,
|
566
655
|
'email' => transaction.customer_details.email,
|
@@ -586,12 +675,10 @@ module ActiveMerchant #:nodoc:
|
|
586
675
|
'postal_code' => transaction.shipping_details.postal_code,
|
587
676
|
'country_name' => transaction.shipping_details.country_name
|
588
677
|
}
|
589
|
-
|
590
|
-
|
591
|
-
'
|
592
|
-
'
|
593
|
-
'card_type' => transaction.credit_card_details.card_type,
|
594
|
-
'token' => transaction.credit_card_details.token
|
678
|
+
|
679
|
+
paypal_details = {
|
680
|
+
'payer_id' => transaction.paypal_details.payer_id,
|
681
|
+
'payer_email' => transaction.paypal_details.payer_email
|
595
682
|
}
|
596
683
|
|
597
684
|
if transaction.risk_data
|
@@ -605,11 +692,23 @@ module ActiveMerchant #:nodoc:
|
|
605
692
|
risk_data = nil
|
606
693
|
end
|
607
694
|
|
695
|
+
if transaction.payment_receipt
|
696
|
+
payment_receipt = {
|
697
|
+
'global_id' => transaction.payment_receipt.global_id
|
698
|
+
}
|
699
|
+
else
|
700
|
+
payment_receipt = nil
|
701
|
+
end
|
702
|
+
|
608
703
|
{
|
609
704
|
'order_id' => transaction.order_id,
|
610
705
|
'amount' => transaction.amount.to_s,
|
611
706
|
'status' => transaction.status,
|
612
707
|
'credit_card_details' => credit_card_details,
|
708
|
+
'network_token_details' => network_token_details,
|
709
|
+
'apple_pay_details' => apple_pay_details,
|
710
|
+
'google_pay_details' => google_pay_details,
|
711
|
+
'paypal_details' => paypal_details,
|
613
712
|
'customer_details' => customer_details,
|
614
713
|
'billing_details' => billing_details,
|
615
714
|
'shipping_details' => shipping_details,
|
@@ -619,7 +718,9 @@ module ActiveMerchant #:nodoc:
|
|
619
718
|
'network_transaction_id' => transaction.network_transaction_id || nil,
|
620
719
|
'processor_response_code' => response_code_from_result(result),
|
621
720
|
'processor_authorization_code' => transaction.processor_authorization_code,
|
622
|
-
'recurring' => transaction.recurring
|
721
|
+
'recurring' => transaction.recurring,
|
722
|
+
'payment_receipt' => payment_receipt,
|
723
|
+
'payment_instrument_type' => payment_instrument_type(transaction)
|
623
724
|
}
|
624
725
|
end
|
625
726
|
|
@@ -665,6 +766,8 @@ module ActiveMerchant #:nodoc:
|
|
665
766
|
|
666
767
|
add_3ds_info(parameters, options[:three_d_secure])
|
667
768
|
|
769
|
+
parameters[:sca_exemption] = options[:three_ds_exemption_type] if options[:three_ds_exemption_type]
|
770
|
+
|
668
771
|
if options[:payment_method_nonce].is_a?(String)
|
669
772
|
parameters.delete(:customer)
|
670
773
|
parameters[:payment_method_nonce] = options[:payment_method_nonce]
|
@@ -803,78 +906,125 @@ module ActiveMerchant #:nodoc:
|
|
803
906
|
end
|
804
907
|
|
805
908
|
def add_stored_credential_data(parameters, credit_card_or_vault_id, options)
|
909
|
+
# Braintree has informed us that the stored_credential mapping may be incorrect
|
910
|
+
# In order to prevent possible breaking changes we will only apply the new logic if
|
911
|
+
# specifically requested. This will be the default behavior in a future release.
|
806
912
|
return unless (stored_credential = options[:stored_credential])
|
807
913
|
|
808
|
-
parameters
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
parameters[:transaction_source] = 'recurring'
|
914
|
+
add_external_vault(parameters, options)
|
915
|
+
stored_credentials(parameters, stored_credential)
|
916
|
+
end
|
917
|
+
|
918
|
+
def stored_credentials(parameters, stored_credential)
|
919
|
+
case stored_credential[:reason_type]
|
920
|
+
when 'recurring', 'installment'
|
921
|
+
if stored_credential[:initial_transaction]
|
922
|
+
parameters[:transaction_source] = "#{stored_credential[:reason_type]}_first"
|
818
923
|
else
|
819
924
|
parameters[:transaction_source] = stored_credential[:reason_type]
|
820
925
|
end
|
821
|
-
|
926
|
+
when 'recurring_first', 'moto'
|
822
927
|
parameters[:transaction_source] = stored_credential[:reason_type]
|
928
|
+
when 'unscheduled'
|
929
|
+
parameters[:transaction_source] = stored_credential[:initiator] == 'merchant' ? stored_credential[:reason_type] : ''
|
823
930
|
else
|
824
931
|
parameters[:transaction_source] = ''
|
825
932
|
end
|
826
933
|
end
|
827
934
|
|
935
|
+
def add_external_vault(parameters, options = {})
|
936
|
+
stored_credential = options[:stored_credential]
|
937
|
+
parameters[:external_vault] = {}
|
938
|
+
if stored_credential[:initial_transaction]
|
939
|
+
parameters[:external_vault][:status] = 'will_vault'
|
940
|
+
else
|
941
|
+
parameters[:external_vault][:status] = 'vaulted'
|
942
|
+
parameters[:external_vault][:previous_network_transaction_id] = options[:network_transaction_id] || stored_credential[:network_transaction_id]
|
943
|
+
end
|
944
|
+
end
|
945
|
+
|
828
946
|
def add_payment_method(parameters, credit_card_or_vault_id, options)
|
829
947
|
if credit_card_or_vault_id.is_a?(String) || credit_card_or_vault_id.is_a?(Integer)
|
830
|
-
|
831
|
-
parameters[:payment_method_token] = credit_card_or_vault_id
|
832
|
-
options.delete(:billing_address)
|
833
|
-
elsif options[:payment_method_nonce]
|
834
|
-
parameters[:payment_method_nonce] = credit_card_or_vault_id
|
835
|
-
else
|
836
|
-
parameters[:customer_id] = credit_card_or_vault_id
|
837
|
-
end
|
948
|
+
add_third_party_token(parameters, credit_card_or_vault_id, options)
|
838
949
|
else
|
839
950
|
parameters[:customer].merge!(
|
840
951
|
first_name: credit_card_or_vault_id.first_name,
|
841
952
|
last_name: credit_card_or_vault_id.last_name
|
842
953
|
)
|
843
954
|
if credit_card_or_vault_id.is_a?(NetworkTokenizationCreditCard)
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
eci_indicator: credit_card_or_vault_id.eci
|
852
|
-
}
|
853
|
-
elsif credit_card_or_vault_id.source == :android_pay || credit_card_or_vault_id.source == :google_pay
|
854
|
-
Braintree::Version::Major < 3 ? pay_card = :android_pay_card : pay_card = :google_pay_card
|
855
|
-
parameters[pay_card] = {
|
856
|
-
number: credit_card_or_vault_id.number,
|
857
|
-
cryptogram: credit_card_or_vault_id.payment_cryptogram,
|
858
|
-
expiration_month: credit_card_or_vault_id.month.to_s.rjust(2, '0'),
|
859
|
-
expiration_year: credit_card_or_vault_id.year.to_s,
|
860
|
-
google_transaction_id: credit_card_or_vault_id.transaction_id,
|
861
|
-
source_card_type: credit_card_or_vault_id.brand,
|
862
|
-
source_card_last_four: credit_card_or_vault_id.last_digits,
|
863
|
-
eci_indicator: credit_card_or_vault_id.eci
|
864
|
-
}
|
955
|
+
case credit_card_or_vault_id.source
|
956
|
+
when :apple_pay
|
957
|
+
add_apple_pay(parameters, credit_card_or_vault_id)
|
958
|
+
when :google_pay
|
959
|
+
add_google_pay(parameters, credit_card_or_vault_id)
|
960
|
+
else
|
961
|
+
add_network_tokenization_card(parameters, credit_card_or_vault_id)
|
865
962
|
end
|
866
963
|
else
|
867
|
-
parameters
|
868
|
-
number: credit_card_or_vault_id.number,
|
869
|
-
cvv: credit_card_or_vault_id.verification_value,
|
870
|
-
expiration_month: credit_card_or_vault_id.month.to_s.rjust(2, '0'),
|
871
|
-
expiration_year: credit_card_or_vault_id.year.to_s,
|
872
|
-
cardholder_name: credit_card_or_vault_id.name
|
873
|
-
}
|
964
|
+
add_credit_card(parameters, credit_card_or_vault_id)
|
874
965
|
end
|
875
966
|
end
|
876
967
|
end
|
877
968
|
|
969
|
+
def add_third_party_token(parameters, payment_method, options)
|
970
|
+
if options[:payment_method_token]
|
971
|
+
parameters[:payment_method_token] = payment_method
|
972
|
+
options.delete(:billing_address)
|
973
|
+
elsif options[:payment_method_nonce]
|
974
|
+
parameters[:payment_method_nonce] = payment_method
|
975
|
+
else
|
976
|
+
parameters[:customer_id] = payment_method
|
977
|
+
end
|
978
|
+
end
|
979
|
+
|
980
|
+
def add_credit_card(parameters, payment_method)
|
981
|
+
parameters[:credit_card] = {
|
982
|
+
number: payment_method.number,
|
983
|
+
cvv: payment_method.verification_value,
|
984
|
+
expiration_month: payment_method.month.to_s.rjust(2, '0'),
|
985
|
+
expiration_year: payment_method.year.to_s,
|
986
|
+
cardholder_name: payment_method.name
|
987
|
+
}
|
988
|
+
end
|
989
|
+
|
990
|
+
def add_apple_pay(parameters, payment_method)
|
991
|
+
parameters[:apple_pay_card] = {
|
992
|
+
number: payment_method.number,
|
993
|
+
expiration_month: payment_method.month.to_s.rjust(2, '0'),
|
994
|
+
expiration_year: payment_method.year.to_s,
|
995
|
+
cardholder_name: payment_method.name,
|
996
|
+
cryptogram: payment_method.payment_cryptogram,
|
997
|
+
eci_indicator: payment_method.eci
|
998
|
+
}
|
999
|
+
end
|
1000
|
+
|
1001
|
+
def add_google_pay(parameters, payment_method)
|
1002
|
+
Braintree::Version::Major < 3 ? pay_card = :android_pay_card : pay_card = :google_pay_card
|
1003
|
+
parameters[pay_card] = {
|
1004
|
+
number: payment_method.number,
|
1005
|
+
cryptogram: payment_method.payment_cryptogram,
|
1006
|
+
expiration_month: payment_method.month.to_s.rjust(2, '0'),
|
1007
|
+
expiration_year: payment_method.year.to_s,
|
1008
|
+
google_transaction_id: payment_method.transaction_id,
|
1009
|
+
source_card_type: payment_method.brand,
|
1010
|
+
source_card_last_four: payment_method.last_digits,
|
1011
|
+
eci_indicator: payment_method.eci
|
1012
|
+
}
|
1013
|
+
end
|
1014
|
+
|
1015
|
+
def add_network_tokenization_card(parameters, payment_method)
|
1016
|
+
parameters[:credit_card] = {
|
1017
|
+
number: payment_method.number,
|
1018
|
+
expiration_month: payment_method.month.to_s.rjust(2, '0'),
|
1019
|
+
expiration_year: payment_method.year.to_s,
|
1020
|
+
cardholder_name: payment_method.name,
|
1021
|
+
network_tokenization_attributes: {
|
1022
|
+
cryptogram: payment_method.payment_cryptogram,
|
1023
|
+
ecommerce_indicator: payment_method.eci
|
1024
|
+
}
|
1025
|
+
}
|
1026
|
+
end
|
1027
|
+
|
878
1028
|
def bank_account_errors(payment_method, options)
|
879
1029
|
if payment_method.validate.present?
|
880
1030
|
payment_method.validate
|
@@ -886,7 +1036,7 @@ module ActiveMerchant #:nodoc:
|
|
886
1036
|
end
|
887
1037
|
|
888
1038
|
def add_bank_account_to_customer(payment_method, options)
|
889
|
-
bank_account_nonce, error_message = TokenNonce.new(@braintree_gateway, options).create_token_nonce_for_payment_method
|
1039
|
+
bank_account_nonce, error_message = TokenNonce.new(@braintree_gateway, options).create_token_nonce_for_payment_method(payment_method, options)
|
890
1040
|
return Response.new(false, error_message) unless bank_account_nonce.present?
|
891
1041
|
|
892
1042
|
result = @braintree_gateway.payment_method.create(
|
@@ -901,13 +1051,16 @@ module ActiveMerchant #:nodoc:
|
|
901
1051
|
message = message_from_result(result)
|
902
1052
|
message = not_verified_reason(result.payment_method) unless verified
|
903
1053
|
|
904
|
-
Response.new(
|
1054
|
+
Response.new(
|
1055
|
+
verified,
|
1056
|
+
message,
|
905
1057
|
{
|
906
1058
|
customer_vault_id: options[:customer],
|
907
1059
|
bank_account_token: result.payment_method&.token,
|
908
1060
|
verified: verified
|
909
1061
|
},
|
910
|
-
authorization: result.payment_method&.token
|
1062
|
+
authorization: result.payment_method&.token
|
1063
|
+
)
|
911
1064
|
end
|
912
1065
|
|
913
1066
|
def not_verified_reason(bank_account)
|
@@ -944,7 +1097,7 @@ module ActiveMerchant #:nodoc:
|
|
944
1097
|
Response.new(
|
945
1098
|
result.success?,
|
946
1099
|
message_from_result(result),
|
947
|
-
{ customer_vault_id: customer_id,
|
1100
|
+
{ customer_vault_id: customer_id, exists: true }
|
948
1101
|
)
|
949
1102
|
end
|
950
1103
|
end
|
@@ -146,9 +146,12 @@ module ActiveMerchant #:nodoc:
|
|
146
146
|
|
147
147
|
def unstore(authorization, options = {})
|
148
148
|
account_id, profile_id = authorization.split('|')
|
149
|
-
commit(
|
149
|
+
commit(
|
150
|
+
'profile',
|
151
|
+
{},
|
150
152
|
verb: :delete,
|
151
|
-
path: "/#{profile_id}/#{account_id}/#{@options[:merchant_id]}"
|
153
|
+
path: "/#{profile_id}/#{account_id}/#{@options[:merchant_id]}"
|
154
|
+
)
|
152
155
|
end
|
153
156
|
|
154
157
|
def supports_scrubbing?
|
@@ -248,12 +248,10 @@ module ActiveMerchant #:nodoc:
|
|
248
248
|
add_pair(post, :orderRef, options[:description] || options[:order_id], required: true)
|
249
249
|
add_pair(post, :statementNarrative1, options[:merchant_name]) if options[:merchant_name]
|
250
250
|
add_pair(post, :statementNarrative2, options[:dynamic_descriptor]) if options[:dynamic_descriptor]
|
251
|
-
if credit_card_or_reference.respond_to?(:number)
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
add_pair(post, :item1GrossValue, localized_amount(money, options[:currency] || currency(money)))
|
256
|
-
end
|
251
|
+
if credit_card_or_reference.respond_to?(:number) && %w[american_express diners_club].include?(card_brand(credit_card_or_reference).to_s)
|
252
|
+
add_pair(post, :item1Quantity, 1)
|
253
|
+
add_pair(post, :item1Description, (options[:description] || options[:order_id]).slice(0, 15))
|
254
|
+
add_pair(post, :item1GrossValue, localized_amount(money, options[:currency] || currency(money)))
|
257
255
|
end
|
258
256
|
|
259
257
|
add_pair(post, :type, options[:type] || '1')
|
@@ -150,7 +150,7 @@ module ActiveMerchant #:nodoc:
|
|
150
150
|
match = body.match(/<cngateway>(.*)<\/cngateway>/)
|
151
151
|
return nil unless match
|
152
152
|
|
153
|
-
|
153
|
+
CGI::parse(match[1]).map { |k, v| [k.to_sym, v.first] }.to_h
|
154
154
|
end
|
155
155
|
|
156
156
|
def handle_response(response)
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module CecabankCommon
|
2
|
+
#### CECA's MAGIC NUMBERS
|
3
|
+
CECA_ENCRIPTION = 'SHA2'
|
4
|
+
CECA_CURRENCIES_DICTIONARY = { 'EUR' => 978, 'USD' => 840, 'GBP' => 826 }
|
5
|
+
|
6
|
+
def self.included(base)
|
7
|
+
base.supported_countries = ['ES']
|
8
|
+
base.supported_cardtypes = %i[visa master american_express]
|
9
|
+
base.homepage_url = 'http://www.ceca.es/es/'
|
10
|
+
base.display_name = 'Cecabank'
|
11
|
+
base.default_currency = 'EUR'
|
12
|
+
base.money_format = :cents
|
13
|
+
end
|
14
|
+
|
15
|
+
# Creates a new CecabankGateway
|
16
|
+
#
|
17
|
+
# The gateway requires four values for connection to be passed
|
18
|
+
# in the +options+ hash.
|
19
|
+
#
|
20
|
+
# ==== Options
|
21
|
+
#
|
22
|
+
# * <tt>:merchant_id</tt> -- Cecabank's merchant_id (REQUIRED)
|
23
|
+
# * <tt>:acquirer_bin</tt> -- Cecabank's acquirer_bin (REQUIRED)
|
24
|
+
# * <tt>:terminal_id</tt> -- Cecabank's terminal_id (REQUIRED)
|
25
|
+
# * <tt>:cypher_key</tt> -- Cecabank's cypher key (REQUIRED)
|
26
|
+
# * <tt>:test</tt> -- +true+ or +false+. If true, perform transactions against the test server.
|
27
|
+
# Otherwise, perform transactions against the production server.
|
28
|
+
def initialize(options = {})
|
29
|
+
requires!(options, :merchant_id, :acquirer_bin, :terminal_id, :cypher_key)
|
30
|
+
super
|
31
|
+
end
|
32
|
+
|
33
|
+
def supports_scrubbing?
|
34
|
+
true
|
35
|
+
end
|
36
|
+
end
|