activemerchant 1.4.2 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/CHANGELOG +78 -0
- data/{CONTRIBUTERS → CONTRIBUTORS} +44 -0
- data/{README → README.rdoc} +4 -1
- data/Rakefile +7 -13
- data/lib/active_merchant.rb +11 -21
- data/lib/active_merchant/billing/avs_result.rb +13 -10
- data/lib/active_merchant/billing/base.rb +2 -2
- data/lib/active_merchant/billing/check.rb +1 -1
- data/lib/active_merchant/billing/credit_card_methods.rb +2 -2
- data/lib/active_merchant/billing/expiry_date.rb +10 -4
- data/lib/active_merchant/billing/gateway.rb +7 -6
- data/lib/active_merchant/billing/gateways.rb +18 -3
- data/lib/active_merchant/billing/gateways/authorize_net.rb +20 -12
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +40 -6
- data/lib/active_merchant/billing/gateways/authorize_net_cim.rb.orig +736 -0
- data/lib/active_merchant/billing/gateways/braintree.rb +6 -211
- data/lib/active_merchant/billing/gateways/data_cash.rb +5 -7
- data/lib/active_merchant/billing/gateways/elavon.rb +134 -0
- data/lib/active_merchant/billing/gateways/eway.rb +7 -2
- data/lib/active_merchant/billing/gateways/first_pay.rb +172 -0
- data/lib/active_merchant/billing/gateways/instapay.rb +164 -0
- data/lib/active_merchant/billing/gateways/jetpay.rb +270 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +65 -12
- data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +154 -0
- data/lib/active_merchant/billing/gateways/merchant_ware.rb +283 -0
- data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +12 -6
- data/lib/active_merchant/billing/gateways/ogone.rb +279 -0
- data/lib/active_merchant/billing/gateways/pay_secure.rb +1 -1
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -1
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +1 -1
- data/lib/active_merchant/billing/gateways/payflow_express.rb +1 -1
- data/lib/active_merchant/billing/gateways/payment_express.rb +20 -32
- data/lib/active_merchant/billing/gateways/paypal.rb +22 -9
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +2 -1
- data/lib/active_merchant/billing/gateways/paypal_ca.rb +1 -1
- data/lib/active_merchant/billing/gateways/psl_card.rb +4 -6
- data/lib/active_merchant/billing/gateways/sage/sage_core.rb +7 -1
- data/lib/active_merchant/billing/gateways/{protx.rb → sage_pay.rb} +60 -35
- data/lib/active_merchant/billing/gateways/sallie_mae.rb +144 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +1 -1
- data/lib/active_merchant/billing/gateways/skip_jack.rb +23 -10
- data/lib/active_merchant/billing/gateways/smart_ps.rb +265 -0
- data/lib/active_merchant/billing/gateways/transax.rb +25 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +38 -14
- data/lib/active_merchant/billing/gateways/wirecard.rb +15 -2
- data/lib/active_merchant/billing/integrations.rb +18 -11
- data/lib/active_merchant/billing/integrations/bogus.rb +4 -3
- data/lib/active_merchant/billing/integrations/chronopay.rb +4 -3
- data/lib/active_merchant/billing/integrations/chronopay/notification.rb +3 -1
- data/lib/active_merchant/billing/integrations/gestpay.rb +4 -5
- data/lib/active_merchant/billing/integrations/gestpay/notification.rb +3 -1
- data/lib/active_merchant/billing/integrations/hi_trust.rb +4 -3
- data/lib/active_merchant/billing/integrations/nochex.rb +4 -3
- data/lib/active_merchant/billing/integrations/nochex/notification.rb +1 -1
- data/lib/active_merchant/billing/integrations/paypal.rb +3 -4
- data/lib/active_merchant/billing/integrations/paypal/helper.rb +9 -8
- data/lib/active_merchant/billing/integrations/quickpay.rb +2 -3
- data/lib/active_merchant/billing/integrations/quickpay/helper.rb +1 -1
- data/lib/active_merchant/billing/integrations/two_checkout.rb +3 -3
- data/lib/active_merchant/lib/connection.rb +170 -0
- data/lib/active_merchant/lib/country.rb +4 -1
- data/lib/active_merchant/lib/posts_data.rb +22 -84
- data/test/fixtures.yml +39 -1
- data/test/remote/gateways/remote_authorize_net_cim_test.rb +2 -1
- data/test/remote/gateways/remote_authorize_net_test.rb +1 -1
- data/test/remote/gateways/remote_beanstream_interac_test.rb +1 -1
- data/test/remote/gateways/remote_beanstream_test.rb +1 -1
- data/test/remote/gateways/remote_braintree_test.rb +2 -9
- data/test/remote/gateways/remote_card_stream_test.rb +1 -1
- data/test/remote/gateways/remote_cyber_source_test.rb +1 -1
- data/test/remote/gateways/remote_data_cash_test.rb +1 -2
- data/test/remote/gateways/remote_efsnet_test.rb +1 -1
- data/test/remote/gateways/remote_elavon_test.rb +66 -0
- data/test/remote/gateways/remote_eway_test.rb +1 -1
- data/test/remote/gateways/remote_exact_test.rb +1 -1
- data/test/remote/gateways/remote_first_pay_test.rb +87 -0
- data/test/remote/gateways/remote_instapay_test.rb +61 -0
- data/test/remote/gateways/remote_jetpay_test.rb +103 -0
- data/test/remote/gateways/remote_linkpoint_test.rb +11 -2
- data/test/remote/gateways/remote_merchant_e_solutions_test.rb +173 -0
- data/test/remote/gateways/remote_merchant_ware_test.rb +113 -0
- data/test/remote/gateways/remote_modern_payments_cim_test.rb +1 -1
- data/test/remote/gateways/remote_modern_payments_test.rb +23 -9
- data/test/remote/gateways/remote_moneris_test.rb +1 -1
- data/test/remote/gateways/remote_net_registry_test.rb +1 -1
- data/test/remote/gateways/remote_netbilling_test.rb +1 -1
- data/test/remote/gateways/remote_ogone_test.rb +115 -0
- data/test/remote/gateways/remote_pay_junction_test.rb +1 -1
- data/test/remote/gateways/remote_pay_secure_test.rb +1 -1
- data/test/remote/gateways/remote_payflow_express_test.rb +1 -1
- data/test/remote/gateways/remote_payflow_test.rb +1 -1
- data/test/remote/gateways/remote_payflow_uk_test.rb +1 -1
- data/test/remote/gateways/remote_payment_express_test.rb +17 -7
- data/test/remote/gateways/remote_paypal_express_test.rb +1 -1
- data/test/remote/gateways/remote_paypal_test.rb +26 -2
- data/test/remote/gateways/remote_plugnpay_test.rb +1 -1
- data/test/remote/gateways/remote_psigate_test.rb +1 -1
- data/test/remote/gateways/remote_psl_card_test.rb +1 -3
- data/test/remote/gateways/remote_quickpay_test.rb +1 -1
- data/test/remote/gateways/remote_realex_test.rb +1 -1
- data/test/remote/gateways/remote_sage_bankcard_test.rb +1 -1
- data/test/remote/gateways/remote_sage_pay_test.rb +219 -0
- data/test/remote/gateways/remote_sage_test.rb +1 -1
- data/test/remote/gateways/remote_sage_virtual_check_test.rb +1 -1
- data/test/remote/gateways/remote_sallie_mae_test.rb +51 -0
- data/test/remote/gateways/remote_secure_pay_au_test.rb +1 -1
- data/test/remote/gateways/remote_secure_pay_tech_test.rb +1 -1
- data/test/remote/gateways/remote_secure_pay_test.rb +2 -2
- data/test/remote/gateways/remote_skipjack_test.rb +1 -1
- data/test/remote/gateways/remote_trans_first_test.rb +1 -1
- data/test/remote/gateways/remote_transax_test.rb +112 -0
- data/test/remote/gateways/remote_trust_commerce_test.rb +1 -1
- data/test/remote/gateways/remote_usa_epay_test.rb +1 -1
- data/test/remote/gateways/remote_verifi_test.rb +1 -1
- data/test/remote/gateways/remote_viaklix_test.rb +1 -1
- data/test/remote/gateways/remote_wirecard_test.rb +34 -0
- data/test/remote/integrations/remote_gestpay_integration_test.rb +1 -1
- data/test/remote/integrations/remote_paypal_integration_test.rb +1 -1
- data/test/test_helper.rb +81 -89
- data/test/unit/avs_result_test.rb +1 -1
- data/test/unit/base_test.rb +1 -2
- data/test/unit/check_test.rb +1 -1
- data/test/unit/connection_test.rb +129 -0
- data/test/unit/country_code_test.rb +1 -1
- data/test/unit/country_test.rb +1 -1
- data/test/unit/credit_card_formatting_test.rb +1 -1
- data/test/unit/credit_card_methods_test.rb +10 -1
- data/test/unit/credit_card_test.rb +1 -1
- data/test/unit/cvv_result_test.rb +1 -1
- data/test/unit/expiry_date_test.rb +13 -2
- data/test/unit/gateways/authorize_net_cim_test.rb +39 -1
- data/test/unit/gateways/authorize_net_test.rb +1 -1
- data/test/unit/gateways/beanstream_interac_test.rb +1 -1
- data/test/unit/gateways/beanstream_test.rb +1 -1
- data/test/unit/gateways/bogus_test.rb +1 -1
- data/test/unit/gateways/braintree_test.rb +16 -14
- data/test/unit/gateways/card_stream_test.rb +1 -1
- data/test/unit/gateways/cyber_source_test.rb +1 -1
- data/test/unit/gateways/data_cash_test.rb +2 -1
- data/test/unit/gateways/efsnet_test.rb +1 -1
- data/test/unit/gateways/elavon_test.rb +139 -0
- data/test/unit/gateways/eway_test.rb +1 -1
- data/test/unit/gateways/exact_test.rb +1 -1
- data/test/unit/gateways/first_pay_test.rb +125 -0
- data/test/unit/gateways/gateway_test.rb +1 -1
- data/test/unit/gateways/instapay_test.rb +102 -0
- data/test/unit/gateways/jetpay_test.rb +185 -0
- data/test/unit/gateways/linkpoint_test.rb +37 -7
- data/test/unit/gateways/merchant_e_solutions_test.rb +169 -0
- data/test/unit/gateways/merchant_ware_test.rb +188 -0
- data/test/unit/gateways/modern_payments_cim_test.rb +25 -34
- data/test/unit/gateways/moneris_test.rb +1 -1
- data/test/unit/gateways/net_registry_test.rb +1 -1
- data/test/unit/gateways/netbilling_test.rb +1 -1
- data/test/unit/gateways/ogone_test.rb +319 -0
- data/test/unit/gateways/pay_junction_test.rb +1 -1
- data/test/unit/gateways/pay_secure_test.rb +1 -1
- data/test/unit/gateways/payflow_express_test.rb +2 -2
- data/test/unit/gateways/payflow_express_uk_test.rb +73 -1
- data/test/unit/gateways/payflow_test.rb +1 -1
- data/test/unit/gateways/payflow_uk_test.rb +1 -1
- data/test/unit/gateways/payment_express_test.rb +3 -3
- data/test/unit/gateways/paypal_express_test.rb +1 -1
- data/test/unit/gateways/paypal_test.rb +50 -1
- data/test/unit/gateways/plugnpay_test.rb +1 -1
- data/test/unit/gateways/psigate_test.rb +1 -1
- data/test/unit/gateways/psl_card_test.rb +1 -1
- data/test/unit/gateways/quickpay_test.rb +1 -1
- data/test/unit/gateways/realex_test.rb +1 -1
- data/test/unit/gateways/sage_bankcard_test.rb +36 -2
- data/test/unit/gateways/{protx_test.rb → sage_pay_test.rb} +49 -32
- data/test/unit/gateways/sage_virtual_check_test.rb +1 -1
- data/test/unit/gateways/sallie_mae_test.rb +53 -0
- data/test/unit/gateways/secure_pay_au_test.rb +1 -1
- data/test/unit/gateways/secure_pay_tech_test.rb +1 -1
- data/test/unit/gateways/secure_pay_test.rb +24 -10
- data/test/unit/gateways/skip_jack_test.rb +81 -1
- data/test/unit/gateways/trans_first_test.rb +1 -1
- data/test/unit/gateways/trust_commerce_test.rb +1 -1
- data/test/unit/gateways/usa_epay_test.rb +1 -1
- data/test/unit/gateways/verifi_test.rb +1 -1
- data/test/unit/gateways/viaklix_test.rb +1 -1
- data/test/unit/gateways/wirecard_test.rb +19 -1
- data/test/unit/generators/test_generator_helper.rb +1 -1
- data/test/unit/integrations/action_view_helper_test.rb +1 -1
- data/test/unit/integrations/bogus_module_test.rb +1 -1
- data/test/unit/integrations/chronopay_module_test.rb +1 -1
- data/test/unit/integrations/gestpay_module_test.rb +1 -1
- data/test/unit/integrations/helpers/bogus_helper_test.rb +1 -1
- data/test/unit/integrations/helpers/chronopay_helper_test.rb +1 -1
- data/test/unit/integrations/helpers/gestpay_helper_test.rb +1 -1
- data/test/unit/integrations/helpers/hi_trust_helper_test.rb +1 -1
- data/test/unit/integrations/helpers/nochex_helper_test.rb +1 -1
- data/test/unit/integrations/helpers/paypal_helper_test.rb +11 -2
- data/test/unit/integrations/helpers/quickpay_helper_test.rb +1 -1
- data/test/unit/integrations/helpers/two_checkout_helper_test.rb +1 -1
- data/test/unit/integrations/hi_trust_module_test.rb +1 -1
- data/test/unit/integrations/nochex_module_test.rb +1 -1
- data/test/unit/integrations/notifications/chronopay_notification_test.rb +1 -1
- data/test/unit/integrations/notifications/gestpay_notification_test.rb +1 -1
- data/test/unit/integrations/notifications/hi_trust_notification_test.rb +1 -1
- data/test/unit/integrations/notifications/nochex_notification_test.rb +2 -2
- data/test/unit/integrations/notifications/notification_test.rb +1 -1
- data/test/unit/integrations/notifications/paypal_notification_test.rb +1 -1
- data/test/unit/integrations/notifications/quickpay_notification_test.rb +1 -1
- data/test/unit/integrations/notifications/two_checkout_notification_test.rb +1 -1
- data/test/unit/integrations/paypal_module_test.rb +1 -1
- data/test/unit/integrations/quickpay_module_test.rb +1 -1
- data/test/unit/integrations/returns/chronopay_return_test.rb +1 -1
- data/test/unit/integrations/returns/gestpay_return_test.rb +1 -1
- data/test/unit/integrations/returns/hi_trust_return_test.rb +1 -1
- data/test/unit/integrations/returns/nochex_return_test.rb +1 -1
- data/test/unit/integrations/returns/paypal_return_test.rb +1 -1
- data/test/unit/integrations/returns/return_test.rb +1 -1
- data/test/unit/integrations/returns/two_checkout_return_test.rb +1 -1
- data/test/unit/integrations/two_checkout_module_test.rb +1 -1
- data/test/unit/post_data_test.rb +1 -1
- data/test/unit/posts_data_test.rb +14 -66
- data/test/unit/response_test.rb +1 -1
- data/test/unit/utils_test.rb +1 -1
- data/test/unit/validateable_test.rb +1 -1
- metadata +41 -45
- metadata.gz.sig +0 -0
- data/test/extra/binding_of_caller.rb +0 -80
- data/test/extra/breakpoint.rb +0 -547
- data/test/remote/gateways/remote_protx_test.rb +0 -184
@@ -1,11 +1,12 @@
|
|
1
|
-
require 'active_merchant/billing/integrations/bogus/helper.rb'
|
2
|
-
require 'active_merchant/billing/integrations/bogus/notification.rb'
|
3
|
-
require 'active_merchant/billing/integrations/bogus/return.rb'
|
4
1
|
|
5
2
|
module ActiveMerchant #:nodoc:
|
6
3
|
module Billing #:nodoc:
|
7
4
|
module Integrations #:nodoc:
|
8
5
|
module Bogus
|
6
|
+
autoload :Return, 'active_merchant/billing/integrations/bogus/return.rb'
|
7
|
+
autoload :Helper, 'active_merchant/billing/integrations/bogus/helper.rb'
|
8
|
+
autoload :Notification, 'active_merchant/billing/integrations/bogus/notification.rb'
|
9
|
+
|
9
10
|
mattr_accessor :service_url
|
10
11
|
self.service_url = 'http://www.bogus.com'
|
11
12
|
|
@@ -1,11 +1,12 @@
|
|
1
|
-
require 'active_merchant/billing/integrations/chronopay/helper.rb'
|
2
|
-
require 'active_merchant/billing/integrations/chronopay/notification.rb'
|
3
|
-
require 'active_merchant/billing/integrations/chronopay/return.rb'
|
4
1
|
|
5
2
|
module ActiveMerchant #:nodoc:
|
6
3
|
module Billing #:nodoc:
|
7
4
|
module Integrations #:nodoc:
|
8
5
|
module Chronopay
|
6
|
+
autoload :Return, 'active_merchant/billing/integrations/chronopay/return.rb'
|
7
|
+
autoload :Helper, 'active_merchant/billing/integrations/chronopay/helper.rb'
|
8
|
+
autoload :Notification, 'active_merchant/billing/integrations/chronopay/notification.rb'
|
9
|
+
|
9
10
|
mattr_accessor :service_url
|
10
11
|
self.service_url = 'https://secure.chronopay.com/index_shop.cgi'
|
11
12
|
|
@@ -59,7 +59,9 @@ module ActiveMerchant #:nodoc:
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def received_at
|
62
|
-
|
62
|
+
# Date should be formatted "dd-mm-yy" to be parsed by 1.8 and 1.9 the same way
|
63
|
+
formatted_date = Date.strptime(date, "%m/%d/%Y").strftime("%d-%m-%Y")
|
64
|
+
Time.parse("#{formatted_date} #{time}") unless date.blank? || time.blank?
|
63
65
|
end
|
64
66
|
|
65
67
|
# Date of transaction in MM/DD/YYYY format
|
@@ -1,14 +1,13 @@
|
|
1
1
|
# With help from Giovanni Intini and his code for RGestPay - http://medlar.it/it/progetti/rgestpay
|
2
2
|
|
3
|
-
require File.dirname(__FILE__) + '/gestpay/common.rb'
|
4
|
-
require File.dirname(__FILE__) + '/gestpay/helper.rb'
|
5
|
-
require File.dirname(__FILE__) + '/gestpay/notification.rb'
|
6
|
-
require File.dirname(__FILE__) + '/gestpay/return.rb'
|
7
|
-
|
8
3
|
module ActiveMerchant #:nodoc:
|
9
4
|
module Billing #:nodoc:
|
10
5
|
module Integrations #:nodoc:
|
11
6
|
module Gestpay
|
7
|
+
autoload :Return, File.dirname(__FILE__) + '/gestpay/return.rb'
|
8
|
+
autoload :Common, File.dirname(__FILE__) + '/gestpay/common.rb'
|
9
|
+
autoload :Helper, File.dirname(__FILE__) + '/gestpay/helper.rb'
|
10
|
+
autoload :Notification, File.dirname(__FILE__) + '/gestpay/notification.rb'
|
12
11
|
|
13
12
|
mattr_accessor :service_url
|
14
13
|
self.service_url = 'https://ecomm.sella.it/gestpay/pagam.asp'
|
@@ -26,7 +26,9 @@ module ActiveMerchant #:nodoc:
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def currency
|
29
|
-
|
29
|
+
# Ruby 1.9 compat
|
30
|
+
method = CURRENCY_MAPPING.respond_to?(:key) ? :key : :index
|
31
|
+
CURRENCY_MAPPING.send(method, params['PAY1_UICCODE'])
|
30
32
|
end
|
31
33
|
|
32
34
|
def test?
|
@@ -1,11 +1,12 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/hi_trust/helper.rb'
|
2
|
-
require File.dirname(__FILE__) + '/hi_trust/notification.rb'
|
3
|
-
require File.dirname(__FILE__) + '/hi_trust/return.rb'
|
4
1
|
|
5
2
|
module ActiveMerchant #:nodoc:
|
6
3
|
module Billing #:nodoc:
|
7
4
|
module Integrations #:nodoc:
|
8
5
|
module HiTrust
|
6
|
+
autoload :Helper, File.dirname(__FILE__) + '/hi_trust/helper.rb'
|
7
|
+
autoload :Return, File.dirname(__FILE__) + '/hi_trust/return.rb'
|
8
|
+
autoload :Notification, File.dirname(__FILE__) + '/hi_trust/notification.rb'
|
9
|
+
|
9
10
|
TEST_URL = 'https://testtrustlink.hitrust.com.tw/TrustLink/TrxReq'
|
10
11
|
LIVE_URL = 'https://trustlink.hitrust.com.tw/TrustLink/TrxReq'
|
11
12
|
|
@@ -1,6 +1,3 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/nochex/helper.rb'
|
2
|
-
require File.dirname(__FILE__) + '/nochex/notification.rb'
|
3
|
-
require File.dirname(__FILE__) + '/nochex/return.rb'
|
4
1
|
|
5
2
|
module ActiveMerchant #:nodoc:
|
6
3
|
module Billing #:nodoc:
|
@@ -65,6 +62,10 @@ module ActiveMerchant #:nodoc:
|
|
65
62
|
# end
|
66
63
|
# end
|
67
64
|
module Nochex
|
65
|
+
autoload :Return, File.dirname(__FILE__) + '/nochex/return.rb'
|
66
|
+
autoload :Helper, File.dirname(__FILE__) + '/nochex/helper.rb'
|
67
|
+
autoload :Notification, File.dirname(__FILE__) + '/nochex/notification.rb'
|
68
|
+
|
68
69
|
|
69
70
|
mattr_accessor :service_url
|
70
71
|
self.service_url = 'https://www.nochex.com/nochex.dll/checkout'
|
@@ -1,11 +1,10 @@
|
|
1
|
-
require 'active_merchant/billing/integrations/paypal/helper.rb'
|
2
|
-
require 'active_merchant/billing/integrations/paypal/notification.rb'
|
3
|
-
require 'active_merchant/billing/integrations/paypal/return.rb'
|
4
|
-
|
5
1
|
module ActiveMerchant #:nodoc:
|
6
2
|
module Billing #:nodoc:
|
7
3
|
module Integrations #:nodoc:
|
8
4
|
module Paypal
|
5
|
+
autoload :Return, 'active_merchant/billing/integrations/paypal/return.rb'
|
6
|
+
autoload :Helper, 'active_merchant/billing/integrations/paypal/helper.rb'
|
7
|
+
autoload :Notification, 'active_merchant/billing/integrations/paypal/notification.rb'
|
9
8
|
|
10
9
|
# Overwrite this if you want to change the Paypal test url
|
11
10
|
mattr_accessor :test_url
|
@@ -60,25 +60,26 @@ module ActiveMerchant #:nodoc:
|
|
60
60
|
:country => 'country'
|
61
61
|
|
62
62
|
def shipping_address(params = {})
|
63
|
+
|
64
|
+
# Get the country code in the correct format
|
65
|
+
# Use what we were given if we can't find anything
|
66
|
+
country_code = lookup_country_code(params.delete(:country))
|
67
|
+
add_field(mappings[:shipping_address][:country], country_code)
|
63
68
|
|
64
69
|
if params.has_key?(:phone)
|
65
70
|
phone = params.delete(:phone).to_s
|
66
71
|
|
67
72
|
# Whipe all non digits
|
68
73
|
phone.gsub!(/\D+/, '')
|
69
|
-
|
70
|
-
|
71
|
-
if phone =~ /(\d{3})(\d{3})(\d{4})$/
|
74
|
+
|
75
|
+
if ['US', 'CA'].include?(country_code) && phone =~ /(\d{3})(\d{3})(\d{4})$/
|
72
76
|
add_field('night_phone_a', $1)
|
73
77
|
add_field('night_phone_b', $2)
|
74
78
|
add_field('night_phone_c', $3)
|
79
|
+
else
|
80
|
+
add_field('night_phone_b', phone)
|
75
81
|
end
|
76
82
|
end
|
77
|
-
|
78
|
-
# Get the country code in the correct format
|
79
|
-
# Use what we were given if we can't find anything
|
80
|
-
country_code = lookup_country_code(params.delete(:country))
|
81
|
-
add_field(mappings[:shipping_address][:country], country_code)
|
82
83
|
|
83
84
|
province_code = params.delete(:state)
|
84
85
|
|
@@ -1,10 +1,9 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/quickpay/helper.rb'
|
2
|
-
require File.dirname(__FILE__) + '/quickpay/notification.rb'
|
3
|
-
|
4
1
|
module ActiveMerchant #:nodoc:
|
5
2
|
module Billing #:nodoc:
|
6
3
|
module Integrations #:nodoc:
|
7
4
|
module Quickpay
|
5
|
+
autoload :Helper, File.dirname(__FILE__) + '/quickpay/helper.rb'
|
6
|
+
autoload :Notification, File.dirname(__FILE__) + '/quickpay/notification.rb'
|
8
7
|
|
9
8
|
mattr_accessor :service_url
|
10
9
|
self.service_url = 'https://secure.quickpay.dk/form/'
|
@@ -1,11 +1,11 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/two_checkout/helper.rb'
|
2
|
-
require File.dirname(__FILE__) + '/two_checkout/notification.rb'
|
3
|
-
require File.dirname(__FILE__) + '/two_checkout/return.rb'
|
4
1
|
|
5
2
|
module ActiveMerchant #:nodoc:
|
6
3
|
module Billing #:nodoc:
|
7
4
|
module Integrations #:nodoc:
|
8
5
|
module TwoCheckout
|
6
|
+
autoload 'Helper', File.dirname(__FILE__) + '/two_checkout/helper'
|
7
|
+
autoload 'Return', File.dirname(__FILE__) + '/two_checkout/return'
|
8
|
+
autoload 'Notification', File.dirname(__FILE__) + '/two_Checkout/notification'
|
9
9
|
|
10
10
|
mattr_accessor :service_url
|
11
11
|
self.service_url = 'https://www.2checkout.com/2co/buyer/purchase'
|
@@ -0,0 +1,170 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'net/http'
|
3
|
+
require 'net/https'
|
4
|
+
require 'benchmark'
|
5
|
+
|
6
|
+
module ActiveMerchant
|
7
|
+
class ConnectionError < ActiveMerchantError # :nodoc:
|
8
|
+
end
|
9
|
+
|
10
|
+
class RetriableConnectionError < ConnectionError # :nodoc:
|
11
|
+
end
|
12
|
+
|
13
|
+
class ResponseError < ActiveMerchantError # :nodoc:
|
14
|
+
attr_reader :response
|
15
|
+
|
16
|
+
def initialize(response, message = nil)
|
17
|
+
@response = response
|
18
|
+
@message = message
|
19
|
+
end
|
20
|
+
|
21
|
+
def to_s
|
22
|
+
"Failed with #{response.code} #{response.message if response.respond_to?(:message)}"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class Connection
|
27
|
+
MAX_RETRIES = 3
|
28
|
+
OPEN_TIMEOUT = 60
|
29
|
+
READ_TIMEOUT = 60
|
30
|
+
VERIFY_PEER = true
|
31
|
+
RETRY_SAFE = false
|
32
|
+
RUBY_184_POST_HEADERS = { "Content-Type" => "application/x-www-form-urlencoded" }
|
33
|
+
|
34
|
+
attr_accessor :endpoint
|
35
|
+
attr_accessor :open_timeout
|
36
|
+
attr_accessor :read_timeout
|
37
|
+
attr_accessor :verify_peer
|
38
|
+
attr_accessor :retry_safe
|
39
|
+
attr_accessor :pem
|
40
|
+
attr_accessor :pem_password
|
41
|
+
attr_accessor :wiredump_device
|
42
|
+
attr_accessor :logger
|
43
|
+
attr_accessor :tag
|
44
|
+
|
45
|
+
def initialize(endpoint)
|
46
|
+
@endpoint = endpoint.is_a?(URI) ? endpoint : URI.parse(endpoint)
|
47
|
+
@open_timeout = OPEN_TIMEOUT
|
48
|
+
@read_timeout = READ_TIMEOUT
|
49
|
+
@retry_safe = RETRY_SAFE
|
50
|
+
@verify_peer = VERIFY_PEER
|
51
|
+
end
|
52
|
+
|
53
|
+
def request(method, body, headers = {})
|
54
|
+
retry_exceptions do
|
55
|
+
begin
|
56
|
+
info "#{method.to_s.upcase} #{endpoint}", tag
|
57
|
+
|
58
|
+
result = nil
|
59
|
+
|
60
|
+
realtime = Benchmark.realtime do
|
61
|
+
result = case method
|
62
|
+
when :get
|
63
|
+
raise ArgumentError, "GET requests do not support a request body" if body
|
64
|
+
http.get(endpoint.request_uri, headers)
|
65
|
+
when :post
|
66
|
+
debug body
|
67
|
+
http.post(endpoint.request_uri, body, RUBY_184_POST_HEADERS.merge(headers))
|
68
|
+
else
|
69
|
+
raise ArgumentError, "Unsupported request method #{method.to_s.upcase}"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
info "--> %d %s (%d %.4fs)" % [result.code, result.message, result.body ? result.body.length : 0, realtime], tag
|
74
|
+
response = handle_response(result)
|
75
|
+
debug response
|
76
|
+
response
|
77
|
+
rescue EOFError => e
|
78
|
+
raise ConnectionError, "The remote server dropped the connection"
|
79
|
+
rescue Errno::ECONNRESET => e
|
80
|
+
raise ConnectionError, "The remote server reset the connection"
|
81
|
+
rescue Errno::ECONNREFUSED => e
|
82
|
+
raise RetriableConnectionError, "The remote server refused the connection"
|
83
|
+
rescue Timeout::Error, Errno::ETIMEDOUT => e
|
84
|
+
raise ConnectionError, "The connection to the remote server timed out"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
private
|
90
|
+
def http
|
91
|
+
http = Net::HTTP.new(endpoint.host, endpoint.port)
|
92
|
+
configure_debugging(http)
|
93
|
+
configure_timeouts(http)
|
94
|
+
configure_ssl(http)
|
95
|
+
configure_cert(http)
|
96
|
+
http
|
97
|
+
end
|
98
|
+
|
99
|
+
def configure_debugging(http)
|
100
|
+
http.set_debug_output(wiredump_device)
|
101
|
+
end
|
102
|
+
|
103
|
+
def configure_timeouts(http)
|
104
|
+
http.open_timeout = open_timeout
|
105
|
+
http.read_timeout = read_timeout
|
106
|
+
end
|
107
|
+
|
108
|
+
def configure_ssl(http)
|
109
|
+
return unless endpoint.scheme == "https"
|
110
|
+
|
111
|
+
http.use_ssl = true
|
112
|
+
|
113
|
+
if verify_peer
|
114
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
115
|
+
http.ca_file = File.dirname(__FILE__) + '/../../certs/cacert.pem'
|
116
|
+
else
|
117
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
def configure_cert(http)
|
122
|
+
return if pem.blank?
|
123
|
+
|
124
|
+
http.cert = OpenSSL::X509::Certificate.new(pem)
|
125
|
+
|
126
|
+
if pem_password
|
127
|
+
http.key = OpenSSL::PKey::RSA.new(pem, pem_password)
|
128
|
+
else
|
129
|
+
http.key = OpenSSL::PKey::RSA.new(pem)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
def retry_exceptions
|
134
|
+
retries = MAX_RETRIES
|
135
|
+
begin
|
136
|
+
yield
|
137
|
+
rescue RetriableConnectionError => e
|
138
|
+
retries -= 1
|
139
|
+
retry unless retries.zero?
|
140
|
+
raise ConnectionError, e.message
|
141
|
+
rescue ConnectionError
|
142
|
+
retries -= 1
|
143
|
+
retry if retry_safe && !retries.zero?
|
144
|
+
raise
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
def handle_response(response)
|
149
|
+
case response.code.to_i
|
150
|
+
when 200...300
|
151
|
+
response.body
|
152
|
+
else
|
153
|
+
raise ResponseError.new(response)
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def debug(message, tag = nil)
|
158
|
+
log(:debug, message, tag)
|
159
|
+
end
|
160
|
+
|
161
|
+
def info(message, tag = nil)
|
162
|
+
log(:info, message, tag)
|
163
|
+
end
|
164
|
+
|
165
|
+
def log(level, message, tag)
|
166
|
+
message = "[#{tag}] #{message}" if tag
|
167
|
+
logger.send(level, message) if logger
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
@@ -1,3 +1,6 @@
|
|
1
|
+
#!ruby19
|
2
|
+
# encoding: utf-8
|
3
|
+
|
1
4
|
module ActiveMerchant #:nodoc:
|
2
5
|
class InvalidCountryCodeError < StandardError
|
3
6
|
end
|
@@ -43,7 +46,7 @@ module ActiveMerchant #:nodoc:
|
|
43
46
|
end
|
44
47
|
|
45
48
|
def code(format)
|
46
|
-
@codes.
|
49
|
+
@codes.find{|c| c.format == format}
|
47
50
|
end
|
48
51
|
|
49
52
|
def to_s
|
@@ -1,108 +1,46 @@
|
|
1
1
|
module ActiveMerchant #:nodoc:
|
2
|
-
class ConnectionError < ActiveMerchantError
|
3
|
-
end
|
4
|
-
|
5
|
-
class RetriableConnectionError < ConnectionError
|
6
|
-
end
|
7
|
-
|
8
2
|
module PostsData #:nodoc:
|
9
|
-
|
10
|
-
OPEN_TIMEOUT = 60
|
11
|
-
READ_TIMEOUT = 60
|
12
|
-
|
3
|
+
|
13
4
|
def self.included(base)
|
14
5
|
base.superclass_delegating_accessor :ssl_strict
|
15
6
|
base.ssl_strict = true
|
16
7
|
|
17
|
-
base.class_inheritable_accessor :pem_password
|
18
|
-
base.pem_password = false
|
19
|
-
|
20
8
|
base.class_inheritable_accessor :retry_safe
|
21
9
|
base.retry_safe = false
|
22
10
|
|
23
11
|
base.superclass_delegating_accessor :open_timeout
|
24
|
-
base.open_timeout =
|
12
|
+
base.open_timeout = 60
|
25
13
|
|
26
14
|
base.superclass_delegating_accessor :read_timeout
|
27
|
-
base.read_timeout =
|
15
|
+
base.read_timeout = 60
|
16
|
+
|
17
|
+
base.superclass_delegating_accessor :logger
|
18
|
+
base.superclass_delegating_accessor :wiredump_device
|
28
19
|
end
|
29
20
|
|
30
|
-
def ssl_get(
|
31
|
-
ssl_request(:get,
|
21
|
+
def ssl_get(endpoint, headers={})
|
22
|
+
ssl_request(:get, endpoint, nil, headers)
|
32
23
|
end
|
33
24
|
|
34
|
-
def ssl_post(
|
35
|
-
ssl_request(:post,
|
25
|
+
def ssl_post(endpoint, data, headers = {})
|
26
|
+
ssl_request(:post, endpoint, data, headers)
|
36
27
|
end
|
37
28
|
|
38
29
|
private
|
39
|
-
def
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
retries -= 1
|
49
|
-
retry if retry_safe && !retries.zero?
|
50
|
-
raise
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def ssl_request(method, url, data, headers = {})
|
55
|
-
if method == :post
|
56
|
-
# Ruby 1.8.4 doesn't automatically set this header
|
57
|
-
headers['Content-Type'] ||= "application/x-www-form-urlencoded"
|
58
|
-
end
|
30
|
+
def ssl_request(method, endpoint, data, headers = {})
|
31
|
+
connection = Connection.new(endpoint)
|
32
|
+
connection.open_timeout = open_timeout
|
33
|
+
connection.read_timeout = read_timeout
|
34
|
+
connection.retry_safe = retry_safe
|
35
|
+
connection.verify_peer = ssl_strict
|
36
|
+
connection.logger = logger
|
37
|
+
connection.tag = self.class.name
|
38
|
+
connection.wiredump_device = wiredump_device
|
59
39
|
|
60
|
-
|
61
|
-
|
62
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
63
|
-
http.open_timeout = self.class.open_timeout
|
64
|
-
http.read_timeout = self.class.read_timeout
|
40
|
+
connection.pem = @options[:pem] if @options
|
41
|
+
connection.pem_password = @options[:pem_password] if @options
|
65
42
|
|
66
|
-
|
67
|
-
http.use_ssl = true
|
68
|
-
|
69
|
-
if ssl_strict
|
70
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
71
|
-
http.ca_file = File.dirname(__FILE__) + '/../../certs/cacert.pem'
|
72
|
-
else
|
73
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
74
|
-
end
|
75
|
-
|
76
|
-
if @options && !@options[:pem].blank?
|
77
|
-
http.cert = OpenSSL::X509::Certificate.new(@options[:pem])
|
78
|
-
|
79
|
-
if pem_password
|
80
|
-
raise ArgumentError, "The private key requires a password" if @options[:pem_password].blank?
|
81
|
-
http.key = OpenSSL::PKey::RSA.new(@options[:pem], @options[:pem_password])
|
82
|
-
else
|
83
|
-
http.key = OpenSSL::PKey::RSA.new(@options[:pem])
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
retry_exceptions do
|
89
|
-
begin
|
90
|
-
case method
|
91
|
-
when :get
|
92
|
-
http.get(uri.request_uri, headers).body
|
93
|
-
when :post
|
94
|
-
http.post(uri.request_uri, data, headers).body
|
95
|
-
end
|
96
|
-
rescue EOFError => e
|
97
|
-
raise ConnectionError, "The remote server dropped the connection"
|
98
|
-
rescue Errno::ECONNRESET => e
|
99
|
-
raise ConnectionError, "The remote server reset the connection"
|
100
|
-
rescue Errno::ECONNREFUSED => e
|
101
|
-
raise RetriableConnectionError, "The remote server refused the connection"
|
102
|
-
rescue Timeout::Error, Errno::ETIMEDOUT => e
|
103
|
-
raise ConnectionError, "The connection to the remote server timed out"
|
104
|
-
end
|
105
|
-
end
|
43
|
+
connection.request(method, data, headers)
|
106
44
|
end
|
107
45
|
|
108
46
|
end
|