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,27 +1,27 @@
|
|
1
1
|
module ActiveMerchant #:nodoc:
|
2
2
|
module Billing #:nodoc:
|
3
3
|
class WorldpayOnlinePaymentsGateway < Gateway
|
4
|
-
self.live_url =
|
4
|
+
self.live_url = 'https://api.worldpay.com/v1/'
|
5
5
|
|
6
6
|
self.default_currency = 'GBP'
|
7
7
|
|
8
8
|
self.money_format = :cents
|
9
9
|
|
10
10
|
self.supported_countries = %w(HK US GB BE CH CZ DE DK ES FI FR GR HU IE IT LU MT NL NO PL PT SE SG TR)
|
11
|
-
self.supported_cardtypes = [
|
11
|
+
self.supported_cardtypes = %i[visa master american_express discover jcb maestro]
|
12
12
|
|
13
13
|
self.homepage_url = 'http://online.worldpay.com'
|
14
14
|
self.display_name = 'Worldpay Online Payments'
|
15
15
|
|
16
|
-
def initialize(options={})
|
16
|
+
def initialize(options = {})
|
17
17
|
requires!(options, :client_key, :service_key)
|
18
18
|
@client_key = options[:client_key]
|
19
19
|
@service_key = options[:service_key]
|
20
20
|
super
|
21
21
|
end
|
22
22
|
|
23
|
-
def authorize(money, credit_card, options={})
|
24
|
-
response = create_token(true, credit_card.first_name+' '+credit_card.last_name, credit_card.month, credit_card.year, credit_card.number, credit_card.verification_value)
|
23
|
+
def authorize(money, credit_card, options = {})
|
24
|
+
response = create_token(true, credit_card.first_name + ' ' + credit_card.last_name, credit_card.month, credit_card.year, credit_card.number, credit_card.verification_value)
|
25
25
|
if response.success?
|
26
26
|
options[:authorizeOnly] = true
|
27
27
|
post = create_post_for_auth_or_purchase(response.authorization, money, options)
|
@@ -30,24 +30,23 @@ module ActiveMerchant #:nodoc:
|
|
30
30
|
response
|
31
31
|
end
|
32
32
|
|
33
|
-
def capture(money, authorization, options={})
|
33
|
+
def capture(money, authorization, options = {})
|
34
34
|
if authorization
|
35
|
-
commit(:post, "orders/#{CGI.escape(authorization)}/capture", {'captureAmount'=>money}, options, 'capture')
|
35
|
+
commit(:post, "orders/#{CGI.escape(authorization)}/capture", { 'captureAmount' => money }, options, 'capture')
|
36
36
|
else
|
37
37
|
Response.new(false,
|
38
38
|
'FAILED',
|
39
39
|
'FAILED',
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
43
|
-
:
|
44
|
-
:
|
45
|
-
)
|
40
|
+
test: test?,
|
41
|
+
authorization: false,
|
42
|
+
avs_result: {},
|
43
|
+
cvv_result: {},
|
44
|
+
error_code: false)
|
46
45
|
end
|
47
46
|
end
|
48
47
|
|
49
|
-
def purchase(money, credit_card, options={})
|
50
|
-
response = create_token(true, credit_card.first_name+' '+credit_card.last_name, credit_card.month, credit_card.year, credit_card.number, credit_card.verification_value)
|
48
|
+
def purchase(money, credit_card, options = {})
|
49
|
+
response = create_token(true, credit_card.first_name + ' ' + credit_card.last_name, credit_card.month, credit_card.year, credit_card.number, credit_card.verification_value)
|
51
50
|
if response.success?
|
52
51
|
post = create_post_for_auth_or_purchase(response.authorization, money, options)
|
53
52
|
response = commit(:post, 'orders', post, options, 'purchase')
|
@@ -55,20 +54,18 @@ module ActiveMerchant #:nodoc:
|
|
55
54
|
response
|
56
55
|
end
|
57
56
|
|
58
|
-
def refund(money, orderCode, options={})
|
59
|
-
obj = money ? {'refundAmount' => money} : {}
|
57
|
+
def refund(money, orderCode, options = {})
|
58
|
+
obj = money ? { 'refundAmount' => money } : {}
|
60
59
|
commit(:post, "orders/#{CGI.escape(orderCode)}/refund", obj, options, 'refund')
|
61
60
|
end
|
62
61
|
|
63
|
-
def void(orderCode, options={})
|
62
|
+
def void(orderCode, options = {})
|
64
63
|
response = commit(:delete, "orders/#{CGI.escape(orderCode)}", nil, options, 'void')
|
65
|
-
if !response.success? && (response.params && response.params['customCode'] != 'ORDER_NOT_FOUND')
|
66
|
-
response = refund(nil, orderCode)
|
67
|
-
end
|
64
|
+
response = refund(nil, orderCode) if !response.success? && (response.params && response.params['customCode'] != 'ORDER_NOT_FOUND')
|
68
65
|
response
|
69
66
|
end
|
70
67
|
|
71
|
-
def verify(credit_card, options={})
|
68
|
+
def verify(credit_card, options = {})
|
72
69
|
authorize(0, credit_card, options)
|
73
70
|
end
|
74
71
|
|
@@ -76,18 +73,18 @@ module ActiveMerchant #:nodoc:
|
|
76
73
|
|
77
74
|
def create_token(reusable, name, exp_month, exp_year, number, cvc)
|
78
75
|
obj = {
|
79
|
-
'reusable'=> reusable,
|
80
|
-
'paymentMethod'=> {
|
81
|
-
'type'=> 'Card',
|
82
|
-
'name'=> name,
|
83
|
-
'expiryMonth'=> exp_month,
|
84
|
-
'expiryYear'=> exp_year,
|
85
|
-
'cardNumber'=> number,
|
86
|
-
'cvc'=> cvc
|
76
|
+
'reusable' => reusable,
|
77
|
+
'paymentMethod' => {
|
78
|
+
'type' => 'Card',
|
79
|
+
'name' => name,
|
80
|
+
'expiryMonth' => exp_month,
|
81
|
+
'expiryYear' => exp_year,
|
82
|
+
'cardNumber' => number,
|
83
|
+
'cvc' => cvc
|
87
84
|
},
|
88
|
-
'clientKey'=> @client_key
|
85
|
+
'clientKey' => @client_key
|
89
86
|
}
|
90
|
-
token_response = commit(:post, 'tokens', obj, {'Authorization' => @service_key}, 'token')
|
87
|
+
token_response = commit(:post, 'tokens', obj, { 'Authorization' => @service_key }, 'token')
|
91
88
|
token_response
|
92
89
|
end
|
93
90
|
|
@@ -97,16 +94,16 @@ module ActiveMerchant #:nodoc:
|
|
97
94
|
'orderDescription' => options[:description] || 'Worldpay Order',
|
98
95
|
'amount' => money,
|
99
96
|
'currencyCode' => options[:currency] || default_currency,
|
100
|
-
'name' => options[:billing_address]&&options[:billing_address][:name] ? options[:billing_address][:name] : '',
|
97
|
+
'name' => options[:billing_address] && options[:billing_address][:name] ? options[:billing_address][:name] : '',
|
101
98
|
'billingAddress' => {
|
102
|
-
'address1'=>options[:billing_address]&&options[:billing_address][:address1] ? options[:billing_address][:address1] : '',
|
103
|
-
'address2'=>options[:billing_address]&&options[:billing_address][:address2] ? options[:billing_address][:address2] : '',
|
104
|
-
'address3'=>'',
|
105
|
-
'postalCode'=>options[:billing_address]&&options[:billing_address][:zip] ? options[:billing_address][:zip] : '',
|
106
|
-
'city'=>options[:billing_address]&&options[:billing_address][:city] ? options[:billing_address][:city] : '',
|
107
|
-
'state'=>options[:billing_address]&&options[:billing_address][:state] ? options[:billing_address][:state] : '',
|
108
|
-
'countryCode'=>options[:billing_address]&&options[:billing_address][:country] ? options[:billing_address][:country] : ''
|
109
|
-
|
99
|
+
'address1' => options[:billing_address] && options[:billing_address][:address1] ? options[:billing_address][:address1] : '',
|
100
|
+
'address2' => options[:billing_address] && options[:billing_address][:address2] ? options[:billing_address][:address2] : '',
|
101
|
+
'address3' => '',
|
102
|
+
'postalCode' => options[:billing_address] && options[:billing_address][:zip] ? options[:billing_address][:zip] : '',
|
103
|
+
'city' => options[:billing_address] && options[:billing_address][:city] ? options[:billing_address][:city] : '',
|
104
|
+
'state' => options[:billing_address] && options[:billing_address][:state] ? options[:billing_address][:state] : '',
|
105
|
+
'countryCode' => options[:billing_address] && options[:billing_address][:country] ? options[:billing_address][:country] : ''
|
106
|
+
},
|
110
107
|
'customerOrderCode' => options[:order_id],
|
111
108
|
'orderType' => 'ECOM',
|
112
109
|
'authorizeOnly' => options[:authorizeOnly] ? true : false
|
@@ -123,15 +120,13 @@ module ActiveMerchant #:nodoc:
|
|
123
120
|
'Content-Type' => 'application/json',
|
124
121
|
'User-Agent' => "Worldpay/v1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
|
125
122
|
'X-Worldpay-Client-User-Agent' => user_agent,
|
126
|
-
'X-Worldpay-Client-User-Metadata' => {:
|
123
|
+
'X-Worldpay-Client-User-Metadata' => { ip: options[:ip] }.to_json
|
127
124
|
}
|
128
|
-
if options['Authorization']
|
129
|
-
headers['Authorization'] = options['Authorization']
|
130
|
-
end
|
125
|
+
headers['Authorization'] = options['Authorization'] if options['Authorization']
|
131
126
|
headers
|
132
127
|
end
|
133
128
|
|
134
|
-
def commit(method, url, parameters=nil, options = {}, type = false)
|
129
|
+
def commit(method, url, parameters = nil, options = {}, type = false)
|
135
130
|
raw_response = response = nil
|
136
131
|
success = false
|
137
132
|
begin
|
@@ -151,7 +146,7 @@ module ActiveMerchant #:nodoc:
|
|
151
146
|
success = true
|
152
147
|
elsif type == 'purchase' && response['paymentStatus'] == 'SUCCESS'
|
153
148
|
success = true
|
154
|
-
elsif type == 'capture' || type=='refund' || type=='void'
|
149
|
+
elsif type == 'capture' || type == 'refund' || type == 'void'
|
155
150
|
success = true
|
156
151
|
end
|
157
152
|
end
|
@@ -178,12 +173,11 @@ module ActiveMerchant #:nodoc:
|
|
178
173
|
Response.new(success,
|
179
174
|
success ? 'SUCCESS' : response['message'],
|
180
175
|
response,
|
181
|
-
:
|
182
|
-
:
|
183
|
-
:
|
184
|
-
:
|
185
|
-
:
|
186
|
-
)
|
176
|
+
test: test?,
|
177
|
+
authorization: authorization,
|
178
|
+
avs_result: {},
|
179
|
+
cvv_result: {},
|
180
|
+
error_code: success ? nil : response['customCode'])
|
187
181
|
end
|
188
182
|
|
189
183
|
def test?
|
@@ -209,7 +203,6 @@ module ActiveMerchant #:nodoc:
|
|
209
203
|
def handle_response(response)
|
210
204
|
response.body
|
211
205
|
end
|
212
|
-
|
213
206
|
end
|
214
207
|
end
|
215
208
|
end
|
@@ -15,14 +15,14 @@ module ActiveMerchant #:nodoc:
|
|
15
15
|
self.supported_countries = ['US']
|
16
16
|
self.default_currency = 'USD'
|
17
17
|
self.money_format = :dollars
|
18
|
-
self.supported_cardtypes = [
|
18
|
+
self.supported_cardtypes = %i[visa master american_express discover jcb]
|
19
19
|
|
20
|
-
def initialize(options={})
|
20
|
+
def initialize(options = {})
|
21
21
|
requires!(options, :acctid, :subid, :merchantpin)
|
22
22
|
super
|
23
23
|
end
|
24
24
|
|
25
|
-
def purchase(money, payment_method, options={})
|
25
|
+
def purchase(money, payment_method, options = {})
|
26
26
|
post = {}
|
27
27
|
add_invoice(post, money, options)
|
28
28
|
add_payment_method(post, payment_method)
|
@@ -31,7 +31,7 @@ module ActiveMerchant #:nodoc:
|
|
31
31
|
commit('purchase', options, post)
|
32
32
|
end
|
33
33
|
|
34
|
-
def authorize(money, payment, options={})
|
34
|
+
def authorize(money, payment, options = {})
|
35
35
|
post = {}
|
36
36
|
add_invoice(post, money, options)
|
37
37
|
add_credit_card(post, payment)
|
@@ -40,7 +40,7 @@ module ActiveMerchant #:nodoc:
|
|
40
40
|
commit('authorize', options, post)
|
41
41
|
end
|
42
42
|
|
43
|
-
def capture(amount, authorization, options={})
|
43
|
+
def capture(amount, authorization, options = {})
|
44
44
|
post = {}
|
45
45
|
add_invoice(post, amount, options)
|
46
46
|
add_reference(post, authorization)
|
@@ -49,7 +49,7 @@ module ActiveMerchant #:nodoc:
|
|
49
49
|
commit('capture', options, post)
|
50
50
|
end
|
51
51
|
|
52
|
-
def refund(amount, authorization, options={})
|
52
|
+
def refund(amount, authorization, options = {})
|
53
53
|
post = {}
|
54
54
|
add_invoice(post, amount, options)
|
55
55
|
add_reference(post, authorization)
|
@@ -58,14 +58,14 @@ module ActiveMerchant #:nodoc:
|
|
58
58
|
commit('refund', options, post)
|
59
59
|
end
|
60
60
|
|
61
|
-
def void(authorization, options={})
|
61
|
+
def void(authorization, options = {})
|
62
62
|
post = {}
|
63
63
|
add_reference(post, authorization)
|
64
64
|
|
65
65
|
commit('void', options, post)
|
66
66
|
end
|
67
67
|
|
68
|
-
def verify(credit_card, options={})
|
68
|
+
def verify(credit_card, options = {})
|
69
69
|
MultiResponse.run(:use_first_response) do |r|
|
70
70
|
r.process { authorize(100, credit_card, options) }
|
71
71
|
r.process(:ignore_result) { void(r.authorization, options) }
|
@@ -91,7 +91,7 @@ module ActiveMerchant #:nodoc:
|
|
91
91
|
end
|
92
92
|
|
93
93
|
def add_customer_data(post, options)
|
94
|
-
if(billing_address = (options[:billing_address] || options[:address]))
|
94
|
+
if (billing_address = (options[:billing_address] || options[:address]))
|
95
95
|
post[:ci_companyname] = billing_address[:company]
|
96
96
|
post[:ci_billaddr1] = billing_address[:address1]
|
97
97
|
post[:ci_billaddr2] = billing_address[:address2]
|
@@ -105,13 +105,13 @@ module ActiveMerchant #:nodoc:
|
|
105
105
|
post[:ci_ipaddress] = billing_address[:ip]
|
106
106
|
end
|
107
107
|
|
108
|
-
if(shipping_address = options[:shipping_address])
|
108
|
+
if (shipping_address = options[:shipping_address])
|
109
109
|
post[:ci_shipaddr1] = shipping_address[:address1]
|
110
110
|
post[:ci_shipaddr2] = shipping_address[:address2]
|
111
111
|
post[:ci_shipcity] = shipping_address[:city]
|
112
112
|
post[:ci_shipstate] = shipping_address[:state]
|
113
|
-
post[:ci_shipzip]
|
114
|
-
post[:ci_shipcountry]
|
113
|
+
post[:ci_shipzip] = shipping_address[:zip]
|
114
|
+
post[:ci_shipcountry] = shipping_address[:country]
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
@@ -139,7 +139,7 @@ module ActiveMerchant #:nodoc:
|
|
139
139
|
|
140
140
|
ACCOUNT_TYPES = {
|
141
141
|
'checking' => '1',
|
142
|
-
'savings' => '2'
|
142
|
+
'savings' => '2'
|
143
143
|
}
|
144
144
|
|
145
145
|
def add_check(post, payment_method)
|
@@ -178,7 +178,7 @@ module ActiveMerchant #:nodoc:
|
|
178
178
|
'refund' => 'ns_credit',
|
179
179
|
'authorize' => 'ns_quicksale_cc',
|
180
180
|
'capture' => 'ns_quicksale_cc',
|
181
|
-
'void' => 'ns_void'
|
181
|
+
'void' => 'ns_void'
|
182
182
|
}
|
183
183
|
|
184
184
|
def commit(action, options, post)
|
@@ -196,8 +196,8 @@ module ActiveMerchant #:nodoc:
|
|
196
196
|
succeeded,
|
197
197
|
message_from(succeeded, raw),
|
198
198
|
raw,
|
199
|
-
:
|
200
|
-
:
|
199
|
+
authorization: authorization_from(raw),
|
200
|
+
test: test?
|
201
201
|
)
|
202
202
|
end
|
203
203
|
|
@@ -14,10 +14,10 @@ module ActiveMerchant #:nodoc:
|
|
14
14
|
self.require_verification_value = false
|
15
15
|
self.require_name = false
|
16
16
|
|
17
|
-
attr_accessor :payment_cryptogram, :eci, :transaction_id
|
17
|
+
attr_accessor :payment_cryptogram, :eci, :transaction_id, :metadata
|
18
18
|
attr_writer :source
|
19
19
|
|
20
|
-
SOURCES = %i(apple_pay android_pay google_pay)
|
20
|
+
SOURCES = %i(apple_pay android_pay google_pay network_token)
|
21
21
|
|
22
22
|
def source
|
23
23
|
if defined?(@source) && SOURCES.include?(@source)
|
@@ -4,12 +4,16 @@ module ActiveMerchant #:nodoc:
|
|
4
4
|
end
|
5
5
|
|
6
6
|
class Response
|
7
|
-
attr_reader :params, :message, :test, :authorization, :avs_result, :cvv_result, :error_code, :emv_authorization
|
7
|
+
attr_reader :params, :message, :test, :authorization, :avs_result, :cvv_result, :error_code, :emv_authorization, :network_transaction_id
|
8
8
|
|
9
9
|
def success?
|
10
10
|
@success
|
11
11
|
end
|
12
12
|
|
13
|
+
def failure?
|
14
|
+
!success?
|
15
|
+
end
|
16
|
+
|
13
17
|
def test?
|
14
18
|
@test
|
15
19
|
end
|
@@ -25,18 +29,19 @@ module ActiveMerchant #:nodoc:
|
|
25
29
|
@fraud_review = options[:fraud_review]
|
26
30
|
@error_code = options[:error_code]
|
27
31
|
@emv_authorization = options[:emv_authorization]
|
32
|
+
@network_transaction_id = options[:network_transaction_id]
|
28
33
|
|
29
34
|
@avs_result = if options[:avs_result].kind_of?(AVSResult)
|
30
35
|
options[:avs_result].to_hash
|
31
36
|
else
|
32
37
|
AVSResult.new(options[:avs_result]).to_hash
|
33
|
-
|
38
|
+
end
|
34
39
|
|
35
40
|
@cvv_result = if options[:cvv_result].kind_of?(CVVResult)
|
36
41
|
options[:cvv_result].to_hash
|
37
42
|
else
|
38
43
|
CVVResult.new(options[:cvv_result]).to_hash
|
39
|
-
|
44
|
+
end
|
40
45
|
end
|
41
46
|
end
|
42
47
|
|
@@ -53,14 +58,14 @@ module ActiveMerchant #:nodoc:
|
|
53
58
|
@primary_response = nil
|
54
59
|
end
|
55
60
|
|
56
|
-
def process(ignore_result=false)
|
61
|
+
def process(ignore_result = false)
|
57
62
|
return unless success?
|
58
63
|
|
59
64
|
response = yield
|
60
65
|
self << response
|
61
66
|
|
62
67
|
unless ignore_result
|
63
|
-
if
|
68
|
+
if @use_first_response && response.success?
|
64
69
|
@primary_response ||= response
|
65
70
|
else
|
66
71
|
@primary_response = response
|
@@ -80,7 +85,21 @@ module ActiveMerchant #:nodoc:
|
|
80
85
|
(primary_response ? primary_response.success? : true)
|
81
86
|
end
|
82
87
|
|
83
|
-
|
88
|
+
def avs_result
|
89
|
+
return @primary_response.try(:avs_result) if @use_first_response
|
90
|
+
|
91
|
+
result = responses.reverse.find { |r| r.avs_result['code'].present? }
|
92
|
+
result.try(:avs_result) || responses.last.try(:avs_result)
|
93
|
+
end
|
94
|
+
|
95
|
+
def cvv_result
|
96
|
+
return @primary_response.try(:cvv_result) if @use_first_response
|
97
|
+
|
98
|
+
result = responses.reverse.find { |r| r.cvv_result['code'].present? }
|
99
|
+
result.try(:cvv_result) || responses.last.try(:cvv_result)
|
100
|
+
end
|
101
|
+
|
102
|
+
%w(params message test authorization error_code emv_authorization test? fraud_review?).each do |m|
|
84
103
|
class_eval %(
|
85
104
|
def #{m}
|
86
105
|
(@responses.empty? ? nil : primary_response.#{m})
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module ActiveMerchant
|
2
|
+
module Billing
|
3
|
+
module ThreeDSecureEciMapper
|
4
|
+
NON_THREE_D_SECURE_TRANSACTION = :non_three_d_secure_transaction
|
5
|
+
ATTEMPTED_AUTHENTICATION_TRANSACTION = :attempted_authentication_transaction
|
6
|
+
FULLY_AUTHENTICATED_TRANSACTION = :fully_authenticated_transaction
|
7
|
+
|
8
|
+
ECI_00_01_02_MAP = { '00' => NON_THREE_D_SECURE_TRANSACTION, '01' => ATTEMPTED_AUTHENTICATION_TRANSACTION, '02' => FULLY_AUTHENTICATED_TRANSACTION }.freeze
|
9
|
+
ECI_05_06_07_MAP = { '05' => FULLY_AUTHENTICATED_TRANSACTION, '06' => ATTEMPTED_AUTHENTICATION_TRANSACTION, '07' => NON_THREE_D_SECURE_TRANSACTION }.freeze
|
10
|
+
BRAND_TO_ECI_MAP = {
|
11
|
+
american_express: ECI_05_06_07_MAP,
|
12
|
+
dankort: ECI_05_06_07_MAP,
|
13
|
+
diners_club: ECI_05_06_07_MAP,
|
14
|
+
discover: ECI_05_06_07_MAP,
|
15
|
+
elo: ECI_05_06_07_MAP,
|
16
|
+
jcb: ECI_05_06_07_MAP,
|
17
|
+
maestro: ECI_00_01_02_MAP,
|
18
|
+
master: ECI_00_01_02_MAP,
|
19
|
+
visa: ECI_05_06_07_MAP
|
20
|
+
}.freeze
|
21
|
+
|
22
|
+
def self.map(brand, eci)
|
23
|
+
BRAND_TO_ECI_MAP.dig(brand, eci)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -62,6 +62,7 @@ module ActiveMerchant
|
|
62
62
|
|
63
63
|
def wiredump_device=(device)
|
64
64
|
raise ArgumentError, "can't wiredump to frozen #{device.class}" if device&.frozen?
|
65
|
+
|
65
66
|
@wiredump_device = device
|
66
67
|
end
|
67
68
|
|
@@ -71,20 +72,19 @@ module ActiveMerchant
|
|
71
72
|
headers = headers.dup
|
72
73
|
headers['connection'] ||= 'close'
|
73
74
|
|
74
|
-
retry_exceptions(:
|
75
|
-
|
76
|
-
info "connection_http_method=#{method.to_s.upcase} connection_uri=#{endpoint}", tag
|
75
|
+
retry_exceptions(max_retries: max_retries, logger: logger, tag: tag) do
|
76
|
+
info "connection_http_method=#{method.to_s.upcase} connection_uri=#{endpoint}", tag
|
77
77
|
|
78
|
-
|
78
|
+
result = nil
|
79
79
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
80
|
+
realtime = Benchmark.realtime do
|
81
|
+
http.start unless http.started?
|
82
|
+
@ssl_connection = http.ssl_connection
|
83
|
+
info "connection_ssl_version=#{ssl_connection[:version]} connection_ssl_cipher=#{ssl_connection[:cipher]}", tag
|
84
84
|
|
85
|
-
|
85
|
+
result =
|
86
|
+
case method
|
86
87
|
when :get
|
87
|
-
raise ArgumentError, 'GET requests do not support a request body' if body
|
88
88
|
http.get(endpoint.request_uri, headers)
|
89
89
|
when :post
|
90
90
|
debug body
|
@@ -110,12 +110,11 @@ module ActiveMerchant
|
|
110
110
|
else
|
111
111
|
raise ArgumentError, "Unsupported request method #{method.to_s.upcase}"
|
112
112
|
end
|
113
|
-
end
|
114
|
-
|
115
|
-
info '--> %d %s (%d %.4fs)' % [result.code, result.message, result.body ? result.body.length : 0, realtime], tag
|
116
|
-
debug result.body
|
117
|
-
result
|
118
113
|
end
|
114
|
+
|
115
|
+
info '--> %d %s (%d %.4fs)' % [result.code, result.message, result.body ? result.body.length : 0, realtime], tag
|
116
|
+
debug result.body
|
117
|
+
result
|
119
118
|
end
|
120
119
|
ensure
|
121
120
|
info 'connection_request_total_time=%.4fs' % [Process.clock_gettime(Process::CLOCK_MONOTONIC) - request_start], tag
|
@@ -39,7 +39,7 @@ module ActiveMerchant #:nodoc:
|
|
39
39
|
|
40
40
|
def initialize(options = {})
|
41
41
|
@name = options.delete(:name)
|
42
|
-
@codes = options.collect { |
|
42
|
+
@codes = options.collect { |_k, v| CountryCode.new(v) }
|
43
43
|
end
|
44
44
|
|
45
45
|
def code(format)
|
@@ -184,6 +184,7 @@ module ActiveMerchant #:nodoc:
|
|
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
186
|
{ alpha2: 'XK', name: 'Kosovo', alpha3: 'XKX', numeric: '900' },
|
187
|
+
{ alpha2: 'QZ', name: 'Kosovo', alpha3: 'XKX', numeric: '900' },
|
187
188
|
{ alpha2: 'KW', name: 'Kuwait', alpha3: 'KWT', numeric: '414' },
|
188
189
|
{ alpha2: 'KG', name: 'Kyrgyzstan', alpha3: 'KGZ', numeric: '417' },
|
189
190
|
{ alpha2: 'LA', name: 'Lao People\'s Democratic Republic', alpha3: 'LAO', numeric: '418' },
|
@@ -330,6 +331,7 @@ module ActiveMerchant #:nodoc:
|
|
330
331
|
country = COUNTRIES.detect { |c| c[:name].casecmp(name).zero? }
|
331
332
|
end
|
332
333
|
raise InvalidCountryCodeError, "No country could be found for the country #{name}" if country.nil?
|
334
|
+
|
333
335
|
Country.new(country.dup)
|
334
336
|
end
|
335
337
|
end
|
@@ -23,10 +23,13 @@ module ActiveMerchant #:nodoc:
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def to_s
|
26
|
-
"Failed with #{response.code} #{response.message if response.respond_to?(:message)}"
|
26
|
+
"Failed with #{response.code if response.respond_to?(:code)} #{response.message if response.respond_to?(:message)}"
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
+
class OAuthResponseError < ResponseError # :nodoc:
|
31
|
+
end
|
32
|
+
|
30
33
|
class ClientCertificateError < ActiveMerchantError # :nodoc
|
31
34
|
end
|
32
35
|
|
@@ -17,26 +17,24 @@ module ActiveMerchant
|
|
17
17
|
base.send(:attr_accessor, :retry_safe)
|
18
18
|
end
|
19
19
|
|
20
|
-
def retry_exceptions(options={})
|
20
|
+
def retry_exceptions(options = {})
|
21
21
|
connection_errors = DEFAULT_CONNECTION_ERRORS.merge(options[:connection_exceptions] || {})
|
22
22
|
|
23
23
|
retry_network_exceptions(options) do
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
raise ActiveMerchant::ConnectionError.new(derived_error_message(connection_errors, e.class), e)
|
35
|
-
end
|
24
|
+
yield
|
25
|
+
rescue Errno::ECONNREFUSED => e
|
26
|
+
raise ActiveMerchant::RetriableConnectionError.new('The remote server refused the connection', e)
|
27
|
+
rescue OpenSSL::X509::CertificateError => e
|
28
|
+
NetworkConnectionRetries.log(options[:logger], :error, e.message, options[:tag])
|
29
|
+
raise ActiveMerchant::ClientCertificateError, 'The remote server did not accept the provided SSL certificate'
|
30
|
+
rescue Zlib::BufError
|
31
|
+
raise ActiveMerchant::InvalidResponseError, 'The remote server replied with an invalid response'
|
32
|
+
rescue *connection_errors.keys => e
|
33
|
+
raise ActiveMerchant::ConnectionError.new(derived_error_message(connection_errors, e.class), e)
|
36
34
|
end
|
37
35
|
end
|
38
36
|
|
39
|
-
def self.log(logger, level, message, tag=nil)
|
37
|
+
def self.log(logger, level, message, tag = nil)
|
40
38
|
tag ||= self.class.to_s
|
41
39
|
message = "[#{tag}] #{message}"
|
42
40
|
logger&.send(level, message)
|
@@ -52,17 +50,17 @@ module ActiveMerchant
|
|
52
50
|
begin
|
53
51
|
request_start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
54
52
|
result = yield
|
55
|
-
log_with_retry_details(options[:logger], initial_retries-retries + 1, Process.clock_gettime(Process::CLOCK_MONOTONIC) - request_start, 'success', options[:tag])
|
53
|
+
log_with_retry_details(options[:logger], initial_retries - retries + 1, Process.clock_gettime(Process::CLOCK_MONOTONIC) - request_start, 'success', options[:tag])
|
56
54
|
result
|
57
55
|
rescue ActiveMerchant::RetriableConnectionError => e
|
58
56
|
retries -= 1
|
59
57
|
|
60
|
-
log_with_retry_details(options[:logger], initial_retries-retries, Process.clock_gettime(Process::CLOCK_MONOTONIC) - request_start, e.message, options[:tag])
|
58
|
+
log_with_retry_details(options[:logger], initial_retries - retries, Process.clock_gettime(Process::CLOCK_MONOTONIC) - request_start, e.message, options[:tag])
|
61
59
|
retry unless retries.zero?
|
62
60
|
raise ActiveMerchant::ConnectionError.new(e.message, e)
|
63
61
|
rescue ActiveMerchant::ConnectionError, ActiveMerchant::InvalidResponseError => e
|
64
62
|
retries -= 1
|
65
|
-
log_with_retry_details(options[:logger], initial_retries-retries, Process.clock_gettime(Process::CLOCK_MONOTONIC) - request_start, e.message, options[:tag])
|
63
|
+
log_with_retry_details(options[:logger], initial_retries - retries, Process.clock_gettime(Process::CLOCK_MONOTONIC) - request_start, e.message, options[:tag])
|
66
64
|
retry if (options[:retry_safe] || retry_safe) && !retries.zero?
|
67
65
|
raise
|
68
66
|
end
|
@@ -2,11 +2,12 @@ require 'cgi'
|
|
2
2
|
|
3
3
|
module ActiveMerchant
|
4
4
|
class PostData < Hash
|
5
|
-
class_attribute :required_fields, :
|
5
|
+
class_attribute :required_fields, instance_writer: false
|
6
6
|
self.required_fields = []
|
7
7
|
|
8
8
|
def []=(key, value)
|
9
9
|
return if value.blank? && !required?(key)
|
10
|
+
|
10
11
|
super
|
11
12
|
end
|
12
13
|
|
@@ -14,7 +15,7 @@ module ActiveMerchant
|
|
14
15
|
collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
|
15
16
|
end
|
16
17
|
|
17
|
-
|
18
|
+
alias to_s to_post_data
|
18
19
|
|
19
20
|
private
|
20
21
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module ActiveMerchant #:nodoc:
|
2
|
-
module PostsData
|
2
|
+
module PostsData #:nodoc:
|
3
3
|
def self.included(base)
|
4
4
|
base.class_attribute :ssl_strict
|
5
5
|
base.ssl_strict = true
|
@@ -32,7 +32,7 @@ module ActiveMerchant #:nodoc:
|
|
32
32
|
base.class_attribute :proxy_port
|
33
33
|
end
|
34
34
|
|
35
|
-
def ssl_get(endpoint, headers={})
|
35
|
+
def ssl_get(endpoint, headers = {})
|
36
36
|
ssl_request(:get, endpoint, nil, headers)
|
37
37
|
end
|
38
38
|
|