swiss-crm-activemerchant 1.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG +4033 -0
- data/CONTRIBUTORS +568 -0
- data/MIT-LICENSE +20 -0
- data/README.md +252 -0
- data/lib/active_merchant/billing/apple_pay_payment_token.rb +22 -0
- data/lib/active_merchant/billing/avs_result.rb +95 -0
- data/lib/active_merchant/billing/base.rb +48 -0
- data/lib/active_merchant/billing/check.rb +112 -0
- data/lib/active_merchant/billing/compatibility.rb +118 -0
- data/lib/active_merchant/billing/credit_card.rb +451 -0
- data/lib/active_merchant/billing/credit_card_formatting.rb +24 -0
- data/lib/active_merchant/billing/credit_card_methods.rb +512 -0
- data/lib/active_merchant/billing/cvv_result.rb +37 -0
- data/lib/active_merchant/billing/gateway.rb +332 -0
- data/lib/active_merchant/billing/gateways/adyen.rb +774 -0
- 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 +205 -0
- data/lib/active_merchant/billing/gateways/authorize_net.rb +1125 -0
- data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +424 -0
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +977 -0
- data/lib/active_merchant/billing/gateways/axcessms.rb +242 -0
- data/lib/active_merchant/billing/gateways/balanced.rb +263 -0
- data/lib/active_merchant/billing/gateways/bambora_apac.rb +222 -0
- data/lib/active_merchant/billing/gateways/bank_frick.rb +225 -0
- data/lib/active_merchant/billing/gateways/banwire.rb +116 -0
- data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +397 -0
- data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +15 -0
- data/lib/active_merchant/billing/gateways/be2bill.rb +131 -0
- data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +474 -0
- data/lib/active_merchant/billing/gateways/beanstream.rb +238 -0
- data/lib/active_merchant/billing/gateways/beanstream_interac.rb +57 -0
- data/lib/active_merchant/billing/gateways/blue_pay.rb +549 -0
- data/lib/active_merchant/billing/gateways/blue_snap.rb +644 -0
- data/lib/active_merchant/billing/gateways/bogus.rb +190 -0
- data/lib/active_merchant/billing/gateways/borgun.rb +272 -0
- data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
- data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +28 -0
- data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +19 -0
- data/lib/active_merchant/billing/gateways/braintree_blue.rb +952 -0
- data/lib/active_merchant/billing/gateways/braintree_orange.rb +19 -0
- data/lib/active_merchant/billing/gateways/bridge_pay.rb +244 -0
- data/lib/active_merchant/billing/gateways/cams.rb +230 -0
- data/lib/active_merchant/billing/gateways/card_connect.rb +338 -0
- data/lib/active_merchant/billing/gateways/card_save.rb +21 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +394 -0
- 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 +235 -0
- data/lib/active_merchant/billing/gateways/cc5.rb +198 -0
- data/lib/active_merchant/billing/gateways/cecabank.rb +249 -0
- data/lib/active_merchant/billing/gateways/cenpos.rb +328 -0
- data/lib/active_merchant/billing/gateways/checkout.rb +212 -0
- data/lib/active_merchant/billing/gateways/checkout_v2.rb +587 -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/commerce_hub.rb +366 -0
- data/lib/active_merchant/billing/gateways/commercegate.rb +142 -0
- data/lib/active_merchant/billing/gateways/conekta.rb +230 -0
- data/lib/active_merchant/billing/gateways/creditcall.rb +272 -0
- data/lib/active_merchant/billing/gateways/credorax.rb +526 -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/cyber_source_common.rb +36 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +1148 -0
- data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +454 -0
- data/lib/active_merchant/billing/gateways/d_local.rb +343 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +302 -0
- data/lib/active_merchant/billing/gateways/decidir.rb +358 -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 +346 -0
- data/lib/active_merchant/billing/gateways/efsnet.rb +215 -0
- data/lib/active_merchant/billing/gateways/elavon.rb +475 -0
- data/lib/active_merchant/billing/gateways/element.rb +406 -0
- data/lib/active_merchant/billing/gateways/epay.rb +296 -0
- data/lib/active_merchant/billing/gateways/evo_ca.rb +307 -0
- data/lib/active_merchant/billing/gateways/eway.rb +226 -0
- data/lib/active_merchant/billing/gateways/eway_managed.rb +289 -0
- data/lib/active_merchant/billing/gateways/eway_rapid.rb +578 -0
- data/lib/active_merchant/billing/gateways/exact.rb +219 -0
- data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
- data/lib/active_merchant/billing/gateways/fat_zebra.rb +223 -0
- data/lib/active_merchant/billing/gateways/federated_canada.rb +158 -0
- data/lib/active_merchant/billing/gateways/finansbank.rb +22 -0
- data/lib/active_merchant/billing/gateways/first_giving.rb +143 -0
- data/lib/active_merchant/billing/gateways/first_pay.rb +182 -0
- data/lib/active_merchant/billing/gateways/firstdata_e4.rb +452 -0
- 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/fluidpay.rb +275 -0
- data/lib/active_merchant/billing/gateways/forte.rb +286 -0
- data/lib/active_merchant/billing/gateways/garanti.rb +256 -0
- data/lib/active_merchant/billing/gateways/global_collect.rb +580 -0
- data/lib/active_merchant/billing/gateways/global_transport.rb +193 -0
- data/lib/active_merchant/billing/gateways/hdfc.rb +205 -0
- data/lib/active_merchant/billing/gateways/hps.rb +472 -0
- data/lib/active_merchant/billing/gateways/iats_payments.rb +312 -0
- data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
- data/lib/active_merchant/billing/gateways/inspire.rb +213 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +159 -0
- data/lib/active_merchant/billing/gateways/ipg.rb +420 -0
- data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
- data/lib/active_merchant/billing/gateways/iridium.rb +467 -0
- data/lib/active_merchant/billing/gateways/itransact.rb +448 -0
- data/lib/active_merchant/billing/gateways/iveri.rb +290 -0
- data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +395 -0
- data/lib/active_merchant/billing/gateways/jetpay_v2.rb +432 -0
- data/lib/active_merchant/billing/gateways/klarna.rb +317 -0
- data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
- data/lib/active_merchant/billing/gateways/kushki.rb +297 -0
- data/lib/active_merchant/billing/gateways/latitude19.rb +412 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +448 -0
- data/lib/active_merchant/billing/gateways/litle.rb +643 -0
- data/lib/active_merchant/billing/gateways/mastercard.rb +286 -0
- data/lib/active_merchant/billing/gateways/maxipago.rb +220 -0
- data/lib/active_merchant/billing/gateways/mercado_pago.rb +348 -0
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +228 -0
- data/lib/active_merchant/billing/gateways/merchant_one.rb +110 -0
- data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +313 -0
- data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +284 -0
- data/lib/active_merchant/billing/gateways/merchant_warrior.rb +248 -0
- data/lib/active_merchant/billing/gateways/mercury.rb +352 -0
- data/lib/active_merchant/billing/gateways/metrics_global.rb +293 -0
- data/lib/active_merchant/billing/gateways/micropayment.rb +182 -0
- data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +100 -0
- data/lib/active_merchant/billing/gateways/migs.rb +329 -0
- data/lib/active_merchant/billing/gateways/mit.rb +260 -0
- data/lib/active_merchant/billing/gateways/modern_payments.rb +37 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +215 -0
- data/lib/active_merchant/billing/gateways/moka.rb +290 -0
- data/lib/active_merchant/billing/gateways/monei.rb +424 -0
- data/lib/active_merchant/billing/gateways/moneris.rb +488 -0
- data/lib/active_merchant/billing/gateways/money_movers.rb +150 -0
- data/lib/active_merchant/billing/gateways/mundipagg.rb +366 -0
- data/lib/active_merchant/billing/gateways/nab_transact.rb +299 -0
- data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +163 -0
- data/lib/active_merchant/billing/gateways/net_registry.rb +198 -0
- data/lib/active_merchant/billing/gateways/netaxept.rb +180 -0
- data/lib/active_merchant/billing/gateways/netbanx.rb +376 -0
- data/lib/active_merchant/billing/gateways/netbilling.rb +229 -0
- data/lib/active_merchant/billing/gateways/netpay.rb +223 -0
- data/lib/active_merchant/billing/gateways/network_merchants.rb +238 -0
- data/lib/active_merchant/billing/gateways/nmi.rb +396 -0
- data/lib/active_merchant/billing/gateways/ogone.rb +509 -0
- data/lib/active_merchant/billing/gateways/omise.rb +323 -0
- data/lib/active_merchant/billing/gateways/openpay.rb +246 -0
- data/lib/active_merchant/billing/gateways/opp.rb +394 -0
- data/lib/active_merchant/billing/gateways/optimal_payment.rb +331 -0
- data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +45 -0
- data/lib/active_merchant/billing/gateways/orbital.rb +1267 -0
- data/lib/active_merchant/billing/gateways/pac_net_raven.rb +206 -0
- data/lib/active_merchant/billing/gateways/pagarme.rb +239 -0
- data/lib/active_merchant/billing/gateways/pago_facil.rb +120 -0
- 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 +277 -0
- data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +390 -0
- data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +206 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +110 -0
- data/lib/active_merchant/billing/gateways/pay_trace.rb +450 -0
- data/lib/active_merchant/billing/gateways/paybox_direct.rb +224 -0
- data/lib/active_merchant/billing/gateways/payeezy.rb +513 -0
- data/lib/active_merchant/billing/gateways/payex.rb +409 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +235 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +42 -0
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +13 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +473 -0
- data/lib/active_merchant/billing/gateways/payflow_express.rb +220 -0
- data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +14 -0
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +20 -0
- data/lib/active_merchant/billing/gateways/payment_express.rb +373 -0
- data/lib/active_merchant/billing/gateways/paymentez.rb +365 -0
- data/lib/active_merchant/billing/gateways/paymill.rb +369 -0
- data/lib/active_merchant/billing/gateways/paynetworx.rb +228 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +718 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +69 -0
- data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +262 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +136 -0
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +13 -0
- data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +44 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +272 -0
- data/lib/active_merchant/billing/gateways/paypal_express_common.rb +30 -0
- data/lib/active_merchant/billing/gateways/paypal_standard.rb +281 -0
- data/lib/active_merchant/billing/gateways/paysafe.rb +420 -0
- data/lib/active_merchant/billing/gateways/payscout.rb +159 -0
- data/lib/active_merchant/billing/gateways/paystation.rb +204 -0
- data/lib/active_merchant/billing/gateways/payu_in.rb +249 -0
- data/lib/active_merchant/billing/gateways/payu_latam.rb +482 -0
- data/lib/active_merchant/billing/gateways/payway.rb +207 -0
- data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
- data/lib/active_merchant/billing/gateways/pin.rb +273 -0
- data/lib/active_merchant/billing/gateways/pixxels.rb +263 -0
- data/lib/active_merchant/billing/gateways/plexo.rb +308 -0
- data/lib/active_merchant/billing/gateways/plugnpay.rb +283 -0
- data/lib/active_merchant/billing/gateways/priority.rb +392 -0
- data/lib/active_merchant/billing/gateways/pro_pay.rb +325 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +227 -0
- data/lib/active_merchant/billing/gateways/psl_card.rb +295 -0
- data/lib/active_merchant/billing/gateways/qbms.rb +302 -0
- data/lib/active_merchant/billing/gateways/quantum.rb +274 -0
- 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 +24 -0
- data/lib/active_merchant/billing/gateways/qvalent.rb +305 -0
- 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 +400 -0
- data/lib/active_merchant/billing/gateways/redsys.rb +723 -0
- 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 +446 -0
- data/lib/active_merchant/billing/gateways/sage_pay.rb +434 -0
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +141 -0
- data/lib/active_merchant/billing/gateways/secure_net.rb +260 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +191 -0
- data/lib/active_merchant/billing/gateways/secure_pay_au.rb +290 -0
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +103 -0
- data/lib/active_merchant/billing/gateways/securion_pay.rb +305 -0
- 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 +450 -0
- data/lib/active_merchant/billing/gateways/smart_ps.rb +274 -0
- data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
- data/lib/active_merchant/billing/gateways/spreedly_core.rb +354 -0
- data/lib/active_merchant/billing/gateways/stripe.rb +866 -0
- data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +602 -0
- data/lib/active_merchant/billing/gateways/swipe_checkout.rb +151 -0
- data/lib/active_merchant/billing/gateways/telr.rb +273 -0
- data/lib/active_merchant/billing/gateways/tns.rb +23 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +240 -0
- 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 +21 -0
- data/lib/active_merchant/billing/gateways/transnational.rb +9 -0
- data/lib/active_merchant/billing/gateways/trexle.rb +221 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +500 -0
- data/lib/active_merchant/billing/gateways/usa_epay.rb +24 -0
- data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +1612 -0
- data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +367 -0
- data/lib/active_merchant/billing/gateways/vanco.rb +303 -0
- data/lib/active_merchant/billing/gateways/verifi.rb +224 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +171 -0
- data/lib/active_merchant/billing/gateways/visanet_peru.rb +250 -0
- data/lib/active_merchant/billing/gateways/vpos.rb +223 -0
- data/lib/active_merchant/billing/gateways/webpay.rb +97 -0
- data/lib/active_merchant/billing/gateways/wepay.rb +235 -0
- data/lib/active_merchant/billing/gateways/wirecard.rb +430 -0
- data/lib/active_merchant/billing/gateways/wompi.rb +197 -0
- data/lib/active_merchant/billing/gateways/world_net.rb +345 -0
- data/lib/active_merchant/billing/gateways/worldpay.rb +1050 -0
- data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +208 -0
- data/lib/active_merchant/billing/gateways/worldpay_us.rb +221 -0
- data/lib/active_merchant/billing/gateways.rb +14 -0
- data/lib/active_merchant/billing/model.rb +30 -0
- data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
- data/lib/active_merchant/billing/payment_token.rb +21 -0
- data/lib/active_merchant/billing/rails.rb +3 -0
- data/lib/active_merchant/billing/response.rb +121 -0
- data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
- data/lib/active_merchant/billing.rb +16 -0
- data/lib/active_merchant/connection.rb +194 -0
- data/lib/active_merchant/country.rb +338 -0
- data/lib/active_merchant/empty.rb +20 -0
- data/lib/active_merchant/errors.rb +38 -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 +3 -0
- data/lib/active_merchant.rb +63 -0
- data/lib/activemerchant.rb +1 -0
- data/lib/certs/cacert.pem +3214 -0
- data/lib/support/gateway_support.rb +69 -0
- data/lib/support/outbound_hosts.rb +28 -0
- data/lib/support/ssl_verify.rb +88 -0
- data/lib/support/ssl_version.rb +86 -0
- metadata +506 -0
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'active_merchant/errors'
|
2
|
+
|
3
|
+
require 'active_merchant/billing/avs_result'
|
4
|
+
require 'active_merchant/billing/cvv_result'
|
5
|
+
require 'active_merchant/billing/credit_card_methods'
|
6
|
+
require 'active_merchant/billing/credit_card_formatting'
|
7
|
+
require 'active_merchant/billing/credit_card'
|
8
|
+
require 'active_merchant/billing/network_tokenization_credit_card'
|
9
|
+
require 'active_merchant/billing/base'
|
10
|
+
require 'active_merchant/billing/check'
|
11
|
+
require 'active_merchant/billing/payment_token'
|
12
|
+
require 'active_merchant/billing/apple_pay_payment_token'
|
13
|
+
require 'active_merchant/billing/response'
|
14
|
+
require 'active_merchant/billing/gateways'
|
15
|
+
require 'active_merchant/billing/gateway'
|
16
|
+
require 'active_merchant/billing/three_d_secure_eci_mapper'
|
@@ -0,0 +1,194 @@
|
|
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
|
+
http.get(endpoint.request_uri, headers)
|
89
|
+
when :post
|
90
|
+
debug body
|
91
|
+
http.post(endpoint.request_uri, body, RUBY_184_POST_HEADERS.merge(headers))
|
92
|
+
when :put
|
93
|
+
debug body
|
94
|
+
http.put(endpoint.request_uri, body, headers)
|
95
|
+
when :patch
|
96
|
+
debug body
|
97
|
+
http.patch(endpoint.request_uri, body, headers)
|
98
|
+
when :delete
|
99
|
+
# It's kind of ambiguous whether the RFC allows bodies
|
100
|
+
# for DELETE requests. But Net::HTTP's delete method
|
101
|
+
# very unambiguously does not.
|
102
|
+
if body
|
103
|
+
debug body
|
104
|
+
req = Net::HTTP::Delete.new(endpoint.request_uri, headers)
|
105
|
+
req.body = body
|
106
|
+
http.request(req)
|
107
|
+
else
|
108
|
+
http.delete(endpoint.request_uri, headers)
|
109
|
+
end
|
110
|
+
else
|
111
|
+
raise ArgumentError, "Unsupported request method #{method.to_s.upcase}"
|
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
|
+
end
|
119
|
+
ensure
|
120
|
+
info 'connection_request_total_time=%.4fs' % [Process.clock_gettime(Process::CLOCK_MONOTONIC) - request_start], tag
|
121
|
+
http.finish if http.started?
|
122
|
+
end
|
123
|
+
|
124
|
+
private
|
125
|
+
|
126
|
+
def http
|
127
|
+
@http ||= begin
|
128
|
+
http = Net::HTTP.new(endpoint.host, endpoint.port, proxy_address, proxy_port)
|
129
|
+
configure_debugging(http)
|
130
|
+
configure_timeouts(http)
|
131
|
+
configure_ssl(http)
|
132
|
+
configure_cert(http)
|
133
|
+
http
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
def configure_debugging(http)
|
138
|
+
http.set_debug_output(wiredump_device)
|
139
|
+
end
|
140
|
+
|
141
|
+
def configure_timeouts(http)
|
142
|
+
http.open_timeout = open_timeout
|
143
|
+
http.read_timeout = read_timeout
|
144
|
+
end
|
145
|
+
|
146
|
+
def configure_ssl(http)
|
147
|
+
return unless endpoint.scheme == 'https'
|
148
|
+
|
149
|
+
http.use_ssl = true
|
150
|
+
http.ssl_version = ssl_version if ssl_version
|
151
|
+
if http.respond_to?(:min_version=)
|
152
|
+
http.min_version = min_version if min_version
|
153
|
+
http.max_version = max_version if max_version
|
154
|
+
end
|
155
|
+
|
156
|
+
if verify_peer
|
157
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
158
|
+
http.ca_file = ca_file
|
159
|
+
http.ca_path = ca_path
|
160
|
+
else
|
161
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
def configure_cert(http)
|
166
|
+
return if pem.blank?
|
167
|
+
|
168
|
+
http.cert = OpenSSL::X509::Certificate.new(pem)
|
169
|
+
|
170
|
+
if pem_password
|
171
|
+
http.key = OpenSSL::PKey::RSA.new(pem, pem_password)
|
172
|
+
else
|
173
|
+
http.key = OpenSSL::PKey::RSA.new(pem)
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
177
|
+
def debug(message, tag = nil)
|
178
|
+
log(:debug, message, tag)
|
179
|
+
end
|
180
|
+
|
181
|
+
def info(message, tag = nil)
|
182
|
+
log(:info, message, tag)
|
183
|
+
end
|
184
|
+
|
185
|
+
def error(message, tag = nil)
|
186
|
+
log(:error, message, tag)
|
187
|
+
end
|
188
|
+
|
189
|
+
def log(level, message, tag)
|
190
|
+
message = "[#{tag}] #{message}" if tag
|
191
|
+
logger&.send(level, message)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
end
|
@@ -0,0 +1,338 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module ActiveMerchant #:nodoc:
|
4
|
+
class InvalidCountryCodeError < StandardError
|
5
|
+
end
|
6
|
+
|
7
|
+
class CountryCodeFormatError < StandardError
|
8
|
+
end
|
9
|
+
|
10
|
+
class CountryCode
|
11
|
+
attr_reader :value, :format
|
12
|
+
def initialize(value)
|
13
|
+
@value = value.to_s.upcase
|
14
|
+
detect_format
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_s
|
18
|
+
value
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def detect_format
|
24
|
+
case @value
|
25
|
+
when /^[[:alpha:]]{2}$/
|
26
|
+
@format = :alpha2
|
27
|
+
when /^[[:alpha:]]{3}$/
|
28
|
+
@format = :alpha3
|
29
|
+
when /^[[:digit:]]{3}$/
|
30
|
+
@format = :numeric
|
31
|
+
else
|
32
|
+
raise CountryCodeFormatError, "The country code is not formatted correctly #{@value}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class Country
|
38
|
+
attr_reader :name
|
39
|
+
|
40
|
+
def initialize(options = {})
|
41
|
+
@name = options.delete(:name)
|
42
|
+
@codes = options.collect { |_k, v| CountryCode.new(v) }
|
43
|
+
end
|
44
|
+
|
45
|
+
def code(format)
|
46
|
+
@codes.detect { |c| c.format == format }
|
47
|
+
end
|
48
|
+
|
49
|
+
def ==(other)
|
50
|
+
if other.class == ActiveMerchant::Country
|
51
|
+
(@name == other.name)
|
52
|
+
else
|
53
|
+
super
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
alias eql? ==
|
58
|
+
|
59
|
+
def hash
|
60
|
+
@name.hash
|
61
|
+
end
|
62
|
+
|
63
|
+
def to_s
|
64
|
+
@name
|
65
|
+
end
|
66
|
+
|
67
|
+
COUNTRIES = [
|
68
|
+
{ alpha2: 'AF', name: 'Afghanistan', alpha3: 'AFG', numeric: '004' },
|
69
|
+
{ alpha2: 'AL', name: 'Albania', alpha3: 'ALB', numeric: '008' },
|
70
|
+
{ alpha2: 'DZ', name: 'Algeria', alpha3: 'DZA', numeric: '012' },
|
71
|
+
{ alpha2: 'AS', name: 'American Samoa', alpha3: 'ASM', numeric: '016' },
|
72
|
+
{ alpha2: 'AD', name: 'Andorra', alpha3: 'AND', numeric: '020' },
|
73
|
+
{ alpha2: 'AO', name: 'Angola', alpha3: 'AGO', numeric: '024' },
|
74
|
+
{ alpha2: 'AI', name: 'Anguilla', alpha3: 'AIA', numeric: '660' },
|
75
|
+
{ alpha2: 'AQ', name: 'Antarctica', alpha3: 'ATA', numeric: '010' },
|
76
|
+
{ alpha2: 'AG', name: 'Antigua and Barbuda', alpha3: 'ATG', numeric: '028' },
|
77
|
+
{ alpha2: 'AR', name: 'Argentina', alpha3: 'ARG', numeric: '032' },
|
78
|
+
{ alpha2: 'AM', name: 'Armenia', alpha3: 'ARM', numeric: '051' },
|
79
|
+
{ alpha2: 'AW', name: 'Aruba', alpha3: 'ABW', numeric: '533' },
|
80
|
+
{ alpha2: 'AU', name: 'Australia', alpha3: 'AUS', numeric: '036' },
|
81
|
+
{ alpha2: 'AT', name: 'Austria', alpha3: 'AUT', numeric: '040' },
|
82
|
+
{ alpha2: 'AZ', name: 'Azerbaijan', alpha3: 'AZE', numeric: '031' },
|
83
|
+
{ alpha2: 'BS', name: 'Bahamas', alpha3: 'BHS', numeric: '044' },
|
84
|
+
{ alpha2: 'BH', name: 'Bahrain', alpha3: 'BHR', numeric: '048' },
|
85
|
+
{ alpha2: 'BD', name: 'Bangladesh', alpha3: 'BGD', numeric: '050' },
|
86
|
+
{ alpha2: 'BB', name: 'Barbados', alpha3: 'BRB', numeric: '052' },
|
87
|
+
{ alpha2: 'BY', name: 'Belarus', alpha3: 'BLR', numeric: '112' },
|
88
|
+
{ alpha2: 'BE', name: 'Belgium', alpha3: 'BEL', numeric: '056' },
|
89
|
+
{ alpha2: 'BZ', name: 'Belize', alpha3: 'BLZ', numeric: '084' },
|
90
|
+
{ alpha2: 'BJ', name: 'Benin', alpha3: 'BEN', numeric: '204' },
|
91
|
+
{ alpha2: 'BM', name: 'Bermuda', alpha3: 'BMU', numeric: '060' },
|
92
|
+
{ alpha2: 'BT', name: 'Bhutan', alpha3: 'BTN', numeric: '064' },
|
93
|
+
{ alpha2: 'BO', name: 'Bolivia', alpha3: 'BOL', numeric: '068' },
|
94
|
+
{ alpha2: 'BQ', name: 'Bonaire, Sint Eustatius and Saba', alpha3: 'BES', numeric: '535' },
|
95
|
+
{ alpha2: 'BA', name: 'Bosnia and Herzegovina', alpha3: 'BIH', numeric: '070' },
|
96
|
+
{ alpha2: 'BW', name: 'Botswana', alpha3: 'BWA', numeric: '072' },
|
97
|
+
{ alpha2: 'BV', name: 'Bouvet Island', alpha3: 'BVD', numeric: '074' },
|
98
|
+
{ alpha2: 'BR', name: 'Brazil', alpha3: 'BRA', numeric: '076' },
|
99
|
+
{ alpha2: 'IO', name: 'British Indian Ocean Territory', alpha3: 'IOT', numeric: '086' },
|
100
|
+
{ alpha2: 'BN', name: 'Brunei Darussalam', alpha3: 'BRN', numeric: '096' },
|
101
|
+
{ alpha2: 'BG', name: 'Bulgaria', alpha3: 'BGR', numeric: '100' },
|
102
|
+
{ alpha2: 'BF', name: 'Burkina Faso', alpha3: 'BFA', numeric: '854' },
|
103
|
+
{ alpha2: 'BI', name: 'Burundi', alpha3: 'BDI', numeric: '108' },
|
104
|
+
{ alpha2: 'KH', name: 'Cambodia', alpha3: 'KHM', numeric: '116' },
|
105
|
+
{ alpha2: 'CM', name: 'Cameroon', alpha3: 'CMR', numeric: '120' },
|
106
|
+
{ alpha2: 'CA', name: 'Canada', alpha3: 'CAN', numeric: '124' },
|
107
|
+
{ alpha2: 'CV', name: 'Cape Verde', alpha3: 'CPV', numeric: '132' },
|
108
|
+
{ alpha2: 'KY', name: 'Cayman Islands', alpha3: 'CYM', numeric: '136' },
|
109
|
+
{ alpha2: 'CF', name: 'Central African Republic', alpha3: 'CAF', numeric: '140' },
|
110
|
+
{ alpha2: 'TD', name: 'Chad', alpha3: 'TCD', numeric: '148' },
|
111
|
+
{ alpha2: 'CL', name: 'Chile', alpha3: 'CHL', numeric: '152' },
|
112
|
+
{ alpha2: 'CN', name: 'China', alpha3: 'CHN', numeric: '156' },
|
113
|
+
{ alpha2: 'CX', name: 'Christmas Island', alpha3: 'CXR', numeric: '162' },
|
114
|
+
{ alpha2: 'CC', name: 'Cocos (Keeling) Islands', alpha3: 'CCK', numeric: '166' },
|
115
|
+
{ alpha2: 'CO', name: 'Colombia', alpha3: 'COL', numeric: '170' },
|
116
|
+
{ alpha2: 'KM', name: 'Comoros', alpha3: 'COM', numeric: '174' },
|
117
|
+
{ alpha2: 'CG', name: 'Congo', alpha3: 'COG', numeric: '178' },
|
118
|
+
{ alpha2: 'CD', name: 'Congo, the Democratic Republic of the', alpha3: 'COD', numeric: '180' },
|
119
|
+
{ alpha2: 'CK', name: 'Cook Islands', alpha3: 'COK', numeric: '184' },
|
120
|
+
{ alpha2: 'CR', name: 'Costa Rica', alpha3: 'CRI', numeric: '188' },
|
121
|
+
{ alpha2: 'CI', name: 'Cote D\'Ivoire', alpha3: 'CIV', numeric: '384' },
|
122
|
+
{ alpha2: 'HR', name: 'Croatia', alpha3: 'HRV', numeric: '191' },
|
123
|
+
{ alpha2: 'CU', name: 'Cuba', alpha3: 'CUB', numeric: '192' },
|
124
|
+
{ alpha2: 'CW', name: 'Curaçao', alpha3: 'CUW', numeric: '531' },
|
125
|
+
{ alpha2: 'CY', name: 'Cyprus', alpha3: 'CYP', numeric: '196' },
|
126
|
+
{ alpha2: 'CZ', name: 'Czech Republic', alpha3: 'CZE', numeric: '203' },
|
127
|
+
{ alpha2: 'DK', name: 'Denmark', alpha3: 'DNK', numeric: '208' },
|
128
|
+
{ alpha2: 'DJ', name: 'Djibouti', alpha3: 'DJI', numeric: '262' },
|
129
|
+
{ alpha2: 'DM', name: 'Dominica', alpha3: 'DMA', numeric: '212' },
|
130
|
+
{ alpha2: 'DO', name: 'Dominican Republic', alpha3: 'DOM', numeric: '214' },
|
131
|
+
{ alpha2: 'EC', name: 'Ecuador', alpha3: 'ECU', numeric: '218' },
|
132
|
+
{ alpha2: 'EG', name: 'Egypt', alpha3: 'EGY', numeric: '818' },
|
133
|
+
{ alpha2: 'SV', name: 'El Salvador', alpha3: 'SLV', numeric: '222' },
|
134
|
+
{ alpha2: 'GQ', name: 'Equatorial Guinea', alpha3: 'GNQ', numeric: '226' },
|
135
|
+
{ alpha2: 'ER', name: 'Eritrea', alpha3: 'ERI', numeric: '232' },
|
136
|
+
{ alpha2: 'EE', name: 'Estonia', alpha3: 'EST', numeric: '233' },
|
137
|
+
{ alpha2: 'ET', name: 'Ethiopia', alpha3: 'ETH', numeric: '231' },
|
138
|
+
{ alpha2: 'FK', name: 'Falkland Islands (Malvinas)', alpha3: 'FLK', numeric: '238' },
|
139
|
+
{ alpha2: 'FO', name: 'Faroe Islands', alpha3: 'FRO', numeric: '234' },
|
140
|
+
{ alpha2: 'FJ', name: 'Fiji', alpha3: 'FJI', numeric: '242' },
|
141
|
+
{ alpha2: 'FI', name: 'Finland', alpha3: 'FIN', numeric: '246' },
|
142
|
+
{ alpha2: 'FR', name: 'France', alpha3: 'FRA', numeric: '250' },
|
143
|
+
{ alpha2: 'GF', name: 'French Guiana', alpha3: 'GUF', numeric: '254' },
|
144
|
+
{ alpha2: 'PF', name: 'French Polynesia', alpha3: 'PYF', numeric: '258' },
|
145
|
+
{ alpha2: 'TF', name: 'French Southern Territories', alpha3: 'ATF', numeric: '260' },
|
146
|
+
{ alpha2: 'GA', name: 'Gabon', alpha3: 'GAB', numeric: '266' },
|
147
|
+
{ alpha2: 'GM', name: 'Gambia', alpha3: 'GMB', numeric: '270' },
|
148
|
+
{ alpha2: 'GE', name: 'Georgia', alpha3: 'GEO', numeric: '268' },
|
149
|
+
{ alpha2: 'DE', name: 'Germany', alpha3: 'DEU', numeric: '276' },
|
150
|
+
{ alpha2: 'GH', name: 'Ghana', alpha3: 'GHA', numeric: '288' },
|
151
|
+
{ alpha2: 'GI', name: 'Gibraltar', alpha3: 'GIB', numeric: '292' },
|
152
|
+
{ alpha2: 'GR', name: 'Greece', alpha3: 'GRC', numeric: '300' },
|
153
|
+
{ alpha2: 'GL', name: 'Greenland', alpha3: 'GRL', numeric: '304' },
|
154
|
+
{ alpha2: 'GD', name: 'Grenada', alpha3: 'GRD', numeric: '308' },
|
155
|
+
{ alpha2: 'GP', name: 'Guadeloupe', alpha3: 'GLP', numeric: '312' },
|
156
|
+
{ alpha2: 'GU', name: 'Guam', alpha3: 'GUM', numeric: '316' },
|
157
|
+
{ alpha2: 'GT', name: 'Guatemala', alpha3: 'GTM', numeric: '320' },
|
158
|
+
{ alpha2: 'GG', name: 'Guernsey', alpha3: 'GGY', numeric: '831' },
|
159
|
+
{ alpha2: 'GN', name: 'Guinea', alpha3: 'GIN', numeric: '324' },
|
160
|
+
{ alpha2: 'GW', name: 'Guinea-Bissau', alpha3: 'GNB', numeric: '624' },
|
161
|
+
{ alpha2: 'GY', name: 'Guyana', alpha3: 'GUY', numeric: '328' },
|
162
|
+
{ alpha2: 'HT', name: 'Haiti', alpha3: 'HTI', numeric: '332' },
|
163
|
+
{ alpha2: 'HM', name: 'Heard Island And Mcdonald Islands', alpha3: 'HMD', numeric: '334' },
|
164
|
+
{ alpha2: 'VA', name: 'Holy See (Vatican City State)', alpha3: 'VAT', numeric: '336' },
|
165
|
+
{ alpha2: 'HN', name: 'Honduras', alpha3: 'HND', numeric: '340' },
|
166
|
+
{ alpha2: 'HK', name: 'Hong Kong', alpha3: 'HKG', numeric: '344' },
|
167
|
+
{ alpha2: 'HU', name: 'Hungary', alpha3: 'HUN', numeric: '348' },
|
168
|
+
{ alpha2: 'IS', name: 'Iceland', alpha3: 'ISL', numeric: '352' },
|
169
|
+
{ alpha2: 'IN', name: 'India', alpha3: 'IND', numeric: '356' },
|
170
|
+
{ alpha2: 'ID', name: 'Indonesia', alpha3: 'IDN', numeric: '360' },
|
171
|
+
{ alpha2: 'IR', name: 'Iran, Islamic Republic of', alpha3: 'IRN', numeric: '364' },
|
172
|
+
{ alpha2: 'IQ', name: 'Iraq', alpha3: 'IRQ', numeric: '368' },
|
173
|
+
{ alpha2: 'IE', name: 'Ireland', alpha3: 'IRL', numeric: '372' },
|
174
|
+
{ alpha2: 'IM', name: 'Isle Of Man', alpha3: 'IMN', numeric: '833' },
|
175
|
+
{ alpha2: 'IL', name: 'Israel', alpha3: 'ISR', numeric: '376' },
|
176
|
+
{ alpha2: 'IT', name: 'Italy', alpha3: 'ITA', numeric: '380' },
|
177
|
+
{ alpha2: 'JM', name: 'Jamaica', alpha3: 'JAM', numeric: '388' },
|
178
|
+
{ alpha2: 'JP', name: 'Japan', alpha3: 'JPN', numeric: '392' },
|
179
|
+
{ alpha2: 'JE', name: 'Jersey', alpha3: 'JEY', numeric: '832' },
|
180
|
+
{ alpha2: 'JO', name: 'Jordan', alpha3: 'JOR', numeric: '400' },
|
181
|
+
{ alpha2: 'KZ', name: 'Kazakhstan', alpha3: 'KAZ', numeric: '398' },
|
182
|
+
{ alpha2: 'KE', name: 'Kenya', alpha3: 'KEN', numeric: '404' },
|
183
|
+
{ alpha2: 'KI', name: 'Kiribati', alpha3: 'KIR', numeric: '296' },
|
184
|
+
{ alpha2: 'KP', name: 'Korea, Democratic People\'s Republic of', alpha3: 'PRK', numeric: '408' },
|
185
|
+
{ alpha2: 'KR', name: 'Korea, Republic of', alpha3: 'KOR', numeric: '410' },
|
186
|
+
{ alpha2: 'XK', name: 'Kosovo', alpha3: 'XKX', numeric: '900' },
|
187
|
+
{ alpha2: 'QZ', name: 'Kosovo', alpha3: 'XKX', numeric: '900' },
|
188
|
+
{ alpha2: 'KW', name: 'Kuwait', alpha3: 'KWT', numeric: '414' },
|
189
|
+
{ alpha2: 'KG', name: 'Kyrgyzstan', alpha3: 'KGZ', numeric: '417' },
|
190
|
+
{ alpha2: 'LA', name: 'Lao People\'s Democratic Republic', alpha3: 'LAO', numeric: '418' },
|
191
|
+
{ alpha2: 'LV', name: 'Latvia', alpha3: 'LVA', numeric: '428' },
|
192
|
+
{ alpha2: 'LB', name: 'Lebanon', alpha3: 'LBN', numeric: '422' },
|
193
|
+
{ alpha2: 'LS', name: 'Lesotho', alpha3: 'LSO', numeric: '426' },
|
194
|
+
{ alpha2: 'LR', name: 'Liberia', alpha3: 'LBR', numeric: '430' },
|
195
|
+
{ alpha2: 'LY', name: 'Libyan Arab Jamahiriya', alpha3: 'LBY', numeric: '434' },
|
196
|
+
{ alpha2: 'LI', name: 'Liechtenstein', alpha3: 'LIE', numeric: '438' },
|
197
|
+
{ alpha2: 'LT', name: 'Lithuania', alpha3: 'LTU', numeric: '440' },
|
198
|
+
{ alpha2: 'LU', name: 'Luxembourg', alpha3: 'LUX', numeric: '442' },
|
199
|
+
{ alpha2: 'MO', name: 'Macao', alpha3: 'MAC', numeric: '446' },
|
200
|
+
{ alpha2: 'MK', name: 'Macedonia, the Former Yugoslav Republic of', alpha3: 'MKD', numeric: '807' },
|
201
|
+
{ alpha2: 'MG', name: 'Madagascar', alpha3: 'MDG', numeric: '450' },
|
202
|
+
{ alpha2: 'MW', name: 'Malawi', alpha3: 'MWI', numeric: '454' },
|
203
|
+
{ alpha2: 'MY', name: 'Malaysia', alpha3: 'MYS', numeric: '458' },
|
204
|
+
{ alpha2: 'MV', name: 'Maldives', alpha3: 'MDV', numeric: '462' },
|
205
|
+
{ alpha2: 'ML', name: 'Mali', alpha3: 'MLI', numeric: '466' },
|
206
|
+
{ alpha2: 'MT', name: 'Malta', alpha3: 'MLT', numeric: '470' },
|
207
|
+
{ alpha2: 'MH', name: 'Marshall Islands', alpha3: 'MHL', numeric: '584' },
|
208
|
+
{ alpha2: 'MQ', name: 'Martinique', alpha3: 'MTQ', numeric: '474' },
|
209
|
+
{ alpha2: 'MR', name: 'Mauritania', alpha3: 'MRT', numeric: '478' },
|
210
|
+
{ alpha2: 'MU', name: 'Mauritius', alpha3: 'MUS', numeric: '480' },
|
211
|
+
{ alpha2: 'YT', name: 'Mayotte', alpha3: 'MYT', numeric: '175' },
|
212
|
+
{ alpha2: 'MX', name: 'Mexico', alpha3: 'MEX', numeric: '484' },
|
213
|
+
{ alpha2: 'FM', name: 'Micronesia, Federated States of', alpha3: 'FSM', numeric: '583' },
|
214
|
+
{ alpha2: 'MD', name: 'Moldova, Republic of', alpha3: 'MDA', numeric: '498' },
|
215
|
+
{ alpha2: 'MC', name: 'Monaco', alpha3: 'MCO', numeric: '492' },
|
216
|
+
{ alpha2: 'MN', name: 'Mongolia', alpha3: 'MNG', numeric: '496' },
|
217
|
+
{ alpha2: 'ME', name: 'Montenegro', alpha3: 'MNE', numeric: '499' },
|
218
|
+
{ alpha2: 'MS', name: 'Montserrat', alpha3: 'MSR', numeric: '500' },
|
219
|
+
{ alpha2: 'MA', name: 'Morocco', alpha3: 'MAR', numeric: '504' },
|
220
|
+
{ alpha2: 'MZ', name: 'Mozambique', alpha3: 'MOZ', numeric: '508' },
|
221
|
+
{ alpha2: 'MM', name: 'Myanmar', alpha3: 'MMR', numeric: '104' },
|
222
|
+
{ alpha2: 'NA', name: 'Namibia', alpha3: 'NAM', numeric: '516' },
|
223
|
+
{ alpha2: 'NR', name: 'Nauru', alpha3: 'NRU', numeric: '520' },
|
224
|
+
{ alpha2: 'NP', name: 'Nepal', alpha3: 'NPL', numeric: '524' },
|
225
|
+
{ alpha2: 'NL', name: 'Netherlands', alpha3: 'NLD', numeric: '528' },
|
226
|
+
{ alpha2: 'NC', name: 'New Caledonia', alpha3: 'NCL', numeric: '540' },
|
227
|
+
{ alpha2: 'NZ', name: 'New Zealand', alpha3: 'NZL', numeric: '554' },
|
228
|
+
{ alpha2: 'NI', name: 'Nicaragua', alpha3: 'NIC', numeric: '558' },
|
229
|
+
{ alpha2: 'NE', name: 'Niger', alpha3: 'NER', numeric: '562' },
|
230
|
+
{ alpha2: 'NG', name: 'Nigeria', alpha3: 'NGA', numeric: '566' },
|
231
|
+
{ alpha2: 'NU', name: 'Niue', alpha3: 'NIU', numeric: '570' },
|
232
|
+
{ alpha2: 'NF', name: 'Norfolk Island', alpha3: 'NFK', numeric: '574' },
|
233
|
+
{ alpha2: 'MP', name: 'Northern Mariana Islands', alpha3: 'MNP', numeric: '580' },
|
234
|
+
{ alpha2: 'NO', name: 'Norway', alpha3: 'NOR', numeric: '578' },
|
235
|
+
{ alpha2: 'OM', name: 'Oman', alpha3: 'OMN', numeric: '512' },
|
236
|
+
{ alpha2: 'PK', name: 'Pakistan', alpha3: 'PAK', numeric: '586' },
|
237
|
+
{ alpha2: 'PW', name: 'Palau', alpha3: 'PLW', numeric: '585' },
|
238
|
+
{ alpha2: 'PS', name: 'Palestinian Territory, Occupied', alpha3: 'PSE', numeric: '275' },
|
239
|
+
{ alpha2: 'PA', name: 'Panama', alpha3: 'PAN', numeric: '591' },
|
240
|
+
{ alpha2: 'PG', name: 'Papua New Guinea', alpha3: 'PNG', numeric: '598' },
|
241
|
+
{ alpha2: 'PY', name: 'Paraguay', alpha3: 'PRY', numeric: '600' },
|
242
|
+
{ alpha2: 'PE', name: 'Peru', alpha3: 'PER', numeric: '604' },
|
243
|
+
{ alpha2: 'PH', name: 'Philippines', alpha3: 'PHL', numeric: '608' },
|
244
|
+
{ alpha2: 'PN', name: 'Pitcairn', alpha3: 'PCN', numeric: '612' },
|
245
|
+
{ alpha2: 'PL', name: 'Poland', alpha3: 'POL', numeric: '616' },
|
246
|
+
{ alpha2: 'PT', name: 'Portugal', alpha3: 'PRT', numeric: '620' },
|
247
|
+
{ alpha2: 'PR', name: 'Puerto Rico', alpha3: 'PRI', numeric: '630' },
|
248
|
+
{ alpha2: 'QA', name: 'Qatar', alpha3: 'QAT', numeric: '634' },
|
249
|
+
{ alpha2: 'RE', name: 'Reunion', alpha3: 'REU', numeric: '638' },
|
250
|
+
{ alpha2: 'RO', name: 'Romania', alpha3: 'ROU', numeric: '642' },
|
251
|
+
{ alpha2: 'RO', name: 'Romania', alpha3: 'ROM', numeric: '642' },
|
252
|
+
{ alpha2: 'RU', name: 'Russian Federation', alpha3: 'RUS', numeric: '643' },
|
253
|
+
{ alpha2: 'RW', name: 'Rwanda', alpha3: 'RWA', numeric: '646' },
|
254
|
+
{ alpha2: 'BL', name: 'Saint Barthélemy', alpha3: 'BLM', numeric: '652' },
|
255
|
+
{ alpha2: 'SH', name: 'Saint Helena', alpha3: 'SHN', numeric: '654' },
|
256
|
+
{ alpha2: 'KN', name: 'Saint Kitts and Nevis', alpha3: 'KNA', numeric: '659' },
|
257
|
+
{ alpha2: 'LC', name: 'Saint Lucia', alpha3: 'LCA', numeric: '662' },
|
258
|
+
{ alpha2: 'MF', name: 'Saint Martin (French part)', alpha3: 'MAF', numeric: '663' },
|
259
|
+
{ alpha2: 'PM', name: 'Saint Pierre and Miquelon', alpha3: 'SPM', numeric: '666' },
|
260
|
+
{ alpha2: 'VC', name: 'Saint Vincent and the Grenadines', alpha3: 'VCT', numeric: '670' },
|
261
|
+
{ alpha2: 'WS', name: 'Samoa', alpha3: 'WSM', numeric: '882' },
|
262
|
+
{ alpha2: 'SM', name: 'San Marino', alpha3: 'SMR', numeric: '674' },
|
263
|
+
{ alpha2: 'ST', name: 'Sao Tome and Principe', alpha3: 'STP', numeric: '678' },
|
264
|
+
{ alpha2: 'SA', name: 'Saudi Arabia', alpha3: 'SAU', numeric: '682' },
|
265
|
+
{ alpha2: 'SN', name: 'Senegal', alpha3: 'SEN', numeric: '686' },
|
266
|
+
{ alpha2: 'RS', name: 'Serbia', alpha3: 'SRB', numeric: '688' },
|
267
|
+
{ alpha2: 'SC', name: 'Seychelles', alpha3: 'SYC', numeric: '690' },
|
268
|
+
{ alpha2: 'SL', name: 'Sierra Leone', alpha3: 'SLE', numeric: '694' },
|
269
|
+
{ alpha2: 'SG', name: 'Singapore', alpha3: 'SGP', numeric: '702' },
|
270
|
+
{ alpha2: 'SX', name: 'Sint Maarten', alpha3: 'SXM', numeric: '534' },
|
271
|
+
{ alpha2: 'SK', name: 'Slovakia', alpha3: 'SVK', numeric: '703' },
|
272
|
+
{ alpha2: 'SI', name: 'Slovenia', alpha3: 'SVN', numeric: '705' },
|
273
|
+
{ alpha2: 'SB', name: 'Solomon Islands', alpha3: 'SLB', numeric: '090' },
|
274
|
+
{ alpha2: 'SO', name: 'Somalia', alpha3: 'SOM', numeric: '706' },
|
275
|
+
{ alpha2: 'ZA', name: 'South Africa', alpha3: 'ZAF', numeric: '710' },
|
276
|
+
{ alpha2: 'GS', name: 'South Georgia and the South Sandwich Islands', alpha3: 'SGS', numeric: '239' },
|
277
|
+
{ alpha2: 'SS', name: 'South Sudan', alpha3: 'SSD', numeric: '728' },
|
278
|
+
{ alpha2: 'ES', name: 'Spain', alpha3: 'ESP', numeric: '724' },
|
279
|
+
{ alpha2: 'LK', name: 'Sri Lanka', alpha3: 'LKA', numeric: '144' },
|
280
|
+
{ alpha2: 'SD', name: 'Sudan', alpha3: 'SDN', numeric: '729' },
|
281
|
+
{ alpha2: 'SR', name: 'Suriname', alpha3: 'SUR', numeric: '740' },
|
282
|
+
{ alpha2: 'SJ', name: 'Svalbard and Jan Mayen', alpha3: 'SJM', numeric: '744' },
|
283
|
+
{ alpha2: 'SZ', name: 'Swaziland', alpha3: 'SWZ', numeric: '748' },
|
284
|
+
{ alpha2: 'SE', name: 'Sweden', alpha3: 'SWE', numeric: '752' },
|
285
|
+
{ alpha2: 'CH', name: 'Switzerland', alpha3: 'CHE', numeric: '756' },
|
286
|
+
{ alpha2: 'SY', name: 'Syrian Arab Republic', alpha3: 'SYR', numeric: '760' },
|
287
|
+
{ alpha2: 'TW', name: 'Taiwan, Province of China', alpha3: 'TWN', numeric: '158' },
|
288
|
+
{ alpha2: 'TJ', name: 'Tajikistan', alpha3: 'TJK', numeric: '762' },
|
289
|
+
{ alpha2: 'TZ', name: 'Tanzania, United Republic of', alpha3: 'TZA', numeric: '834' },
|
290
|
+
{ alpha2: 'TH', name: 'Thailand', alpha3: 'THA', numeric: '764' },
|
291
|
+
{ alpha2: 'TL', name: 'Timor Leste', alpha3: 'TLS', numeric: '626' },
|
292
|
+
{ alpha2: 'TG', name: 'Togo', alpha3: 'TGO', numeric: '768' },
|
293
|
+
{ alpha2: 'TK', name: 'Tokelau', alpha3: 'TKL', numeric: '772' },
|
294
|
+
{ alpha2: 'TO', name: 'Tonga', alpha3: 'TON', numeric: '776' },
|
295
|
+
{ alpha2: 'TT', name: 'Trinidad and Tobago', alpha3: 'TTO', numeric: '780' },
|
296
|
+
{ alpha2: 'TN', name: 'Tunisia', alpha3: 'TUN', numeric: '788' },
|
297
|
+
{ alpha2: 'TR', name: 'Turkey', alpha3: 'TUR', numeric: '792' },
|
298
|
+
{ alpha2: 'TM', name: 'Turkmenistan', alpha3: 'TKM', numeric: '795' },
|
299
|
+
{ alpha2: 'TC', name: 'Turks and Caicos Islands', alpha3: 'TCA', numeric: '796' },
|
300
|
+
{ alpha2: 'TV', name: 'Tuvalu', alpha3: 'TUV', numeric: '798' },
|
301
|
+
{ alpha2: 'UG', name: 'Uganda', alpha3: 'UGA', numeric: '800' },
|
302
|
+
{ alpha2: 'UA', name: 'Ukraine', alpha3: 'UKR', numeric: '804' },
|
303
|
+
{ alpha2: 'AE', name: 'United Arab Emirates', alpha3: 'ARE', numeric: '784' },
|
304
|
+
{ alpha2: 'GB', name: 'United Kingdom', alpha3: 'GBR', numeric: '826' },
|
305
|
+
{ alpha2: 'US', name: 'United States', alpha3: 'USA', numeric: '840' },
|
306
|
+
{ alpha2: 'UM', name: 'United States Minor Outlying Islands', alpha3: 'UMI', numeric: '581' },
|
307
|
+
{ alpha2: 'UY', name: 'Uruguay', alpha3: 'URY', numeric: '858' },
|
308
|
+
{ alpha2: 'UZ', name: 'Uzbekistan', alpha3: 'UZB', numeric: '860' },
|
309
|
+
{ alpha2: 'VU', name: 'Vanuatu', alpha3: 'VUT', numeric: '548' },
|
310
|
+
{ alpha2: 'VE', name: 'Venezuela', alpha3: 'VEN', numeric: '862' },
|
311
|
+
{ alpha2: 'VN', name: 'Viet Nam', alpha3: 'VNM', numeric: '704' },
|
312
|
+
{ alpha2: 'VG', name: 'Virgin Islands, British', alpha3: 'VGB', numeric: '092' },
|
313
|
+
{ alpha2: 'VI', name: 'Virgin Islands, U.S.', alpha3: 'VIR', numeric: '850' },
|
314
|
+
{ alpha2: 'WF', name: 'Wallis and Futuna', alpha3: 'WLF', numeric: '876' },
|
315
|
+
{ alpha2: 'EH', name: 'Western Sahara', alpha3: 'ESH', numeric: '732' },
|
316
|
+
{ alpha2: 'YE', name: 'Yemen', alpha3: 'YEM', numeric: '887' },
|
317
|
+
{ alpha2: 'ZM', name: 'Zambia', alpha3: 'ZMB', numeric: '894' },
|
318
|
+
{ alpha2: 'ZW', name: 'Zimbabwe', alpha3: 'ZWE', numeric: '716' },
|
319
|
+
{ alpha2: 'AX', name: 'Åland Islands', alpha3: 'ALA', numeric: '248' }
|
320
|
+
]
|
321
|
+
|
322
|
+
def self.find(name)
|
323
|
+
raise InvalidCountryCodeError, 'Cannot lookup country for an empty name' if name.blank?
|
324
|
+
|
325
|
+
case name.length
|
326
|
+
when 2, 3
|
327
|
+
upcase_name = name.upcase
|
328
|
+
country_code = CountryCode.new(name)
|
329
|
+
country = COUNTRIES.detect { |c| c[country_code.format] == upcase_name }
|
330
|
+
else
|
331
|
+
country = COUNTRIES.detect { |c| c[:name].casecmp(name).zero? }
|
332
|
+
end
|
333
|
+
raise InvalidCountryCodeError, "No country could be found for the country #{name}" if country.nil?
|
334
|
+
|
335
|
+
Country.new(country.dup)
|
336
|
+
end
|
337
|
+
end
|
338
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module ActiveMerchant
|
2
|
+
module Empty
|
3
|
+
private
|
4
|
+
|
5
|
+
def empty?(value)
|
6
|
+
case value
|
7
|
+
when nil
|
8
|
+
true
|
9
|
+
when Array, Hash
|
10
|
+
value.empty?
|
11
|
+
when String
|
12
|
+
value.strip.empty?
|
13
|
+
when Numeric
|
14
|
+
(value == 0)
|
15
|
+
else
|
16
|
+
false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
2
|
+
class ActiveMerchantError < StandardError #:nodoc:
|
3
|
+
end
|
4
|
+
|
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
|
12
|
+
end
|
13
|
+
|
14
|
+
class RetriableConnectionError < ConnectionError # :nodoc:
|
15
|
+
end
|
16
|
+
|
17
|
+
class ResponseError < ActiveMerchantError # :nodoc:
|
18
|
+
attr_reader :response
|
19
|
+
|
20
|
+
def initialize(response, message = nil)
|
21
|
+
@response = response
|
22
|
+
@message = message
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_s
|
26
|
+
"Failed with #{response.code if response.respond_to?(:code)} #{response.message if response.respond_to?(:message)}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class OAuthResponseError < ResponseError # :nodoc:
|
31
|
+
end
|
32
|
+
|
33
|
+
class ClientCertificateError < ActiveMerchantError # :nodoc
|
34
|
+
end
|
35
|
+
|
36
|
+
class InvalidResponseError < ActiveMerchantError # :nodoc
|
37
|
+
end
|
38
|
+
end
|