activemerchant 1.100.0 → 1.133.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +1057 -0
- data/README.md +11 -9
- data/lib/active_merchant/billing/avs_result.rb +9 -9
- data/lib/active_merchant/billing/base.rb +0 -13
- data/lib/active_merchant/billing/check.rb +49 -17
- data/lib/active_merchant/billing/compatibility.rb +5 -4
- data/lib/active_merchant/billing/credit_card.rb +55 -8
- data/lib/active_merchant/billing/credit_card_formatting.rb +1 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +209 -36
- data/lib/active_merchant/billing/cvv_result.rb +0 -1
- data/lib/active_merchant/billing/gateway.rb +38 -36
- data/lib/active_merchant/billing/gateways/adyen.rb +399 -78
- data/lib/active_merchant/billing/gateways/airwallex.rb +370 -0
- data/lib/active_merchant/billing/gateways/alelo.rb +256 -0
- data/lib/active_merchant/billing/gateways/allied_wallet.rb +14 -14
- data/lib/active_merchant/billing/gateways/authorize_net.rb +200 -130
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +27 -20
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +48 -51
- data/lib/active_merchant/billing/gateways/axcessms.rb +13 -15
- data/lib/active_merchant/billing/gateways/balanced.rb +43 -36
- data/lib/active_merchant/billing/gateways/bambora_apac.rb +16 -20
- data/lib/active_merchant/billing/gateways/bank_frick.rb +13 -13
- data/lib/active_merchant/billing/gateways/banwire.rb +5 -5
- data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +43 -30
- data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +1 -1
- data/lib/active_merchant/billing/gateways/be2bill.rb +5 -5
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +37 -36
- data/lib/active_merchant/billing/gateways/beanstream.rb +21 -3
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +1 -1
- data/lib/active_merchant/billing/gateways/blue_pay.rb +53 -28
- data/lib/active_merchant/billing/gateways/blue_snap.rb +176 -54
- data/lib/active_merchant/billing/gateways/bogus.rb +24 -20
- data/lib/active_merchant/billing/gateways/borgun.rb +92 -38
- data/lib/active_merchant/billing/gateways/bpoint.rb +15 -15
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +8 -2
- data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +1 -1
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +387 -175
- data/lib/active_merchant/billing/gateways/bridge_pay.rb +13 -13
- data/lib/active_merchant/billing/gateways/cams.rb +10 -10
- data/lib/active_merchant/billing/gateways/card_connect.rb +33 -14
- data/lib/active_merchant/billing/gateways/card_save.rb +3 -4
- data/lib/active_merchant/billing/gateways/card_stream.rb +67 -40
- data/lib/active_merchant/billing/gateways/cardknox.rb +13 -13
- data/lib/active_merchant/billing/gateways/cardprocess.rb +4 -2
- data/lib/active_merchant/billing/gateways/cashnet.rb +28 -12
- data/lib/active_merchant/billing/gateways/cc5.rb +9 -9
- data/lib/active_merchant/billing/gateways/cecabank.rb +38 -38
- data/lib/active_merchant/billing/gateways/cenpos.rb +29 -28
- data/lib/active_merchant/billing/gateways/checkout.rb +7 -9
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +316 -68
- data/lib/active_merchant/billing/gateways/citrus_pay.rb +1 -2
- data/lib/active_merchant/billing/gateways/clearhaus.rb +32 -33
- data/lib/active_merchant/billing/gateways/commerce_hub.rb +370 -0
- data/lib/active_merchant/billing/gateways/commercegate.rb +4 -4
- data/lib/active_merchant/billing/gateways/conekta.rb +8 -6
- data/lib/active_merchant/billing/gateways/creditcall.rb +18 -17
- data/lib/active_merchant/billing/gateways/credorax.rb +152 -63
- data/lib/active_merchant/billing/gateways/ct_payment.rb +15 -14
- data/lib/active_merchant/billing/gateways/culqi.rb +30 -28
- data/lib/active_merchant/billing/gateways/cyber_source/cyber_source_common.rb +36 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +496 -187
- data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +454 -0
- data/lib/active_merchant/billing/gateways/d_local.rb +148 -31
- data/lib/active_merchant/billing/gateways/data_cash.rb +34 -37
- data/lib/active_merchant/billing/gateways/decidir.rb +134 -21
- data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
- data/lib/active_merchant/billing/gateways/dibs.rb +10 -10
- data/lib/active_merchant/billing/gateways/digitzs.rb +11 -8
- data/lib/active_merchant/billing/gateways/ebanx.rb +90 -40
- data/lib/active_merchant/billing/gateways/efsnet.rb +36 -36
- data/lib/active_merchant/billing/gateways/elavon.rb +349 -194
- data/lib/active_merchant/billing/gateways/element.rb +71 -21
- data/lib/active_merchant/billing/gateways/epay.rb +43 -43
- data/lib/active_merchant/billing/gateways/evo_ca.rb +12 -13
- data/lib/active_merchant/billing/gateways/eway.rb +9 -9
- data/lib/active_merchant/billing/gateways/eway_managed.rb +55 -56
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +37 -22
- data/lib/active_merchant/billing/gateways/exact.rb +19 -20
- data/lib/active_merchant/billing/gateways/ezic.rb +9 -9
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +24 -19
- data/lib/active_merchant/billing/gateways/federated_canada.rb +6 -7
- data/lib/active_merchant/billing/gateways/finansbank.rb +3 -3
- data/lib/active_merchant/billing/gateways/first_giving.rb +5 -4
- data/lib/active_merchant/billing/gateways/first_pay.rb +7 -7
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +39 -38
- data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +51 -31
- data/lib/active_merchant/billing/gateways/flo2cash.rb +24 -24
- data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +1 -1
- data/lib/active_merchant/billing/gateways/forte.rb +38 -22
- data/lib/active_merchant/billing/gateways/garanti.rb +12 -15
- data/lib/active_merchant/billing/gateways/global_collect.rb +333 -89
- data/lib/active_merchant/billing/gateways/global_transport.rb +8 -9
- data/lib/active_merchant/billing/gateways/hdfc.rb +22 -23
- data/lib/active_merchant/billing/gateways/hps.rb +171 -50
- data/lib/active_merchant/billing/gateways/iats_payments.rb +47 -25
- data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +1 -1
- data/lib/active_merchant/billing/gateways/inspire.rb +22 -27
- data/lib/active_merchant/billing/gateways/instapay.rb +5 -8
- data/lib/active_merchant/billing/gateways/ipg.rb +420 -0
- data/lib/active_merchant/billing/gateways/ipp.rb +9 -9
- data/lib/active_merchant/billing/gateways/iridium.rb +30 -31
- data/lib/active_merchant/billing/gateways/itransact.rb +11 -10
- data/lib/active_merchant/billing/gateways/iveri.rb +62 -23
- data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +10 -17
- data/lib/active_merchant/billing/gateways/jetpay_v2.rb +13 -18
- data/lib/active_merchant/billing/gateways/komoju.rb +1 -1
- data/lib/active_merchant/billing/gateways/kushki.rb +100 -22
- data/lib/active_merchant/billing/gateways/latitude19.rb +20 -19
- data/lib/active_merchant/billing/gateways/linkpoint.rb +71 -72
- data/lib/active_merchant/billing/gateways/litle.rb +181 -45
- data/lib/active_merchant/billing/gateways/mastercard.rb +16 -22
- data/lib/active_merchant/billing/gateways/maxipago.rb +2 -2
- data/lib/active_merchant/billing/gateways/mercado_pago.rb +89 -18
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +58 -24
- data/lib/active_merchant/billing/gateways/merchant_one.rb +7 -10
- data/lib/active_merchant/billing/gateways/merchant_partners.rb +19 -19
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +18 -22
- data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +15 -17
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +46 -8
- data/lib/active_merchant/billing/gateways/mercury.rb +19 -23
- data/lib/active_merchant/billing/gateways/metrics_global.rb +24 -33
- data/lib/active_merchant/billing/gateways/micropayment.rb +11 -12
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +7 -7
- data/lib/active_merchant/billing/gateways/migs.rb +18 -21
- data/lib/active_merchant/billing/gateways/mit.rb +260 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +10 -12
- data/lib/active_merchant/billing/gateways/moka.rb +290 -0
- data/lib/active_merchant/billing/gateways/monei.rb +236 -150
- data/lib/active_merchant/billing/gateways/moneris.rb +122 -53
- data/lib/active_merchant/billing/gateways/money_movers.rb +6 -7
- data/lib/active_merchant/billing/gateways/mundipagg.rb +69 -23
- data/lib/active_merchant/billing/gateways/nab_transact.rb +18 -20
- data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +10 -12
- data/lib/active_merchant/billing/gateways/net_registry.rb +8 -9
- data/lib/active_merchant/billing/gateways/netaxept.rb +12 -12
- data/lib/active_merchant/billing/gateways/netbanx.rb +128 -46
- data/lib/active_merchant/billing/gateways/netbilling.rb +18 -21
- data/lib/active_merchant/billing/gateways/netpay.rb +5 -4
- data/lib/active_merchant/billing/gateways/network_merchants.rb +7 -10
- data/lib/active_merchant/billing/gateways/nmi.rb +69 -27
- data/lib/active_merchant/billing/gateways/ogone.rb +62 -31
- data/lib/active_merchant/billing/gateways/omise.rb +15 -16
- data/lib/active_merchant/billing/gateways/openpay.rb +33 -15
- data/lib/active_merchant/billing/gateways/opp.rb +39 -33
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +43 -42
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +3 -5
- data/lib/active_merchant/billing/gateways/orbital.rb +623 -362
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +20 -20
- data/lib/active_merchant/billing/gateways/pagarme.rb +16 -23
- data/lib/active_merchant/billing/gateways/pago_facil.rb +4 -6
- data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
- data/lib/active_merchant/billing/gateways/pay_conex.rb +17 -17
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +30 -33
- data/lib/active_merchant/billing/gateways/pay_hub.rb +10 -10
- data/lib/active_merchant/billing/gateways/pay_junction.rb +31 -31
- data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +36 -18
- data/lib/active_merchant/billing/gateways/pay_secure.rb +10 -11
- data/lib/active_merchant/billing/gateways/pay_trace.rb +450 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +64 -40
- data/lib/active_merchant/billing/gateways/payeezy.rb +130 -27
- data/lib/active_merchant/billing/gateways/payex.rb +24 -25
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +17 -17
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +1 -1
- data/lib/active_merchant/billing/gateways/payflow.rb +103 -25
- data/lib/active_merchant/billing/gateways/payflow_express.rb +4 -4
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +1 -1
- data/lib/active_merchant/billing/gateways/payment_express.rb +22 -18
- data/lib/active_merchant/billing/gateways/paymentez.rb +89 -24
- data/lib/active_merchant/billing/gateways/paymill.rb +14 -16
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +2 -1
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +4 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +13 -5
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +1 -1
- data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +1 -1
- data/lib/active_merchant/billing/gateways/paypal_express.rb +4 -1
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +1 -1
- data/lib/active_merchant/billing/gateways/paysafe.rb +420 -0
- data/lib/active_merchant/billing/gateways/payscout.rb +8 -9
- data/lib/active_merchant/billing/gateways/paystation.rb +6 -9
- data/lib/active_merchant/billing/gateways/payu_in.rb +20 -19
- data/lib/active_merchant/billing/gateways/payu_latam.rb +70 -37
- data/lib/active_merchant/billing/gateways/payway.rb +22 -22
- data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
- data/lib/active_merchant/billing/gateways/pin.rb +60 -21
- data/lib/active_merchant/billing/gateways/plexo.rb +308 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +20 -21
- data/lib/active_merchant/billing/gateways/priority.rb +392 -0
- data/lib/active_merchant/billing/gateways/pro_pay.rb +13 -14
- data/lib/active_merchant/billing/gateways/psigate.rb +29 -29
- data/lib/active_merchant/billing/gateways/psl_card.rb +7 -8
- data/lib/active_merchant/billing/gateways/qbms.rb +25 -26
- data/lib/active_merchant/billing/gateways/quantum.rb +9 -11
- data/lib/active_merchant/billing/gateways/quickbooks.rb +126 -39
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +98 -98
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +19 -23
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +3 -3
- data/lib/active_merchant/billing/gateways/quickpay.rb +0 -1
- data/lib/active_merchant/billing/gateways/qvalent.rb +36 -20
- data/lib/active_merchant/billing/gateways/rapyd.rb +319 -0
- data/lib/active_merchant/billing/gateways/reach.rb +277 -0
- data/lib/active_merchant/billing/gateways/realex.rb +42 -16
- data/lib/active_merchant/billing/gateways/redsys.rb +191 -86
- data/lib/active_merchant/billing/gateways/s5.rb +10 -9
- data/lib/active_merchant/billing/gateways/safe_charge.rb +70 -33
- data/lib/active_merchant/billing/gateways/sage.rb +19 -21
- data/lib/active_merchant/billing/gateways/sage_pay.rb +57 -57
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +3 -4
- data/lib/active_merchant/billing/gateways/secure_net.rb +19 -26
- data/lib/active_merchant/billing/gateways/secure_pay.rb +24 -33
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +18 -20
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +4 -5
- data/lib/active_merchant/billing/gateways/securion_pay.rb +48 -7
- data/lib/active_merchant/billing/gateways/shift4.rb +345 -0
- data/lib/active_merchant/billing/gateways/simetrik.rb +368 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +19 -19
- data/lib/active_merchant/billing/gateways/smart_ps.rb +26 -32
- data/lib/active_merchant/billing/gateways/so_easy_pay.rb +24 -25
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +27 -21
- data/lib/active_merchant/billing/gateways/stripe.rb +126 -53
- data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +441 -113
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +7 -8
- data/lib/active_merchant/billing/gateways/telr.rb +17 -18
- data/lib/active_merchant/billing/gateways/tns.rb +3 -7
- data/lib/active_merchant/billing/gateways/trans_first.rb +10 -9
- data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +28 -24
- data/lib/active_merchant/billing/gateways/transact_pro.rb +13 -15
- data/lib/active_merchant/billing/gateways/transax.rb +1 -2
- data/lib/active_merchant/billing/gateways/trexle.rb +5 -2
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +57 -47
- data/lib/active_merchant/billing/gateways/usa_epay.rb +1 -2
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +176 -184
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +60 -48
- data/lib/active_merchant/billing/gateways/vanco.rb +17 -8
- data/lib/active_merchant/billing/gateways/verifi.rb +13 -14
- data/lib/active_merchant/billing/gateways/viaklix.rb +9 -14
- data/lib/active_merchant/billing/gateways/visanet_peru.rb +26 -21
- data/lib/active_merchant/billing/gateways/vpos.rb +223 -0
- data/lib/active_merchant/billing/gateways/webpay.rb +4 -4
- data/lib/active_merchant/billing/gateways/wepay.rb +14 -16
- data/lib/active_merchant/billing/gateways/wirecard.rb +14 -16
- data/lib/active_merchant/billing/gateways/wompi.rb +197 -0
- data/lib/active_merchant/billing/gateways/world_net.rb +36 -35
- data/lib/active_merchant/billing/gateways/worldpay.rb +556 -190
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +47 -54
- data/lib/active_merchant/billing/gateways/worldpay_us.rb +16 -16
- data/lib/active_merchant/billing/network_tokenization_credit_card.rb +2 -2
- data/lib/active_merchant/billing/response.rb +25 -6
- data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
- data/lib/active_merchant/billing.rb +1 -0
- data/lib/active_merchant/connection.rb +14 -15
- data/lib/active_merchant/country.rb +3 -1
- data/lib/active_merchant/errors.rb +4 -1
- data/lib/active_merchant/net_http_ssl_connection.rb +1 -0
- data/lib/active_merchant/network_connection_retries.rb +15 -17
- data/lib/active_merchant/post_data.rb +3 -2
- data/lib/active_merchant/posts_data.rb +2 -2
- data/lib/active_merchant/version.rb +1 -1
- data/lib/active_merchant.rb +2 -2
- data/lib/certs/cacert.pem +1587 -2361
- data/lib/support/gateway_support.rb +1 -1
- data/lib/support/ssl_verify.rb +3 -7
- data/lib/support/ssl_version.rb +2 -3
- metadata +86 -34
- data/lib/active_merchant/billing/gateways/moneris_us.rb +0 -352
@@ -1,4 +1,6 @@
|
|
1
1
|
require 'active_merchant/billing/gateways/braintree/braintree_common'
|
2
|
+
require 'active_merchant/billing/gateways/braintree/token_nonce'
|
3
|
+
require 'active_support/core_ext/array/extract_options'
|
2
4
|
|
3
5
|
begin
|
4
6
|
require 'braintree'
|
@@ -6,9 +8,7 @@ rescue LoadError
|
|
6
8
|
raise 'Could not load the braintree gem. Use `gem install braintree` to install it.'
|
7
9
|
end
|
8
10
|
|
9
|
-
unless Braintree::Version::Major
|
10
|
-
raise "Need braintree gem >= 2.78.0. Run `gem install braintree --version '~>2.78'` to get the correct version."
|
11
|
-
end
|
11
|
+
raise 'Need braintree gem >= 2.0.0.' unless Braintree::Version::Major >= 2 && Braintree::Version::Minor >= 0
|
12
12
|
|
13
13
|
module ActiveMerchant #:nodoc:
|
14
14
|
module Billing #:nodoc:
|
@@ -47,6 +47,8 @@ module ActiveMerchant #:nodoc:
|
|
47
47
|
cannot_refund_if_unsettled: 91506
|
48
48
|
}
|
49
49
|
|
50
|
+
DIRECT_BANK_ERROR = 'Direct bank account transactions are not supported. Bank accounts must be successfully stored before use.'.freeze
|
51
|
+
|
50
52
|
def initialize(options = {})
|
51
53
|
requires!(options, :merchant_id, :public_key, :private_key)
|
52
54
|
@merchant_account_id = options[:merchant_account_id]
|
@@ -62,30 +64,45 @@ module ActiveMerchant #:nodoc:
|
|
62
64
|
end
|
63
65
|
|
64
66
|
@configuration = Braintree::Configuration.new(
|
65
|
-
:
|
66
|
-
:
|
67
|
-
:
|
68
|
-
:
|
69
|
-
:
|
70
|
-
:
|
67
|
+
merchant_id: options[:merchant_id],
|
68
|
+
public_key: options[:public_key],
|
69
|
+
private_key: options[:private_key],
|
70
|
+
environment: (options[:environment] || (test? ? :sandbox : :production)).to_sym,
|
71
|
+
custom_user_agent: "ActiveMerchant #{ActiveMerchant::VERSION}",
|
72
|
+
logger: options[:logger] || logger
|
71
73
|
)
|
72
74
|
|
73
75
|
@braintree_gateway = Braintree::Gateway.new(@configuration)
|
74
76
|
end
|
75
77
|
|
78
|
+
def setup_purchase
|
79
|
+
commit do
|
80
|
+
Response.new(true, 'Client token created', { client_token: @braintree_gateway.client_token.generate })
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
76
84
|
def authorize(money, credit_card_or_vault_id, options = {})
|
85
|
+
return Response.new(false, DIRECT_BANK_ERROR) if credit_card_or_vault_id.is_a? Check
|
86
|
+
|
77
87
|
create_transaction(:sale, money, credit_card_or_vault_id, options)
|
78
88
|
end
|
79
89
|
|
80
90
|
def capture(money, authorization, options = {})
|
81
|
-
|
82
|
-
|
83
|
-
|
91
|
+
if options[:partial_capture] == true
|
92
|
+
commit do
|
93
|
+
result = @braintree_gateway.transaction.submit_for_partial_settlement(authorization, localized_amount(money, options[:currency] || default_currency).to_s)
|
94
|
+
response_from_result(result)
|
95
|
+
end
|
96
|
+
else
|
97
|
+
commit do
|
98
|
+
result = @braintree_gateway.transaction.submit_for_settlement(authorization, localized_amount(money, options[:currency] || default_currency).to_s)
|
99
|
+
response_from_result(result)
|
100
|
+
end
|
84
101
|
end
|
85
102
|
end
|
86
103
|
|
87
104
|
def purchase(money, credit_card_or_vault_id, options = {})
|
88
|
-
authorize(money, credit_card_or_vault_id, options.merge(:
|
105
|
+
authorize(money, credit_card_or_vault_id, options.merge(submit_for_settlement: true))
|
89
106
|
end
|
90
107
|
|
91
108
|
def credit(money, credit_card_or_vault_id, options = {})
|
@@ -100,10 +117,13 @@ module ActiveMerchant #:nodoc:
|
|
100
117
|
|
101
118
|
commit do
|
102
119
|
response = response_from_result(@braintree_gateway.transaction.refund(transaction_id, money))
|
103
|
-
return response if response.success?
|
104
|
-
return response unless options[:force_full_refund_if_unsettled]
|
105
120
|
|
106
|
-
|
121
|
+
if !response.success? && options[:force_full_refund_if_unsettled] &&
|
122
|
+
response.message =~ /#{ERROR_CODES[:cannot_refund_if_unsettled]}/
|
123
|
+
void(transaction_id)
|
124
|
+
else
|
125
|
+
response
|
126
|
+
end
|
107
127
|
end
|
108
128
|
end
|
109
129
|
|
@@ -113,28 +133,46 @@ module ActiveMerchant #:nodoc:
|
|
113
133
|
end
|
114
134
|
end
|
115
135
|
|
116
|
-
def verify(
|
117
|
-
|
118
|
-
|
119
|
-
|
136
|
+
def verify(creditcard, options = {})
|
137
|
+
if options[:allow_card_verification] == true
|
138
|
+
options.delete(:allow_card_verification)
|
139
|
+
exp_month = creditcard.month.to_s
|
140
|
+
exp_year = creditcard.year.to_s
|
141
|
+
expiration = "#{exp_month}/#{exp_year}"
|
142
|
+
payload = {
|
143
|
+
credit_card: {
|
144
|
+
number: creditcard.number,
|
145
|
+
expiration_date: expiration,
|
146
|
+
cvv: creditcard.verification_value,
|
147
|
+
billing_address: {
|
148
|
+
postal_code: options[:billing_address][:zip]
|
149
|
+
}
|
150
|
+
}
|
151
|
+
}
|
152
|
+
commit do
|
153
|
+
result = @braintree_gateway.verification.create(payload)
|
154
|
+
response = Response.new(result.success?, message_from_transaction_result(result), response_options(result))
|
155
|
+
response.cvv_result['message'] = ''
|
156
|
+
response.cvv_result['code'] = response.params['cvv_result'] if response.params['cvv_result']
|
157
|
+
response.avs_result['code'] = response.params['avs_result'][:code] if response.params.dig('avs_result', :code)
|
158
|
+
response
|
159
|
+
end
|
160
|
+
|
161
|
+
else
|
162
|
+
MultiResponse.run(:use_first_response) do |r|
|
163
|
+
r.process { authorize(100, creditcard, options) }
|
164
|
+
r.process(:ignore_result) { void(r.authorization, options) }
|
165
|
+
end
|
120
166
|
end
|
121
167
|
end
|
122
168
|
|
123
|
-
def store(
|
124
|
-
if options
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
add_credit_card_to_customer(creditcard, options)
|
131
|
-
else
|
132
|
-
add_customer_with_credit_card(creditcard, options)
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
else
|
137
|
-
add_customer_with_credit_card(creditcard, options)
|
169
|
+
def store(payment_method, options = {})
|
170
|
+
return Response.new(false, bank_account_errors(payment_method, options)) if payment_method.is_a?(Check) && bank_account_errors(payment_method, options).present?
|
171
|
+
|
172
|
+
MultiResponse.run do |r|
|
173
|
+
r.process { check_customer_exists(options[:customer]) }
|
174
|
+
process_by = payment_method.is_a?(Check) ? :store_bank_account : :store_credit_card
|
175
|
+
send process_by, payment_method, options, r
|
138
176
|
end
|
139
177
|
end
|
140
178
|
|
@@ -146,33 +184,30 @@ module ActiveMerchant #:nodoc:
|
|
146
184
|
|
147
185
|
options[:update_existing_token] = braintree_credit_card.token
|
148
186
|
credit_card_params = merge_credit_card_options({
|
149
|
-
:
|
150
|
-
:
|
151
|
-
:
|
152
|
-
:
|
153
|
-
:
|
154
|
-
:
|
187
|
+
credit_card: {
|
188
|
+
cardholder_name: creditcard.name,
|
189
|
+
number: creditcard.number,
|
190
|
+
cvv: creditcard.verification_value,
|
191
|
+
expiration_month: creditcard.month.to_s.rjust(2, '0'),
|
192
|
+
expiration_year: creditcard.year.to_s
|
155
193
|
}
|
156
194
|
}, options)[:credit_card]
|
157
195
|
|
158
196
|
result = @braintree_gateway.customer.update(vault_id,
|
159
|
-
:
|
160
|
-
:
|
161
|
-
:
|
162
|
-
|
163
|
-
|
164
|
-
:credit_card => credit_card_params
|
165
|
-
)
|
197
|
+
first_name: creditcard.first_name,
|
198
|
+
last_name: creditcard.last_name,
|
199
|
+
email: scrub_email(options[:email]),
|
200
|
+
phone: phone_from(options),
|
201
|
+
credit_card: credit_card_params)
|
166
202
|
Response.new(result.success?, message_from_result(result),
|
167
|
-
:
|
168
|
-
:
|
169
|
-
)
|
203
|
+
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?))
|
170
205
|
end
|
171
206
|
end
|
172
207
|
|
173
208
|
def unstore(customer_vault_id, options = {})
|
174
209
|
commit do
|
175
|
-
if
|
210
|
+
if !customer_vault_id && options[:credit_card_token]
|
176
211
|
@braintree_gateway.credit_card.delete(options[:credit_card_token])
|
177
212
|
else
|
178
213
|
@braintree_gateway.customer.delete(customer_vault_id)
|
@@ -180,7 +215,7 @@ module ActiveMerchant #:nodoc:
|
|
180
215
|
Response.new(true, 'OK')
|
181
216
|
end
|
182
217
|
end
|
183
|
-
|
218
|
+
alias delete unstore
|
184
219
|
|
185
220
|
def supports_network_tokenization?
|
186
221
|
true
|
@@ -201,13 +236,13 @@ module ActiveMerchant #:nodoc:
|
|
201
236
|
private
|
202
237
|
|
203
238
|
def check_customer_exists(customer_vault_id)
|
239
|
+
return Response.new true, 'Customer not found', { exists: false } if customer_vault_id.blank?
|
240
|
+
|
204
241
|
commit do
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
ActiveMerchant::Billing::Response.new(true, 'Customer not found', {exists: false})
|
210
|
-
end
|
242
|
+
@braintree_gateway.customer.find(customer_vault_id)
|
243
|
+
ActiveMerchant::Billing::Response.new(true, 'Customer found', { exists: true }, authorization: customer_vault_id)
|
244
|
+
rescue Braintree::NotFoundError
|
245
|
+
ActiveMerchant::Billing::Response.new(true, 'Customer not found', { exists: false })
|
211
246
|
end
|
212
247
|
end
|
213
248
|
|
@@ -217,34 +252,32 @@ module ActiveMerchant #:nodoc:
|
|
217
252
|
credit_card_params = { payment_method_nonce: options[:payment_method_nonce] }
|
218
253
|
else
|
219
254
|
credit_card_params = {
|
220
|
-
:
|
221
|
-
:
|
222
|
-
:
|
223
|
-
:
|
224
|
-
:
|
225
|
-
:
|
226
|
-
:
|
255
|
+
credit_card: {
|
256
|
+
cardholder_name: creditcard.name,
|
257
|
+
number: creditcard.number,
|
258
|
+
cvv: creditcard.verification_value,
|
259
|
+
expiration_month: creditcard.month.to_s.rjust(2, '0'),
|
260
|
+
expiration_year: creditcard.year.to_s,
|
261
|
+
token: options[:credit_card_token]
|
227
262
|
}
|
228
263
|
}
|
229
264
|
end
|
230
265
|
parameters = {
|
231
|
-
:
|
232
|
-
:
|
233
|
-
:
|
234
|
-
|
235
|
-
|
236
|
-
:
|
237
|
-
:device_data => options[:device_data],
|
266
|
+
first_name: creditcard.first_name,
|
267
|
+
last_name: creditcard.last_name,
|
268
|
+
email: scrub_email(options[:email]),
|
269
|
+
phone: phone_from(options),
|
270
|
+
id: options[:customer],
|
271
|
+
device_data: options[:device_data]
|
238
272
|
}.merge credit_card_params
|
239
273
|
result = @braintree_gateway.customer.create(merge_credit_card_options(parameters, options))
|
240
274
|
Response.new(result.success?, message_from_result(result),
|
241
275
|
{
|
242
|
-
:
|
243
|
-
:
|
244
|
-
:
|
276
|
+
braintree_customer: (customer_hash(result.customer, :include_credit_cards) if result.success?),
|
277
|
+
customer_vault_id: (result.customer.id if result.success?),
|
278
|
+
credit_card_token: (result.customer.credit_cards[0].token if result.success?)
|
245
279
|
},
|
246
|
-
:
|
247
|
-
)
|
280
|
+
authorization: (result.customer.id if result.success?))
|
248
281
|
end
|
249
282
|
end
|
250
283
|
|
@@ -258,11 +291,11 @@ module ActiveMerchant #:nodoc:
|
|
258
291
|
cvv: credit_card.verification_value,
|
259
292
|
expiration_month: credit_card.month.to_s.rjust(2, '0'),
|
260
293
|
expiration_year: credit_card.year.to_s,
|
261
|
-
device_data: options[:device_data]
|
294
|
+
device_data: options[:device_data]
|
262
295
|
}
|
263
296
|
if options[:billing_address]
|
264
297
|
address = map_address(options[:billing_address])
|
265
|
-
parameters[:
|
298
|
+
parameters[:billing_address] = address unless address.all? { |_k, v| empty?(v) }
|
266
299
|
end
|
267
300
|
|
268
301
|
result = @braintree_gateway.credit_card.create(parameters)
|
@@ -289,22 +322,20 @@ module ActiveMerchant #:nodoc:
|
|
289
322
|
|
290
323
|
def scrub_zip(zip)
|
291
324
|
return nil unless zip.present?
|
292
|
-
return nil if
|
325
|
+
return nil if
|
293
326
|
zip.gsub(/[^a-z0-9]/i, '').length > 9 ||
|
294
327
|
zip =~ /[^a-z0-9\- ]/i
|
295
|
-
|
328
|
+
|
296
329
|
zip
|
297
330
|
end
|
298
331
|
|
299
332
|
def merge_credit_card_options(parameters, options)
|
300
333
|
valid_options = {}
|
301
334
|
options.each do |key, value|
|
302
|
-
valid_options[key] = value if [
|
335
|
+
valid_options[key] = value if %i[update_existing_token verify_card verification_merchant_account_id].include?(key)
|
303
336
|
end
|
304
337
|
|
305
|
-
if valid_options.include?(:verify_card) && @merchant_account_id
|
306
|
-
valid_options[:verification_merchant_account_id] ||= @merchant_account_id
|
307
|
-
end
|
338
|
+
valid_options[:verification_merchant_account_id] ||= @merchant_account_id if valid_options.include?(:verify_card) && @merchant_account_id
|
308
339
|
|
309
340
|
parameters[:credit_card] ||= {}
|
310
341
|
parameters[:credit_card][:options] = valid_options
|
@@ -315,22 +346,24 @@ module ActiveMerchant #:nodoc:
|
|
315
346
|
parameters
|
316
347
|
end
|
317
348
|
|
349
|
+
def phone_from(options)
|
350
|
+
options[:phone] || options.dig(:billing_address, :phone) || options.dig(:billing_address, :phone_number)
|
351
|
+
end
|
352
|
+
|
318
353
|
def map_address(address)
|
319
354
|
mapped = {
|
320
|
-
:
|
321
|
-
:
|
322
|
-
:
|
323
|
-
:
|
324
|
-
:
|
325
|
-
:
|
355
|
+
street_address: address[:address1],
|
356
|
+
extended_address: address[:address2],
|
357
|
+
company: address[:company],
|
358
|
+
locality: address[:city],
|
359
|
+
region: address[:state],
|
360
|
+
postal_code: scrub_zip(address[:zip])
|
326
361
|
}
|
327
362
|
|
328
363
|
mapped[:country_code_alpha2] = (address[:country] || address[:country_code_alpha2]) if address[:country] || address[:country_code_alpha2]
|
329
364
|
mapped[:country_name] = address[:country_name] if address[:country_name]
|
330
365
|
mapped[:country_code_alpha3] = address[:country_code_alpha3] if address[:country_code_alpha3]
|
331
|
-
unless address[:country].blank?
|
332
|
-
mapped[:country_code_alpha3] ||= Country.find(address[:country]).code(:alpha3).value
|
333
|
-
end
|
366
|
+
mapped[:country_code_alpha3] ||= Country.find(address[:country]).code(:alpha3).value unless address[:country].blank?
|
334
367
|
mapped[:country_code_numeric] = address[:country_code_numeric] if address[:country_code_numeric]
|
335
368
|
|
336
369
|
mapped
|
@@ -375,7 +408,11 @@ module ActiveMerchant #:nodoc:
|
|
375
408
|
|
376
409
|
def response_options(result)
|
377
410
|
options = {}
|
378
|
-
if result.
|
411
|
+
if result.credit_card_verification
|
412
|
+
options[:authorization] = result.credit_card_verification.id
|
413
|
+
options[:avs_result] = { code: avs_code_from(result.credit_card_verification) }
|
414
|
+
options[:cvv_result] = result.credit_card_verification.cvv_response_code
|
415
|
+
elsif result.transaction
|
379
416
|
options[:authorization] = result.transaction.id
|
380
417
|
options[:avs_result] = { code: avs_code_from(result.transaction) }
|
381
418
|
options[:cvv_result] = result.transaction.cvv_response_code
|
@@ -445,16 +482,28 @@ module ActiveMerchant #:nodoc:
|
|
445
482
|
end
|
446
483
|
end
|
447
484
|
|
485
|
+
def additional_processor_response_from_result(result)
|
486
|
+
result.transaction&.additional_processor_response
|
487
|
+
end
|
488
|
+
|
448
489
|
def create_transaction(transaction_type, money, credit_card_or_vault_id, options)
|
449
490
|
transaction_params = create_transaction_parameters(money, credit_card_or_vault_id, options)
|
450
491
|
commit do
|
451
492
|
result = @braintree_gateway.transaction.send(transaction_type, transaction_params)
|
493
|
+
make_default_payment_method_token(result) if options.dig(:paypal, :paypal_flow_type) == 'checkout_with_vault' && result.success?
|
452
494
|
response = Response.new(result.success?, message_from_transaction_result(result), response_params(result), response_options(result))
|
453
495
|
response.cvv_result['message'] = ''
|
454
496
|
response
|
455
497
|
end
|
456
498
|
end
|
457
499
|
|
500
|
+
def make_default_payment_method_token(result)
|
501
|
+
@braintree_gateway.customer.update(
|
502
|
+
result.transaction.customer_details.id,
|
503
|
+
default_payment_method_token: result.transaction.paypal_details.implicitly_vaulted_payment_method_token
|
504
|
+
)
|
505
|
+
end
|
506
|
+
|
458
507
|
def extract_refund_args(args)
|
459
508
|
options = args.extract_options!
|
460
509
|
|
@@ -468,7 +517,7 @@ module ActiveMerchant #:nodoc:
|
|
468
517
|
end
|
469
518
|
end
|
470
519
|
|
471
|
-
def customer_hash(customer, include_credit_cards=false)
|
520
|
+
def customer_hash(customer, include_credit_cards = false)
|
472
521
|
hash = {
|
473
522
|
'email' => customer.email,
|
474
523
|
'phone' => customer.phone,
|
@@ -495,7 +544,8 @@ module ActiveMerchant #:nodoc:
|
|
495
544
|
|
496
545
|
def transaction_hash(result)
|
497
546
|
unless result.success?
|
498
|
-
return { 'processor_response_code' => response_code_from_result(result)
|
547
|
+
return { 'processor_response_code' => response_code_from_result(result),
|
548
|
+
'additional_processor_response' => additional_processor_response_from_result(result) }
|
499
549
|
end
|
500
550
|
|
501
551
|
transaction = result.transaction
|
@@ -514,7 +564,7 @@ module ActiveMerchant #:nodoc:
|
|
514
564
|
customer_details = {
|
515
565
|
'id' => transaction.customer_details.id,
|
516
566
|
'email' => transaction.customer_details.email,
|
517
|
-
'phone' => transaction.customer_details.phone
|
567
|
+
'phone' => transaction.customer_details.phone
|
518
568
|
}
|
519
569
|
|
520
570
|
billing_details = {
|
@@ -524,7 +574,7 @@ module ActiveMerchant #:nodoc:
|
|
524
574
|
'locality' => transaction.billing_details.locality,
|
525
575
|
'region' => transaction.billing_details.region,
|
526
576
|
'postal_code' => transaction.billing_details.postal_code,
|
527
|
-
'country_name' => transaction.billing_details.country_name
|
577
|
+
'country_name' => transaction.billing_details.country_name
|
528
578
|
}
|
529
579
|
|
530
580
|
shipping_details = {
|
@@ -534,7 +584,7 @@ module ActiveMerchant #:nodoc:
|
|
534
584
|
'locality' => transaction.shipping_details.locality,
|
535
585
|
'region' => transaction.shipping_details.region,
|
536
586
|
'postal_code' => transaction.shipping_details.postal_code,
|
537
|
-
'country_name' => transaction.shipping_details.country_name
|
587
|
+
'country_name' => transaction.shipping_details.country_name
|
538
588
|
}
|
539
589
|
credit_card_details = {
|
540
590
|
'masked_number' => transaction.credit_card_details.masked_number,
|
@@ -556,97 +606,182 @@ module ActiveMerchant #:nodoc:
|
|
556
606
|
end
|
557
607
|
|
558
608
|
{
|
559
|
-
'order_id'
|
560
|
-
'amount'
|
561
|
-
'status'
|
562
|
-
'credit_card_details'
|
563
|
-
'customer_details'
|
564
|
-
'billing_details'
|
565
|
-
'shipping_details'
|
566
|
-
'vault_customer'
|
567
|
-
'merchant_account_id'
|
568
|
-
'risk_data'
|
569
|
-
'network_transaction_id'
|
570
|
-
'processor_response_code'
|
609
|
+
'order_id' => transaction.order_id,
|
610
|
+
'amount' => transaction.amount.to_s,
|
611
|
+
'status' => transaction.status,
|
612
|
+
'credit_card_details' => credit_card_details,
|
613
|
+
'customer_details' => customer_details,
|
614
|
+
'billing_details' => billing_details,
|
615
|
+
'shipping_details' => shipping_details,
|
616
|
+
'vault_customer' => vault_customer,
|
617
|
+
'merchant_account_id' => transaction.merchant_account_id,
|
618
|
+
'risk_data' => risk_data,
|
619
|
+
'network_transaction_id' => transaction.network_transaction_id || nil,
|
620
|
+
'processor_response_code' => response_code_from_result(result),
|
621
|
+
'processor_authorization_code' => transaction.processor_authorization_code,
|
622
|
+
'recurring' => transaction.recurring
|
571
623
|
}
|
572
624
|
end
|
573
625
|
|
574
626
|
def create_transaction_parameters(money, credit_card_or_vault_id, options)
|
575
627
|
parameters = {
|
576
|
-
:
|
577
|
-
:
|
578
|
-
:
|
579
|
-
:
|
580
|
-
:
|
581
|
-
|
582
|
-
options[:billing_address][:phone])
|
628
|
+
amount: localized_amount(money, options[:currency] || default_currency).to_s,
|
629
|
+
order_id: options[:order_id],
|
630
|
+
customer: {
|
631
|
+
id: options[:store] == true ? '' : options[:store],
|
632
|
+
email: scrub_email(options[:email]),
|
633
|
+
phone: phone_from(options)
|
583
634
|
},
|
584
|
-
:
|
585
|
-
:
|
586
|
-
:
|
587
|
-
:
|
635
|
+
options: {
|
636
|
+
store_in_vault: options[:store] ? true : false,
|
637
|
+
submit_for_settlement: options[:submit_for_settlement],
|
638
|
+
hold_in_escrow: options[:hold_in_escrow]
|
588
639
|
}
|
589
640
|
}
|
590
641
|
|
591
|
-
if options[:skip_advanced_fraud_checking]
|
592
|
-
parameters[:options][:skip_advanced_fraud_checking] = options[:skip_advanced_fraud_checking]
|
593
|
-
end
|
594
|
-
|
595
|
-
if options[:skip_avs]
|
596
|
-
parameters[:options][:skip_avs] = options[:skip_avs]
|
597
|
-
end
|
598
|
-
|
599
|
-
if options[:skip_cvv]
|
600
|
-
parameters[:options][:skip_cvv] = options[:skip_cvv]
|
601
|
-
end
|
602
|
-
|
603
642
|
parameters[:custom_fields] = options[:custom_fields]
|
604
643
|
parameters[:device_data] = options[:device_data] if options[:device_data]
|
605
644
|
parameters[:service_fee_amount] = options[:service_fee_amount] if options[:service_fee_amount]
|
606
|
-
if merchant_account_id = (options[:merchant_account_id] || @merchant_account_id)
|
607
|
-
parameters[:merchant_account_id] = merchant_account_id
|
608
|
-
end
|
609
645
|
|
610
|
-
if options[:
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
end
|
646
|
+
add_account_type(parameters, options) if options[:account_type]
|
647
|
+
add_skip_options(parameters, options)
|
648
|
+
add_merchant_account_id(parameters, options)
|
649
|
+
add_profile_id(parameters, options)
|
615
650
|
|
616
651
|
add_payment_method(parameters, credit_card_or_vault_id, options)
|
617
652
|
add_stored_credential_data(parameters, credit_card_or_vault_id, options)
|
653
|
+
add_addresses(parameters, options)
|
654
|
+
|
655
|
+
add_descriptor(parameters, options)
|
656
|
+
add_risk_data(parameters, options)
|
657
|
+
add_paypal_options(parameters, options)
|
658
|
+
add_travel_data(parameters, options) if options[:travel_data]
|
659
|
+
add_lodging_data(parameters, options) if options[:lodging_data]
|
660
|
+
add_channel(parameters, options)
|
661
|
+
add_transaction_source(parameters, options)
|
662
|
+
|
663
|
+
add_level_2_data(parameters, options)
|
664
|
+
add_level_3_data(parameters, options)
|
665
|
+
|
666
|
+
add_3ds_info(parameters, options[:three_d_secure])
|
667
|
+
|
668
|
+
if options[:payment_method_nonce].is_a?(String)
|
669
|
+
parameters.delete(:customer)
|
670
|
+
parameters[:payment_method_nonce] = options[:payment_method_nonce]
|
671
|
+
end
|
672
|
+
|
673
|
+
parameters
|
674
|
+
end
|
675
|
+
|
676
|
+
def add_account_type(parameters, options)
|
677
|
+
parameters[:options][:credit_card] = {}
|
678
|
+
parameters[:options][:credit_card][:account_type] = options[:account_type]
|
679
|
+
end
|
618
680
|
|
681
|
+
def add_skip_options(parameters, options)
|
682
|
+
parameters[:options][:skip_advanced_fraud_checking] = options[:skip_advanced_fraud_checking] if options[:skip_advanced_fraud_checking]
|
683
|
+
parameters[:options][:skip_avs] = options[:skip_avs] if options[:skip_avs]
|
684
|
+
parameters[:options][:skip_cvv] = options[:skip_cvv] if options[:skip_cvv]
|
685
|
+
end
|
686
|
+
|
687
|
+
def add_merchant_account_id(parameters, options)
|
688
|
+
return unless merchant_account_id = (options[:merchant_account_id] || @merchant_account_id)
|
689
|
+
|
690
|
+
parameters[:merchant_account_id] = merchant_account_id
|
691
|
+
end
|
692
|
+
|
693
|
+
def add_profile_id(parameters, options)
|
694
|
+
return unless profile_id = options[:venmo_profile_id]
|
695
|
+
|
696
|
+
parameters[:options][:venmo] = {}
|
697
|
+
parameters[:options][:venmo][:profile_id] = profile_id
|
698
|
+
end
|
699
|
+
|
700
|
+
def add_transaction_source(parameters, options)
|
701
|
+
parameters[:transaction_source] = options[:transaction_source] if options[:transaction_source]
|
702
|
+
parameters[:transaction_source] = 'recurring' if options[:recurring]
|
703
|
+
end
|
704
|
+
|
705
|
+
def add_addresses(parameters, options)
|
619
706
|
parameters[:billing] = map_address(options[:billing_address]) if options[:billing_address]
|
620
707
|
parameters[:shipping] = map_address(options[:shipping_address]) if options[:shipping_address]
|
708
|
+
end
|
621
709
|
|
710
|
+
def add_channel(parameters, options)
|
622
711
|
channel = @options[:channel] || application_id
|
623
712
|
parameters[:channel] = channel if channel
|
713
|
+
end
|
624
714
|
|
625
|
-
|
626
|
-
|
627
|
-
name: options[:descriptor_name],
|
628
|
-
phone: options[:descriptor_phone],
|
629
|
-
url: options[:descriptor_url]
|
630
|
-
}
|
631
|
-
end
|
715
|
+
def add_descriptor(parameters, options)
|
716
|
+
return unless options[:descriptor_name] || options[:descriptor_phone] || options[:descriptor_url]
|
632
717
|
|
633
|
-
|
718
|
+
parameters[:descriptor] = {
|
719
|
+
name: options[:descriptor_name],
|
720
|
+
phone: options[:descriptor_phone],
|
721
|
+
url: options[:descriptor_url]
|
722
|
+
}
|
723
|
+
end
|
724
|
+
|
725
|
+
def add_risk_data(parameters, options)
|
726
|
+
return unless options[:risk_data]
|
727
|
+
|
728
|
+
parameters[:risk_data] = {
|
729
|
+
customer_browser: options[:risk_data][:customer_browser],
|
730
|
+
customer_ip: options[:risk_data][:customer_ip]
|
731
|
+
}
|
732
|
+
end
|
733
|
+
|
734
|
+
def add_paypal_options(parameters, options)
|
735
|
+
return unless options[:paypal_custom_field] || options[:paypal_description]
|
634
736
|
|
737
|
+
parameters[:options][:paypal] = {
|
738
|
+
custom_field: options[:paypal_custom_field],
|
739
|
+
description: options[:paypal_description]
|
740
|
+
}
|
741
|
+
end
|
742
|
+
|
743
|
+
def add_level_2_data(parameters, options)
|
635
744
|
parameters[:tax_amount] = options[:tax_amount] if options[:tax_amount]
|
636
745
|
parameters[:tax_exempt] = options[:tax_exempt] if options[:tax_exempt]
|
637
746
|
parameters[:purchase_order_number] = options[:purchase_order_number] if options[:purchase_order_number]
|
747
|
+
end
|
638
748
|
|
749
|
+
def add_level_3_data(parameters, options)
|
639
750
|
parameters[:shipping_amount] = options[:shipping_amount] if options[:shipping_amount]
|
640
751
|
parameters[:discount_amount] = options[:discount_amount] if options[:discount_amount]
|
641
752
|
parameters[:ships_from_postal_code] = options[:ships_from_postal_code] if options[:ships_from_postal_code]
|
642
753
|
|
643
754
|
parameters[:line_items] = options[:line_items] if options[:line_items]
|
755
|
+
end
|
644
756
|
|
645
|
-
|
757
|
+
def add_travel_data(parameters, options)
|
758
|
+
parameters[:industry] = {
|
759
|
+
industry_type: Braintree::Transaction::IndustryType::TravelAndCruise,
|
760
|
+
data: {}
|
761
|
+
}
|
762
|
+
|
763
|
+
parameters[:industry][:data][:travel_package] = options[:travel_data][:travel_package] if options[:travel_data][:travel_package]
|
764
|
+
parameters[:industry][:data][:departure_date] = options[:travel_data][:departure_date] if options[:travel_data][:departure_date]
|
765
|
+
parameters[:industry][:data][:lodging_check_in_date] = options[:travel_data][:lodging_check_in_date] if options[:travel_data][:lodging_check_in_date]
|
766
|
+
parameters[:industry][:data][:lodging_check_out_date] = options[:travel_data][:lodging_check_out_date] if options[:travel_data][:lodging_check_out_date]
|
767
|
+
parameters[:industry][:data][:lodging_name] = options[:travel_data][:lodging_name] if options[:travel_data][:lodging_name]
|
768
|
+
end
|
769
|
+
|
770
|
+
def add_lodging_data(parameters, options)
|
771
|
+
parameters[:industry] = {
|
772
|
+
industry_type: Braintree::Transaction::IndustryType::Lodging,
|
773
|
+
data: {}
|
774
|
+
}
|
775
|
+
|
776
|
+
parameters[:industry][:data][:folio_number] = options[:lodging_data][:folio_number] if options[:lodging_data][:folio_number]
|
777
|
+
parameters[:industry][:data][:check_in_date] = options[:lodging_data][:check_in_date] if options[:lodging_data][:check_in_date]
|
778
|
+
parameters[:industry][:data][:check_out_date] = options[:lodging_data][:check_out_date] if options[:lodging_data][:check_out_date]
|
779
|
+
parameters[:industry][:data][:room_rate] = options[:lodging_data][:room_rate] if options[:lodging_data][:room_rate]
|
646
780
|
end
|
647
781
|
|
648
782
|
def add_3ds_info(parameters, three_d_secure_opts)
|
649
783
|
return if empty?(three_d_secure_opts)
|
784
|
+
|
650
785
|
pass_thru = {}
|
651
786
|
|
652
787
|
pass_thru[:three_d_secure_version] = three_d_secure_opts[:version] if three_d_secure_opts[:version]
|
@@ -669,6 +804,7 @@ module ActiveMerchant #:nodoc:
|
|
669
804
|
|
670
805
|
def add_stored_credential_data(parameters, credit_card_or_vault_id, options)
|
671
806
|
return unless (stored_credential = options[:stored_credential])
|
807
|
+
|
672
808
|
parameters[:external_vault] = {}
|
673
809
|
if stored_credential[:initial_transaction]
|
674
810
|
parameters[:external_vault][:status] = 'will_vault'
|
@@ -682,6 +818,8 @@ module ActiveMerchant #:nodoc:
|
|
682
818
|
else
|
683
819
|
parameters[:transaction_source] = stored_credential[:reason_type]
|
684
820
|
end
|
821
|
+
elsif %w(recurring_first moto).include?(stored_credential[:reason_type])
|
822
|
+
parameters[:transaction_source] = stored_credential[:reason_type]
|
685
823
|
else
|
686
824
|
parameters[:transaction_source] = ''
|
687
825
|
end
|
@@ -699,42 +837,116 @@ module ActiveMerchant #:nodoc:
|
|
699
837
|
end
|
700
838
|
else
|
701
839
|
parameters[:customer].merge!(
|
702
|
-
:
|
703
|
-
:
|
840
|
+
first_name: credit_card_or_vault_id.first_name,
|
841
|
+
last_name: credit_card_or_vault_id.last_name
|
704
842
|
)
|
705
843
|
if credit_card_or_vault_id.is_a?(NetworkTokenizationCreditCard)
|
706
844
|
if credit_card_or_vault_id.source == :apple_pay
|
707
845
|
parameters[:apple_pay_card] = {
|
708
|
-
:
|
709
|
-
:
|
710
|
-
:
|
711
|
-
:
|
712
|
-
:
|
713
|
-
:
|
846
|
+
number: credit_card_or_vault_id.number,
|
847
|
+
expiration_month: credit_card_or_vault_id.month.to_s.rjust(2, '0'),
|
848
|
+
expiration_year: credit_card_or_vault_id.year.to_s,
|
849
|
+
cardholder_name: credit_card_or_vault_id.name,
|
850
|
+
cryptogram: credit_card_or_vault_id.payment_cryptogram,
|
851
|
+
eci_indicator: credit_card_or_vault_id.eci
|
714
852
|
}
|
715
853
|
elsif credit_card_or_vault_id.source == :android_pay || credit_card_or_vault_id.source == :google_pay
|
716
|
-
|
717
|
-
|
718
|
-
:
|
719
|
-
:
|
720
|
-
:
|
721
|
-
:
|
722
|
-
:
|
723
|
-
:
|
724
|
-
:
|
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
|
725
864
|
}
|
726
865
|
end
|
727
866
|
else
|
728
867
|
parameters[:credit_card] = {
|
729
|
-
:
|
730
|
-
:
|
731
|
-
:
|
732
|
-
:
|
733
|
-
:
|
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
|
734
873
|
}
|
735
874
|
end
|
736
875
|
end
|
737
876
|
end
|
877
|
+
|
878
|
+
def bank_account_errors(payment_method, options)
|
879
|
+
if payment_method.validate.present?
|
880
|
+
payment_method.validate
|
881
|
+
elsif options[:billing_address].blank?
|
882
|
+
'billing_address is required parameter to store and verify Bank accounts.'
|
883
|
+
elsif options[:ach_mandate].blank?
|
884
|
+
'ach_mandate is a required parameter to process bank acccount transactions see (https://developer.paypal.com/braintree/docs/guides/ach/client-side#show-required-authorization-language)'
|
885
|
+
end
|
886
|
+
end
|
887
|
+
|
888
|
+
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 payment_method
|
890
|
+
return Response.new(false, error_message) unless bank_account_nonce.present?
|
891
|
+
|
892
|
+
result = @braintree_gateway.payment_method.create(
|
893
|
+
customer_id: options[:customer],
|
894
|
+
payment_method_nonce: bank_account_nonce,
|
895
|
+
options: {
|
896
|
+
us_bank_account_verification_method: 'network_check'
|
897
|
+
}
|
898
|
+
)
|
899
|
+
|
900
|
+
verified = result.success? && result.payment_method&.verified
|
901
|
+
message = message_from_result(result)
|
902
|
+
message = not_verified_reason(result.payment_method) unless verified
|
903
|
+
|
904
|
+
Response.new(verified, message,
|
905
|
+
{
|
906
|
+
customer_vault_id: options[:customer],
|
907
|
+
bank_account_token: result.payment_method&.token,
|
908
|
+
verified: verified
|
909
|
+
},
|
910
|
+
authorization: result.payment_method&.token)
|
911
|
+
end
|
912
|
+
|
913
|
+
def not_verified_reason(bank_account)
|
914
|
+
return unless bank_account.verifications.present?
|
915
|
+
|
916
|
+
verification = bank_account.verifications.first
|
917
|
+
"verification_status: [#{verification.status}], processor_response: [#{verification.processor_response_code}-#{verification.processor_response_text}]"
|
918
|
+
end
|
919
|
+
|
920
|
+
def store_bank_account(payment_method, options, multi_response)
|
921
|
+
multi_response.process { create_customer_from_bank_account payment_method, options } unless multi_response.params['exists']
|
922
|
+
multi_response.process { add_bank_account_to_customer payment_method, options }
|
923
|
+
end
|
924
|
+
|
925
|
+
def store_credit_card(payment_method, options, multi_response)
|
926
|
+
process_by = multi_response.params['exists'] ? :add_credit_card_to_customer : :add_customer_with_credit_card
|
927
|
+
multi_response.process { send process_by, payment_method, options }
|
928
|
+
end
|
929
|
+
|
930
|
+
def create_customer_from_bank_account(payment_method, options)
|
931
|
+
parameters = {
|
932
|
+
id: options[:customer],
|
933
|
+
first_name: payment_method.first_name,
|
934
|
+
last_name: payment_method.last_name,
|
935
|
+
email: scrub_email(options[:email]),
|
936
|
+
phone: phone_from(options),
|
937
|
+
device_data: options[:device_data]
|
938
|
+
}.compact
|
939
|
+
|
940
|
+
result = @braintree_gateway.customer.create(parameters)
|
941
|
+
customer_id = result.customer.id if result.success?
|
942
|
+
options[:customer] = customer_id
|
943
|
+
|
944
|
+
Response.new(
|
945
|
+
result.success?,
|
946
|
+
message_from_result(result),
|
947
|
+
{ customer_vault_id: customer_id, 'exists': true }
|
948
|
+
)
|
949
|
+
end
|
738
950
|
end
|
739
951
|
end
|
740
952
|
end
|