activemerchant 1.45.0 → 1.126.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG +2167 -2
- data/CONTRIBUTORS +57 -0
- data/README.md +62 -41
- data/lib/active_merchant/billing/avs_result.rb +25 -28
- data/lib/active_merchant/billing/base.rb +11 -35
- data/lib/active_merchant/billing/check.rb +28 -24
- data/lib/active_merchant/billing/compatibility.rb +10 -12
- data/lib/active_merchant/billing/credit_card.rb +141 -69
- data/lib/active_merchant/billing/credit_card_formatting.rb +4 -4
- data/lib/active_merchant/billing/credit_card_methods.rb +348 -52
- data/lib/active_merchant/billing/cvv_result.rb +0 -1
- data/lib/active_merchant/billing/gateway.rb +125 -61
- data/lib/active_merchant/billing/gateways/adyen.rb +633 -127
- data/lib/active_merchant/billing/gateways/airwallex.rb +341 -0
- data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +883 -195
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +31 -24
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +104 -103
- data/lib/active_merchant/billing/gateways/axcessms.rb +179 -0
- data/lib/active_merchant/billing/gateways/balanced.rb +72 -65
- data/lib/active_merchant/billing/gateways/bambora_apac.rb +222 -0
- data/lib/active_merchant/billing/gateways/bank_frick.rb +16 -16
- data/lib/active_merchant/billing/gateways/banwire.rb +24 -13
- data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +397 -0
- data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +7 -7
- data/lib/active_merchant/billing/gateways/be2bill.rb +7 -7
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +143 -62
- data/lib/active_merchant/billing/gateways/beanstream.rb +45 -13
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +13 -10
- data/lib/active_merchant/billing/gateways/blue_pay.rb +549 -506
- data/lib/active_merchant/billing/gateways/blue_snap.rb +623 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +82 -36
- data/lib/active_merchant/billing/gateways/borgun.rb +61 -40
- data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +21 -2
- data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +3 -3
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +592 -203
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +3 -4
- data/lib/active_merchant/billing/gateways/bridge_pay.rb +116 -61
- data/lib/active_merchant/billing/gateways/cams.rb +230 -0
- data/lib/active_merchant/billing/gateways/card_connect.rb +320 -0
- data/lib/active_merchant/billing/gateways/card_save.rb +7 -9
- data/lib/active_merchant/billing/gateways/card_stream.rb +248 -97
- data/lib/active_merchant/billing/gateways/cardknox.rb +327 -0
- data/lib/active_merchant/billing/gateways/cardprocess.rb +256 -0
- data/lib/active_merchant/billing/gateways/cashnet.rb +70 -26
- data/lib/active_merchant/billing/gateways/cc5.rb +14 -17
- data/lib/active_merchant/billing/gateways/cecabank.rb +73 -53
- data/lib/active_merchant/billing/gateways/cenpos.rb +328 -0
- data/lib/active_merchant/billing/gateways/checkout.rb +32 -33
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +340 -0
- data/lib/active_merchant/billing/gateways/citrus_pay.rb +21 -0
- data/lib/active_merchant/billing/gateways/clearhaus.rb +219 -0
- data/lib/active_merchant/billing/gateways/commercegate.rb +11 -12
- data/lib/active_merchant/billing/gateways/conekta.rb +55 -34
- data/lib/active_merchant/billing/gateways/creditcall.rb +272 -0
- data/lib/active_merchant/billing/gateways/credorax.rb +506 -0
- data/lib/active_merchant/billing/gateways/ct_payment.rb +269 -0
- data/lib/active_merchant/billing/gateways/culqi.rb +279 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +637 -221
- data/lib/active_merchant/billing/gateways/d_local.rb +303 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +57 -355
- data/lib/active_merchant/billing/gateways/decidir.rb +347 -0
- data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
- data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
- data/lib/active_merchant/billing/gateways/digitzs.rb +295 -0
- data/lib/active_merchant/billing/gateways/ebanx.rb +334 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +46 -50
- data/lib/active_merchant/billing/gateways/elavon.rb +377 -250
- data/lib/active_merchant/billing/gateways/element.rb +386 -0
- data/lib/active_merchant/billing/gateways/epay.rb +92 -71
- data/lib/active_merchant/billing/gateways/evo_ca.rb +13 -14
- data/lib/active_merchant/billing/gateways/eway.rb +85 -73
- data/lib/active_merchant/billing/gateways/eway_managed.rb +85 -87
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +134 -80
- data/lib/active_merchant/billing/gateways/exact.rb +37 -36
- data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +124 -74
- data/lib/active_merchant/billing/gateways/federated_canada.rb +11 -13
- data/lib/active_merchant/billing/gateways/finansbank.rb +4 -5
- data/lib/active_merchant/billing/gateways/first_giving.rb +23 -23
- data/lib/active_merchant/billing/gateways/first_pay.rb +45 -23
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +184 -87
- data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +505 -0
- data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
- data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
- data/lib/active_merchant/billing/gateways/forte.rb +286 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +31 -32
- data/lib/active_merchant/billing/gateways/global_collect.rb +507 -0
- data/lib/active_merchant/billing/gateways/global_transport.rb +25 -15
- data/lib/active_merchant/billing/gateways/hdfc.rb +55 -57
- data/lib/active_merchant/billing/gateways/hps.rb +252 -68
- data/lib/active_merchant/billing/gateways/iats_payments.rb +99 -38
- data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
- data/lib/active_merchant/billing/gateways/inspire.rb +48 -48
- data/lib/active_merchant/billing/gateways/instapay.rb +10 -14
- data/lib/active_merchant/billing/gateways/ipg.rb +415 -0
- data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
- data/lib/active_merchant/billing/gateways/iridium.rb +254 -244
- data/lib/active_merchant/billing/gateways/itransact.rb +14 -14
- data/lib/active_merchant/billing/gateways/iveri.rb +254 -0
- data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +200 -80
- data/lib/active_merchant/billing/gateways/jetpay_v2.rb +432 -0
- data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
- data/lib/active_merchant/billing/gateways/kushki.rb +277 -0
- data/lib/active_merchant/billing/gateways/latitude19.rb +412 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +95 -85
- data/lib/active_merchant/billing/gateways/litle.rb +371 -94
- data/lib/active_merchant/billing/gateways/mastercard.rb +293 -0
- data/lib/active_merchant/billing/gateways/maxipago.rb +146 -123
- data/lib/active_merchant/billing/gateways/mercado_pago.rb +331 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +47 -23
- data/lib/active_merchant/billing/gateways/merchant_one.rb +16 -20
- data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +54 -60
- data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +60 -44
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +76 -23
- data/lib/active_merchant/billing/gateways/mercury.rb +73 -54
- data/lib/active_merchant/billing/gateways/metrics_global.rb +33 -43
- data/lib/active_merchant/billing/gateways/micropayment.rb +182 -0
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +7 -7
- data/lib/active_merchant/billing/gateways/migs.rb +101 -37
- data/lib/active_merchant/billing/gateways/mit.rb +260 -0
- data/lib/active_merchant/billing/gateways/modern_payments.rb +3 -3
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +30 -34
- data/lib/active_merchant/billing/gateways/moka.rb +290 -0
- data/lib/active_merchant/billing/gateways/monei.rb +422 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +236 -72
- data/lib/active_merchant/billing/gateways/money_movers.rb +11 -13
- data/lib/active_merchant/billing/gateways/mundipagg.rb +363 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +87 -68
- data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +163 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +12 -12
- data/lib/active_merchant/billing/gateways/netaxept.rb +33 -34
- data/lib/active_merchant/billing/gateways/netbanx.rb +376 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +82 -43
- data/lib/active_merchant/billing/gateways/netpay.rb +10 -10
- data/lib/active_merchant/billing/gateways/network_merchants.rb +7 -11
- data/lib/active_merchant/billing/gateways/nmi.rb +279 -174
- data/lib/active_merchant/billing/gateways/ogone.rb +96 -50
- data/lib/active_merchant/billing/gateways/omise.rb +323 -0
- data/lib/active_merchant/billing/gateways/openpay.rb +58 -23
- data/lib/active_merchant/billing/gateways/opp.rb +394 -0
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +87 -69
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +5 -7
- data/lib/active_merchant/billing/gateways/orbital.rb +771 -328
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +31 -32
- data/lib/active_merchant/billing/gateways/pagarme.rb +239 -0
- data/lib/active_merchant/billing/gateways/pago_facil.rb +12 -14
- data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
- data/lib/active_merchant/billing/gateways/pay_conex.rb +245 -0
- data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +84 -68
- data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +37 -37
- data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +206 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +15 -17
- data/lib/active_merchant/billing/gateways/pay_trace.rb +404 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +85 -49
- data/lib/active_merchant/billing/gateways/payeezy.rb +458 -0
- data/lib/active_merchant/billing/gateways/payex.rb +39 -42
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +67 -41
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +11 -8
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +3 -3
- data/lib/active_merchant/billing/gateways/payflow.rb +215 -46
- data/lib/active_merchant/billing/gateways/payflow_express.rb +64 -68
- data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +2 -3
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +5 -6
- data/lib/active_merchant/billing/gateways/payment_express.rb +78 -58
- data/lib/active_merchant/billing/gateways/paymentez.rb +353 -0
- data/lib/active_merchant/billing/gateways/paymill.rb +163 -75
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +55 -7
- data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +1 -1
- data/lib/active_merchant/billing/gateways/paypal.rb +37 -18
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +2 -2
- data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +5 -5
- data/lib/active_merchant/billing/gateways/paypal_express.rb +12 -6
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +3 -3
- data/lib/active_merchant/billing/gateways/paysafe.rb +412 -0
- data/lib/active_merchant/billing/gateways/payscout.rb +10 -13
- data/lib/active_merchant/billing/gateways/paystation.rb +96 -91
- data/lib/active_merchant/billing/gateways/payu_in.rb +249 -0
- data/lib/active_merchant/billing/gateways/payu_latam.rb +479 -0
- data/lib/active_merchant/billing/gateways/payway.rb +27 -27
- data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
- data/lib/active_merchant/billing/gateways/pin.rb +113 -37
- data/lib/active_merchant/billing/gateways/plugnpay.rb +82 -82
- data/lib/active_merchant/billing/gateways/priority.rb +369 -0
- data/lib/active_merchant/billing/gateways/pro_pay.rb +325 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +55 -44
- data/lib/active_merchant/billing/gateways/psl_card.rb +32 -40
- data/lib/active_merchant/billing/gateways/qbms.rb +86 -76
- data/lib/active_merchant/billing/gateways/quantum.rb +21 -23
- data/lib/active_merchant/billing/gateways/quickbooks.rb +377 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +297 -0
- data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +10 -353
- data/lib/active_merchant/billing/gateways/qvalent.rb +305 -0
- data/lib/active_merchant/billing/gateways/rapyd.rb +258 -0
- data/lib/active_merchant/billing/gateways/realex.rb +154 -52
- data/lib/active_merchant/billing/gateways/redsys.rb +488 -161
- data/lib/active_merchant/billing/gateways/s5.rb +247 -0
- data/lib/active_merchant/billing/gateways/safe_charge.rb +298 -0
- data/lib/active_merchant/billing/gateways/sage.rb +404 -133
- data/lib/active_merchant/billing/gateways/sage_pay.rb +145 -109
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +13 -15
- data/lib/active_merchant/billing/gateways/secure_net.rb +62 -54
- data/lib/active_merchant/billing/gateways/secure_pay.rb +32 -42
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +36 -27
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +14 -16
- data/lib/active_merchant/billing/gateways/securion_pay.rb +265 -0
- data/lib/active_merchant/billing/gateways/simetrik.rb +362 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +52 -54
- data/lib/active_merchant/billing/gateways/smart_ps.rb +51 -60
- data/lib/active_merchant/billing/gateways/so_easy_pay.rb +29 -29
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +108 -43
- data/lib/active_merchant/billing/gateways/stripe.rb +536 -120
- data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +516 -0
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +19 -25
- data/lib/active_merchant/billing/gateways/telr.rb +273 -0
- data/lib/active_merchant/billing/gateways/tns.rb +16 -217
- data/lib/active_merchant/billing/gateways/trans_first.rb +148 -34
- data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +612 -0
- data/lib/active_merchant/billing/gateways/transact_pro.rb +222 -0
- data/lib/active_merchant/billing/gateways/transax.rb +6 -8
- data/lib/active_merchant/billing/gateways/transnational.rb +1 -2
- data/lib/active_merchant/billing/gateways/trexle.rb +221 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +162 -89
- data/lib/active_merchant/billing/gateways/usa_epay.rb +5 -6
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +332 -236
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +185 -72
- data/lib/active_merchant/billing/gateways/vanco.rb +294 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +52 -53
- data/lib/active_merchant/billing/gateways/viaklix.rb +19 -31
- data/lib/active_merchant/billing/gateways/visanet_peru.rb +250 -0
- data/lib/active_merchant/billing/gateways/vpos.rb +220 -0
- data/lib/active_merchant/billing/gateways/webpay.rb +9 -9
- data/lib/active_merchant/billing/gateways/wepay.rb +108 -62
- data/lib/active_merchant/billing/gateways/wirecard.rb +52 -43
- data/lib/active_merchant/billing/gateways/wompi.rb +193 -0
- data/lib/active_merchant/billing/gateways/world_net.rb +345 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +725 -121
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +208 -0
- data/lib/active_merchant/billing/gateways/worldpay_us.rb +79 -39
- data/lib/active_merchant/billing/gateways.rb +8 -11
- data/lib/active_merchant/billing/model.rb +2 -2
- data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
- data/lib/active_merchant/billing/payment_token.rb +1 -1
- data/lib/active_merchant/billing/rails.rb +1 -1
- data/lib/active_merchant/billing/response.rb +19 -13
- data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
- data/lib/active_merchant/billing.rb +3 -0
- data/lib/active_merchant/connection.rb +196 -0
- data/lib/active_merchant/country.rb +13 -8
- data/lib/active_merchant/errors.rb +6 -0
- data/lib/active_merchant/net_http_ssl_connection.rb +11 -0
- data/lib/active_merchant/network_connection_retries.rb +78 -0
- data/lib/active_merchant/post_data.rb +26 -0
- data/lib/active_merchant/posts_data.rb +92 -0
- data/lib/active_merchant/version.rb +1 -1
- data/lib/active_merchant.rb +14 -59
- data/lib/activemerchant.rb +1 -1
- data/lib/certs/cacert.pem +3214 -0
- data/lib/support/gateway_support.rb +8 -10
- data/lib/support/outbound_hosts.rb +13 -10
- data/lib/support/ssl_verify.rb +9 -14
- data/lib/support/ssl_version.rb +86 -0
- metadata +136 -94
- checksums.yaml.gz.sig +0 -1
- data/lib/active_merchant/billing/gateways/app55.rb +0 -176
- data/lib/active_merchant/billing/gateways/barclays_epdq.rb +0 -314
- data/lib/active_merchant/billing/gateways/certo_direct.rb +0 -278
- data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +0 -246
- data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +0 -13
- data/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +0 -29
- data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +0 -66
- data/lib/active_merchant/billing/gateways/moneris_us.rb +0 -291
- data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +0 -87
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +0 -114
- data/lib/active_merchant/billing/gateways/sage/sage_vault.rb +0 -149
- data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +0 -102
- data/lib/active_merchant/billing/gateways/vindicia.rb +0 -385
- data/lib/active_merchant/offsite_payments_shim.rb +0 -19
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -0
@@ -0,0 +1,196 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'net/http'
|
3
|
+
require 'net/https'
|
4
|
+
require 'benchmark'
|
5
|
+
|
6
|
+
module ActiveMerchant
|
7
|
+
class Connection
|
8
|
+
using NetHttpSslConnection
|
9
|
+
include NetworkConnectionRetries
|
10
|
+
|
11
|
+
MAX_RETRIES = 3
|
12
|
+
OPEN_TIMEOUT = 60
|
13
|
+
READ_TIMEOUT = 60
|
14
|
+
VERIFY_PEER = true
|
15
|
+
CA_FILE = File.expand_path('../certs/cacert.pem', File.dirname(__FILE__))
|
16
|
+
CA_PATH = nil
|
17
|
+
MIN_VERSION = :TLS1_1
|
18
|
+
RETRY_SAFE = false
|
19
|
+
RUBY_184_POST_HEADERS = { 'Content-Type' => 'application/x-www-form-urlencoded' }
|
20
|
+
|
21
|
+
attr_accessor :endpoint
|
22
|
+
attr_accessor :open_timeout
|
23
|
+
attr_accessor :read_timeout
|
24
|
+
attr_accessor :verify_peer
|
25
|
+
attr_accessor :ssl_version
|
26
|
+
if Net::HTTP.instance_methods.include?(:min_version=)
|
27
|
+
attr_accessor :min_version
|
28
|
+
attr_accessor :max_version
|
29
|
+
end
|
30
|
+
attr_reader :ssl_connection
|
31
|
+
attr_accessor :ca_file
|
32
|
+
attr_accessor :ca_path
|
33
|
+
attr_accessor :pem
|
34
|
+
attr_accessor :pem_password
|
35
|
+
attr_reader :wiredump_device
|
36
|
+
attr_accessor :logger
|
37
|
+
attr_accessor :tag
|
38
|
+
attr_accessor :ignore_http_status
|
39
|
+
attr_accessor :max_retries
|
40
|
+
attr_accessor :proxy_address
|
41
|
+
attr_accessor :proxy_port
|
42
|
+
|
43
|
+
def initialize(endpoint)
|
44
|
+
@endpoint = endpoint.is_a?(URI) ? endpoint : URI.parse(endpoint)
|
45
|
+
@open_timeout = OPEN_TIMEOUT
|
46
|
+
@read_timeout = READ_TIMEOUT
|
47
|
+
@retry_safe = RETRY_SAFE
|
48
|
+
@verify_peer = VERIFY_PEER
|
49
|
+
@ca_file = CA_FILE
|
50
|
+
@ca_path = CA_PATH
|
51
|
+
@max_retries = MAX_RETRIES
|
52
|
+
@ignore_http_status = false
|
53
|
+
@ssl_version = nil
|
54
|
+
if Net::HTTP.instance_methods.include?(:min_version=)
|
55
|
+
@min_version = MIN_VERSION
|
56
|
+
@max_version = nil
|
57
|
+
end
|
58
|
+
@ssl_connection = {}
|
59
|
+
@proxy_address = :ENV
|
60
|
+
@proxy_port = nil
|
61
|
+
end
|
62
|
+
|
63
|
+
def wiredump_device=(device)
|
64
|
+
raise ArgumentError, "can't wiredump to frozen #{device.class}" if device&.frozen?
|
65
|
+
|
66
|
+
@wiredump_device = device
|
67
|
+
end
|
68
|
+
|
69
|
+
def request(method, body, headers = {})
|
70
|
+
request_start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
71
|
+
|
72
|
+
headers = headers.dup
|
73
|
+
headers['connection'] ||= 'close'
|
74
|
+
|
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
|
+
|
78
|
+
result = nil
|
79
|
+
|
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
|
+
|
85
|
+
result =
|
86
|
+
case method
|
87
|
+
when :get
|
88
|
+
raise ArgumentError, 'GET requests do not support a request body' if body
|
89
|
+
|
90
|
+
http.get(endpoint.request_uri, headers)
|
91
|
+
when :post
|
92
|
+
debug body
|
93
|
+
http.post(endpoint.request_uri, body, RUBY_184_POST_HEADERS.merge(headers))
|
94
|
+
when :put
|
95
|
+
debug body
|
96
|
+
http.put(endpoint.request_uri, body, headers)
|
97
|
+
when :patch
|
98
|
+
debug body
|
99
|
+
http.patch(endpoint.request_uri, body, headers)
|
100
|
+
when :delete
|
101
|
+
# It's kind of ambiguous whether the RFC allows bodies
|
102
|
+
# for DELETE requests. But Net::HTTP's delete method
|
103
|
+
# very unambiguously does not.
|
104
|
+
if body
|
105
|
+
debug body
|
106
|
+
req = Net::HTTP::Delete.new(endpoint.request_uri, headers)
|
107
|
+
req.body = body
|
108
|
+
http.request(req)
|
109
|
+
else
|
110
|
+
http.delete(endpoint.request_uri, headers)
|
111
|
+
end
|
112
|
+
else
|
113
|
+
raise ArgumentError, "Unsupported request method #{method.to_s.upcase}"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
info '--> %d %s (%d %.4fs)' % [result.code, result.message, result.body ? result.body.length : 0, realtime], tag
|
118
|
+
debug result.body
|
119
|
+
result
|
120
|
+
end
|
121
|
+
ensure
|
122
|
+
info 'connection_request_total_time=%.4fs' % [Process.clock_gettime(Process::CLOCK_MONOTONIC) - request_start], tag
|
123
|
+
http.finish if http.started?
|
124
|
+
end
|
125
|
+
|
126
|
+
private
|
127
|
+
|
128
|
+
def http
|
129
|
+
@http ||= begin
|
130
|
+
http = Net::HTTP.new(endpoint.host, endpoint.port, proxy_address, proxy_port)
|
131
|
+
configure_debugging(http)
|
132
|
+
configure_timeouts(http)
|
133
|
+
configure_ssl(http)
|
134
|
+
configure_cert(http)
|
135
|
+
http
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def configure_debugging(http)
|
140
|
+
http.set_debug_output(wiredump_device)
|
141
|
+
end
|
142
|
+
|
143
|
+
def configure_timeouts(http)
|
144
|
+
http.open_timeout = open_timeout
|
145
|
+
http.read_timeout = read_timeout
|
146
|
+
end
|
147
|
+
|
148
|
+
def configure_ssl(http)
|
149
|
+
return unless endpoint.scheme == 'https'
|
150
|
+
|
151
|
+
http.use_ssl = true
|
152
|
+
http.ssl_version = ssl_version if ssl_version
|
153
|
+
if http.respond_to?(:min_version=)
|
154
|
+
http.min_version = min_version if min_version
|
155
|
+
http.max_version = max_version if max_version
|
156
|
+
end
|
157
|
+
|
158
|
+
if verify_peer
|
159
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
160
|
+
http.ca_file = ca_file
|
161
|
+
http.ca_path = ca_path
|
162
|
+
else
|
163
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
def configure_cert(http)
|
168
|
+
return if pem.blank?
|
169
|
+
|
170
|
+
http.cert = OpenSSL::X509::Certificate.new(pem)
|
171
|
+
|
172
|
+
if pem_password
|
173
|
+
http.key = OpenSSL::PKey::RSA.new(pem, pem_password)
|
174
|
+
else
|
175
|
+
http.key = OpenSSL::PKey::RSA.new(pem)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def debug(message, tag = nil)
|
180
|
+
log(:debug, message, tag)
|
181
|
+
end
|
182
|
+
|
183
|
+
def info(message, tag = nil)
|
184
|
+
log(:info, message, tag)
|
185
|
+
end
|
186
|
+
|
187
|
+
def error(message, tag = nil)
|
188
|
+
log(:error, message, tag)
|
189
|
+
end
|
190
|
+
|
191
|
+
def log(level, message, tag)
|
192
|
+
message = "[#{tag}] #{message}" if tag
|
193
|
+
logger&.send(level, message)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
@@ -39,11 +39,11 @@ 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)
|
46
|
-
@codes.detect{|c| c.format == format}
|
46
|
+
@codes.detect { |c| c.format == format }
|
47
47
|
end
|
48
48
|
|
49
49
|
def ==(other)
|
@@ -72,6 +72,7 @@ module ActiveMerchant #:nodoc:
|
|
72
72
|
{ alpha2: 'AD', name: 'Andorra', alpha3: 'AND', numeric: '020' },
|
73
73
|
{ alpha2: 'AO', name: 'Angola', alpha3: 'AGO', numeric: '024' },
|
74
74
|
{ alpha2: 'AI', name: 'Anguilla', alpha3: 'AIA', numeric: '660' },
|
75
|
+
{ alpha2: 'AQ', name: 'Antarctica', alpha3: 'ATA', numeric: '010' },
|
75
76
|
{ alpha2: 'AG', name: 'Antigua and Barbuda', alpha3: 'ATG', numeric: '028' },
|
76
77
|
{ alpha2: 'AR', name: 'Argentina', alpha3: 'ARG', numeric: '032' },
|
77
78
|
{ alpha2: 'AM', name: 'Armenia', alpha3: 'ARM', numeric: '051' },
|
@@ -90,6 +91,7 @@ module ActiveMerchant #:nodoc:
|
|
90
91
|
{ alpha2: 'BM', name: 'Bermuda', alpha3: 'BMU', numeric: '060' },
|
91
92
|
{ alpha2: 'BT', name: 'Bhutan', alpha3: 'BTN', numeric: '064' },
|
92
93
|
{ alpha2: 'BO', name: 'Bolivia', alpha3: 'BOL', numeric: '068' },
|
94
|
+
{ alpha2: 'BQ', name: 'Bonaire, Sint Eustatius and Saba', alpha3: 'BES', numeric: '535' },
|
93
95
|
{ alpha2: 'BA', name: 'Bosnia and Herzegovina', alpha3: 'BIH', numeric: '070' },
|
94
96
|
{ alpha2: 'BW', name: 'Botswana', alpha3: 'BWA', numeric: '072' },
|
95
97
|
{ alpha2: 'BV', name: 'Bouvet Island', alpha3: 'BVD', numeric: '074' },
|
@@ -181,7 +183,7 @@ module ActiveMerchant #:nodoc:
|
|
181
183
|
{ alpha2: 'KI', name: 'Kiribati', alpha3: 'KIR', numeric: '296' },
|
182
184
|
{ alpha2: 'KP', name: 'Korea, Democratic People\'s Republic of', alpha3: 'PRK', numeric: '408' },
|
183
185
|
{ alpha2: 'KR', name: 'Korea, Republic of', alpha3: 'KOR', numeric: '410' },
|
184
|
-
{ alpha2: '
|
186
|
+
{ alpha2: 'XK', name: 'Kosovo', alpha3: 'XKX', numeric: '900' },
|
185
187
|
{ alpha2: 'KW', name: 'Kuwait', alpha3: 'KWT', numeric: '414' },
|
186
188
|
{ alpha2: 'KG', name: 'Kyrgyzstan', alpha3: 'KGZ', numeric: '417' },
|
187
189
|
{ alpha2: 'LA', name: 'Lao People\'s Democratic Republic', alpha3: 'LAO', numeric: '418' },
|
@@ -220,7 +222,6 @@ module ActiveMerchant #:nodoc:
|
|
220
222
|
{ alpha2: 'NR', name: 'Nauru', alpha3: 'NRU', numeric: '520' },
|
221
223
|
{ alpha2: 'NP', name: 'Nepal', alpha3: 'NPL', numeric: '524' },
|
222
224
|
{ alpha2: 'NL', name: 'Netherlands', alpha3: 'NLD', numeric: '528' },
|
223
|
-
{ alpha2: 'AN', name: 'Netherlands Antilles', alpha3: 'ANT', numeric: '530' },
|
224
225
|
{ alpha2: 'NC', name: 'New Caledonia', alpha3: 'NCL', numeric: '540' },
|
225
226
|
{ alpha2: 'NZ', name: 'New Zealand', alpha3: 'NZL', numeric: '554' },
|
226
227
|
{ alpha2: 'NI', name: 'Nicaragua', alpha3: 'NIC', numeric: '558' },
|
@@ -245,6 +246,7 @@ module ActiveMerchant #:nodoc:
|
|
245
246
|
{ alpha2: 'PR', name: 'Puerto Rico', alpha3: 'PRI', numeric: '630' },
|
246
247
|
{ alpha2: 'QA', name: 'Qatar', alpha3: 'QAT', numeric: '634' },
|
247
248
|
{ alpha2: 'RE', name: 'Reunion', alpha3: 'REU', numeric: '638' },
|
249
|
+
{ alpha2: 'RO', name: 'Romania', alpha3: 'ROU', numeric: '642' },
|
248
250
|
{ alpha2: 'RO', name: 'Romania', alpha3: 'ROM', numeric: '642' },
|
249
251
|
{ alpha2: 'RU', name: 'Russian Federation', alpha3: 'RUS', numeric: '643' },
|
250
252
|
{ alpha2: 'RW', name: 'Rwanda', alpha3: 'RWA', numeric: '646' },
|
@@ -264,15 +266,17 @@ module ActiveMerchant #:nodoc:
|
|
264
266
|
{ alpha2: 'SC', name: 'Seychelles', alpha3: 'SYC', numeric: '690' },
|
265
267
|
{ alpha2: 'SL', name: 'Sierra Leone', alpha3: 'SLE', numeric: '694' },
|
266
268
|
{ alpha2: 'SG', name: 'Singapore', alpha3: 'SGP', numeric: '702' },
|
269
|
+
{ alpha2: 'SX', name: 'Sint Maarten', alpha3: 'SXM', numeric: '534' },
|
267
270
|
{ alpha2: 'SK', name: 'Slovakia', alpha3: 'SVK', numeric: '703' },
|
268
271
|
{ alpha2: 'SI', name: 'Slovenia', alpha3: 'SVN', numeric: '705' },
|
269
272
|
{ alpha2: 'SB', name: 'Solomon Islands', alpha3: 'SLB', numeric: '090' },
|
270
273
|
{ alpha2: 'SO', name: 'Somalia', alpha3: 'SOM', numeric: '706' },
|
271
274
|
{ alpha2: 'ZA', name: 'South Africa', alpha3: 'ZAF', numeric: '710' },
|
272
275
|
{ alpha2: 'GS', name: 'South Georgia and the South Sandwich Islands', alpha3: 'SGS', numeric: '239' },
|
276
|
+
{ alpha2: 'SS', name: 'South Sudan', alpha3: 'SSD', numeric: '728' },
|
273
277
|
{ alpha2: 'ES', name: 'Spain', alpha3: 'ESP', numeric: '724' },
|
274
278
|
{ alpha2: 'LK', name: 'Sri Lanka', alpha3: 'LKA', numeric: '144' },
|
275
|
-
{ alpha2: 'SD', name: 'Sudan', alpha3: 'SDN', numeric: '
|
279
|
+
{ alpha2: 'SD', name: 'Sudan', alpha3: 'SDN', numeric: '729' },
|
276
280
|
{ alpha2: 'SR', name: 'Suriname', alpha3: 'SUR', numeric: '740' },
|
277
281
|
{ alpha2: 'SJ', name: 'Svalbard and Jan Mayen', alpha3: 'SJM', numeric: '744' },
|
278
282
|
{ alpha2: 'SZ', name: 'Swaziland', alpha3: 'SWZ', numeric: '748' },
|
@@ -315,17 +319,18 @@ module ActiveMerchant #:nodoc:
|
|
315
319
|
]
|
316
320
|
|
317
321
|
def self.find(name)
|
318
|
-
raise InvalidCountryCodeError,
|
322
|
+
raise InvalidCountryCodeError, 'Cannot lookup country for an empty name' if name.blank?
|
319
323
|
|
320
324
|
case name.length
|
321
325
|
when 2, 3
|
322
326
|
upcase_name = name.upcase
|
323
327
|
country_code = CountryCode.new(name)
|
324
|
-
country = COUNTRIES.detect{|c| c[country_code.format] == upcase_name }
|
328
|
+
country = COUNTRIES.detect { |c| c[country_code.format] == upcase_name }
|
325
329
|
else
|
326
|
-
country = COUNTRIES.detect{|c| c[:name]
|
330
|
+
country = COUNTRIES.detect { |c| c[:name].casecmp(name).zero? }
|
327
331
|
end
|
328
332
|
raise InvalidCountryCodeError, "No country could be found for the country #{name}" if country.nil?
|
333
|
+
|
329
334
|
Country.new(country.dup)
|
330
335
|
end
|
331
336
|
end
|
@@ -3,6 +3,12 @@ module ActiveMerchant #:nodoc:
|
|
3
3
|
end
|
4
4
|
|
5
5
|
class ConnectionError < ActiveMerchantError # :nodoc:
|
6
|
+
attr_reader :triggering_exception
|
7
|
+
|
8
|
+
def initialize(message, triggering_exception)
|
9
|
+
super(message)
|
10
|
+
@triggering_exception = triggering_exception
|
11
|
+
end
|
6
12
|
end
|
7
13
|
|
8
14
|
class RetriableConnectionError < ConnectionError # :nodoc:
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'openssl'
|
2
|
+
|
3
|
+
module ActiveMerchant
|
4
|
+
module NetworkConnectionRetries
|
5
|
+
DEFAULT_RETRIES = 3
|
6
|
+
DEFAULT_CONNECTION_ERRORS = {
|
7
|
+
EOFError => 'The remote server dropped the connection',
|
8
|
+
Errno::ECONNRESET => 'The remote server reset the connection',
|
9
|
+
Timeout::Error => 'The connection to the remote server timed out',
|
10
|
+
Errno::ETIMEDOUT => 'The connection to the remote server timed out',
|
11
|
+
SocketError => 'The connection to the remote server could not be established',
|
12
|
+
Errno::EHOSTUNREACH => 'The connection to the remote server could not be established',
|
13
|
+
OpenSSL::SSL::SSLError => 'The SSL connection to the remote server could not be established'
|
14
|
+
}
|
15
|
+
|
16
|
+
def self.included(base)
|
17
|
+
base.send(:attr_accessor, :retry_safe)
|
18
|
+
end
|
19
|
+
|
20
|
+
def retry_exceptions(options = {})
|
21
|
+
connection_errors = DEFAULT_CONNECTION_ERRORS.merge(options[:connection_exceptions] || {})
|
22
|
+
|
23
|
+
retry_network_exceptions(options) do
|
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)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.log(logger, level, message, tag = nil)
|
38
|
+
tag ||= self.class.to_s
|
39
|
+
message = "[#{tag}] #{message}"
|
40
|
+
logger&.send(level, message)
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def retry_network_exceptions(options = {})
|
46
|
+
initial_retries = options[:max_retries] || DEFAULT_RETRIES
|
47
|
+
retries = initial_retries
|
48
|
+
request_start = nil
|
49
|
+
|
50
|
+
begin
|
51
|
+
request_start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
52
|
+
result = yield
|
53
|
+
log_with_retry_details(options[:logger], initial_retries - retries + 1, Process.clock_gettime(Process::CLOCK_MONOTONIC) - request_start, 'success', options[:tag])
|
54
|
+
result
|
55
|
+
rescue ActiveMerchant::RetriableConnectionError => e
|
56
|
+
retries -= 1
|
57
|
+
|
58
|
+
log_with_retry_details(options[:logger], initial_retries - retries, Process.clock_gettime(Process::CLOCK_MONOTONIC) - request_start, e.message, options[:tag])
|
59
|
+
retry unless retries.zero?
|
60
|
+
raise ActiveMerchant::ConnectionError.new(e.message, e)
|
61
|
+
rescue ActiveMerchant::ConnectionError, ActiveMerchant::InvalidResponseError => e
|
62
|
+
retries -= 1
|
63
|
+
log_with_retry_details(options[:logger], initial_retries - retries, Process.clock_gettime(Process::CLOCK_MONOTONIC) - request_start, e.message, options[:tag])
|
64
|
+
retry if (options[:retry_safe] || retry_safe) && !retries.zero?
|
65
|
+
raise
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def log_with_retry_details(logger, attempts, time, message, tag)
|
70
|
+
NetworkConnectionRetries.log(logger, :info, 'connection_attempt=%d connection_request_time=%.4fs connection_msg="%s"' % [attempts, time, message], tag)
|
71
|
+
end
|
72
|
+
|
73
|
+
def derived_error_message(errors, klass)
|
74
|
+
key = (errors.keys & klass.ancestors).first
|
75
|
+
key ? errors[key] : nil
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'cgi'
|
2
|
+
|
3
|
+
module ActiveMerchant
|
4
|
+
class PostData < Hash
|
5
|
+
class_attribute :required_fields, instance_writer: false
|
6
|
+
self.required_fields = []
|
7
|
+
|
8
|
+
def []=(key, value)
|
9
|
+
return if value.blank? && !required?(key)
|
10
|
+
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_post_data
|
15
|
+
collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
|
16
|
+
end
|
17
|
+
|
18
|
+
alias to_s to_post_data
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def required?(key)
|
23
|
+
required_fields.include?(key)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
module PostsData #:nodoc:
|
3
|
+
def self.included(base)
|
4
|
+
base.class_attribute :ssl_strict
|
5
|
+
base.ssl_strict = true
|
6
|
+
|
7
|
+
base.class_attribute :ssl_version
|
8
|
+
base.ssl_version = nil
|
9
|
+
|
10
|
+
base.class_attribute :min_version
|
11
|
+
base.min_version = Connection::MIN_VERSION
|
12
|
+
|
13
|
+
base.class_attribute :max_version
|
14
|
+
base.max_version = nil
|
15
|
+
|
16
|
+
base.class_attribute :retry_safe
|
17
|
+
base.retry_safe = false
|
18
|
+
|
19
|
+
base.class_attribute :open_timeout
|
20
|
+
base.open_timeout = Connection::OPEN_TIMEOUT
|
21
|
+
|
22
|
+
base.class_attribute :read_timeout
|
23
|
+
base.read_timeout = Connection::READ_TIMEOUT
|
24
|
+
|
25
|
+
base.class_attribute :max_retries
|
26
|
+
base.max_retries = Connection::MAX_RETRIES
|
27
|
+
|
28
|
+
base.class_attribute :logger
|
29
|
+
base.class_attribute :wiredump_device
|
30
|
+
|
31
|
+
base.class_attribute :proxy_address
|
32
|
+
base.class_attribute :proxy_port
|
33
|
+
end
|
34
|
+
|
35
|
+
def ssl_get(endpoint, headers = {})
|
36
|
+
ssl_request(:get, endpoint, nil, headers)
|
37
|
+
end
|
38
|
+
|
39
|
+
def ssl_post(endpoint, data, headers = {})
|
40
|
+
ssl_request(:post, endpoint, data, headers)
|
41
|
+
end
|
42
|
+
|
43
|
+
def ssl_request(method, endpoint, data, headers)
|
44
|
+
handle_response(raw_ssl_request(method, endpoint, data, headers))
|
45
|
+
end
|
46
|
+
|
47
|
+
def raw_ssl_request(method, endpoint, data, headers = {})
|
48
|
+
logger&.warn "#{self.class} using ssl_strict=false, which is insecure" unless ssl_strict
|
49
|
+
logger&.warn "#{self.class} posting to plaintext endpoint, which is insecure" unless endpoint.to_s =~ /^https:/
|
50
|
+
|
51
|
+
connection = new_connection(endpoint)
|
52
|
+
connection.open_timeout = open_timeout
|
53
|
+
connection.read_timeout = read_timeout
|
54
|
+
connection.retry_safe = retry_safe
|
55
|
+
connection.verify_peer = ssl_strict
|
56
|
+
connection.ssl_version = ssl_version
|
57
|
+
connection.logger = logger
|
58
|
+
connection.max_retries = max_retries
|
59
|
+
connection.tag = self.class.name
|
60
|
+
connection.wiredump_device = wiredump_device
|
61
|
+
if connection.respond_to?(:min_version=)
|
62
|
+
connection.min_version = min_version
|
63
|
+
connection.max_version = max_version
|
64
|
+
end
|
65
|
+
|
66
|
+
connection.pem = @options[:pem] if @options
|
67
|
+
connection.pem_password = @options[:pem_password] if @options
|
68
|
+
|
69
|
+
connection.ignore_http_status = @options[:ignore_http_status] if @options
|
70
|
+
|
71
|
+
connection.proxy_address = proxy_address
|
72
|
+
connection.proxy_port = proxy_port
|
73
|
+
|
74
|
+
connection.request(method, data, headers)
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def new_connection(endpoint)
|
80
|
+
Connection.new(endpoint)
|
81
|
+
end
|
82
|
+
|
83
|
+
def handle_response(response)
|
84
|
+
case response.code.to_i
|
85
|
+
when 200...300
|
86
|
+
response.body
|
87
|
+
else
|
88
|
+
raise ResponseError.new(response)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
data/lib/active_merchant.rb
CHANGED
@@ -27,82 +27,37 @@ require 'active_support/core_ext/hash/indifferent_access'
|
|
27
27
|
require 'active_support/core_ext/hash/conversions'
|
28
28
|
require 'active_support/core_ext/object/conversions'
|
29
29
|
require 'active_support/core_ext/class/attribute'
|
30
|
-
require 'active_support/core_ext/enumerable
|
31
|
-
|
32
|
-
if(!defined?(ActiveSupport::VERSION) || (ActiveSupport::VERSION::STRING < "4.1"))
|
33
|
-
require 'active_support/core_ext/class/attribute_accessors'
|
34
|
-
end
|
35
|
-
|
36
|
-
require 'active_support/core_ext/class/delegating_attributes'
|
30
|
+
require 'active_support/core_ext/enumerable'
|
37
31
|
require 'active_support/core_ext/module/attribute_accessors'
|
38
32
|
|
39
|
-
|
40
|
-
require 'active_support/base64'
|
41
|
-
|
42
|
-
unless defined?(Base64)
|
43
|
-
Base64 = ActiveSupport::Base64
|
44
|
-
end
|
45
|
-
|
46
|
-
unless Base64.respond_to?(:strict_encode64)
|
47
|
-
def Base64.strict_encode64(v)
|
48
|
-
ActiveSupport::Base64.encode64s(v)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
rescue LoadError
|
52
|
-
require 'base64'
|
53
|
-
end
|
54
|
-
|
33
|
+
require 'base64'
|
55
34
|
require 'securerandom'
|
56
35
|
require 'builder'
|
57
36
|
require 'cgi'
|
58
37
|
require 'rexml/document'
|
59
38
|
require 'timeout'
|
60
39
|
require 'socket'
|
40
|
+
require 'openssl'
|
61
41
|
|
62
|
-
require '
|
63
|
-
|
64
|
-
require '
|
65
|
-
require '
|
42
|
+
require 'active_merchant/network_connection_retries'
|
43
|
+
require 'active_merchant/net_http_ssl_connection'
|
44
|
+
require 'active_merchant/connection'
|
45
|
+
require 'active_merchant/post_data'
|
46
|
+
require 'active_merchant/posts_data'
|
66
47
|
|
67
48
|
require 'active_merchant/billing'
|
68
49
|
require 'active_merchant/version'
|
69
50
|
require 'active_merchant/country'
|
70
51
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
module Billing #:nodoc:
|
77
|
-
def self.const_missing(name)
|
78
|
-
if name.to_s == "Integrations"
|
79
|
-
ActiveMerchant.deprecated(OFFSITE_PAYMENT_EXTRACTION_MESSAGE)
|
80
|
-
require "active_merchant/offsite_payments_shim"
|
81
|
-
ActiveMerchant::OffsitePaymentsShim
|
82
|
-
else
|
83
|
-
super
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def self.included(klass)
|
88
|
-
def klass.const_missing(name)
|
89
|
-
if name.to_s == "Integrations"
|
90
|
-
ActiveMerchant.deprecated(OFFSITE_PAYMENT_EXTRACTION_MESSAGE)
|
91
|
-
require "active_merchant/offsite_payments_shim"
|
92
|
-
ActiveMerchant::OffsitePaymentsShim
|
93
|
-
else
|
94
|
-
super
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
def self.deprecated(message, caller=Kernel.caller[1])
|
101
|
-
warning = caller + ": " + message
|
102
|
-
if(respond_to?(:logger) && logger.present?)
|
52
|
+
module ActiveMerchant
|
53
|
+
def self.deprecated(message, caller = Kernel.caller[1])
|
54
|
+
warning = caller + ': ' + message
|
55
|
+
if respond_to?(:logger) && logger.present?
|
103
56
|
logger.warn(warning)
|
104
57
|
else
|
105
58
|
warn(warning)
|
106
59
|
end
|
107
60
|
end
|
108
61
|
end
|
62
|
+
|
63
|
+
I18n.enforce_available_locales = false
|
data/lib/activemerchant.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
require 'active_merchant'
|
1
|
+
require 'active_merchant'
|