activemerchant 1.2.1 → 1.3.0
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.
- data.tar.gz.sig +0 -0
- data/CHANGELOG +310 -294
- data/CONTRIBUTERS +13 -0
- data/README +55 -31
- data/Rakefile +21 -13
- data/lib/active_merchant.rb +7 -0
- data/lib/active_merchant/billing/avs_result.rb +95 -0
- data/lib/active_merchant/billing/base.rb +8 -3
- data/lib/active_merchant/billing/check.rb +61 -0
- data/lib/active_merchant/billing/credit_card.rb +104 -80
- data/lib/active_merchant/billing/credit_card_formatting.rb +11 -8
- data/lib/active_merchant/billing/credit_card_methods.rb +76 -32
- data/lib/active_merchant/billing/cvv_result.rb +38 -0
- data/lib/active_merchant/billing/expiry_date.rb +28 -0
- data/lib/active_merchant/billing/gateway.rb +47 -111
- data/lib/active_merchant/billing/gateways/authorize_net.rb +508 -121
- data/lib/active_merchant/billing/gateways/bogus.rb +26 -32
- data/lib/active_merchant/billing/gateways/brain_tree.rb +82 -70
- data/lib/active_merchant/billing/gateways/card_stream.rb +43 -15
- data/lib/active_merchant/billing/gateways/cyber_source.rb +9 -29
- data/lib/active_merchant/billing/gateways/data_cash.rb +18 -38
- data/lib/active_merchant/billing/gateways/efsnet.rb +23 -50
- data/lib/active_merchant/billing/gateways/eway.rb +8 -19
- data/lib/active_merchant/billing/gateways/exact.rb +17 -25
- data/lib/active_merchant/billing/gateways/linkpoint.rb +18 -25
- data/lib/active_merchant/billing/gateways/moneris.rb +9 -39
- data/lib/active_merchant/billing/gateways/net_registry.rb +113 -182
- data/lib/active_merchant/billing/gateways/netbilling.rb +168 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +52 -73
- data/lib/active_merchant/billing/gateways/pay_secure.rb +120 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +13 -14
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +55 -37
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +4 -0
- data/lib/active_merchant/billing/gateways/payflow_express.rb +2 -4
- data/lib/active_merchant/billing/gateways/payment_express.rb +11 -30
- data/lib/active_merchant/billing/gateways/paypal.rb +3 -14
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +36 -16
- data/lib/active_merchant/billing/gateways/paypal_express.rb +1 -2
- data/lib/active_merchant/billing/gateways/plugnpay.rb +7 -15
- data/lib/active_merchant/billing/gateways/protx.rb +24 -25
- data/lib/active_merchant/billing/gateways/psigate.rb +34 -71
- data/lib/active_merchant/billing/gateways/psl_card.rb +24 -19
- data/lib/active_merchant/billing/gateways/quickpay.rb +10 -24
- data/lib/active_merchant/billing/gateways/realex.rb +7 -19
- data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +113 -0
- data/lib/active_merchant/billing/gateways/skip_jack.rb +437 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +5 -14
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +100 -39
- data/lib/active_merchant/billing/gateways/usa_epay.rb +60 -55
- data/lib/active_merchant/billing/gateways/verifi.rb +32 -39
- data/lib/active_merchant/billing/gateways/viaklix.rb +31 -37
- data/lib/active_merchant/billing/integrations.rb +2 -0
- data/lib/active_merchant/billing/integrations/bogus.rb +5 -0
- data/lib/active_merchant/billing/integrations/bogus/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/chronopay.rb +5 -0
- data/lib/active_merchant/billing/integrations/chronopay/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/gestpay.rb +5 -0
- data/lib/active_merchant/billing/integrations/gestpay/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/hi_trust.rb +26 -0
- data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +58 -0
- data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +57 -0
- data/lib/active_merchant/billing/integrations/hi_trust/return.rb +67 -0
- data/lib/active_merchant/billing/integrations/nochex.rb +5 -0
- data/lib/active_merchant/billing/integrations/nochex/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/paypal.rb +5 -0
- data/lib/active_merchant/billing/integrations/paypal/return.rb +10 -0
- data/lib/active_merchant/billing/integrations/return.rb +35 -0
- data/lib/active_merchant/billing/integrations/two_checkout.rb +5 -0
- data/lib/active_merchant/billing/integrations/two_checkout/return.rb +17 -0
- data/lib/active_merchant/billing/response.rb +12 -8
- data/lib/active_merchant/lib/posts_data.rb +39 -7
- data/lib/active_merchant/lib/requires_parameters.rb +2 -3
- data/lib/active_merchant/lib/utils.rb +18 -0
- data/lib/active_merchant/lib/validateable.rb +3 -3
- data/lib/support/gateway_support.rb +22 -9
- data/script/destroy +14 -0
- data/script/generate +7 -7
- data/test/fixtures.yml +25 -3
- data/test/remote/gateways/remote_authorize_net_test.rb +145 -0
- data/test/remote/gateways/remote_brain_tree_test.rb +118 -0
- data/test/{remote_tests → remote/gateways}/remote_card_stream_test.rb +56 -68
- data/test/{remote_tests → remote/gateways}/remote_cyber_source_test.rb +21 -32
- data/test/{remote_tests → remote/gateways}/remote_data_cash_test.rb +2 -2
- data/test/{remote_tests → remote/gateways}/remote_efsnet_test.rb +22 -34
- data/test/{remote_tests → remote/gateways}/remote_eway_test.rb +18 -15
- data/test/{remote_tests → remote/gateways}/remote_exact_test.rb +20 -19
- data/test/{remote_tests → remote/gateways}/remote_linkpoint_test.rb +31 -63
- data/test/remote/gateways/remote_moneris_test.rb +82 -0
- data/test/{remote_tests → remote/gateways}/remote_net_registry_test.rb +19 -54
- data/test/remote/gateways/remote_netbilling_test.rb +70 -0
- data/test/{remote_tests → remote/gateways}/remote_pay_junction_test.rb +41 -60
- data/test/remote/gateways/remote_pay_secure_test.rb +39 -0
- data/test/{remote_tests → remote/gateways}/remote_payflow_express_test.rb +2 -2
- data/test/{remote_tests → remote/gateways}/remote_payflow_test.rb +34 -38
- data/test/{remote_tests → remote/gateways}/remote_payflow_uk_test.rb +13 -12
- data/test/{remote_tests → remote/gateways}/remote_payment_express_test.rb +26 -36
- data/test/{remote_tests → remote/gateways}/remote_paypal_express_test.rb +3 -3
- data/test/{remote_tests → remote/gateways}/remote_paypal_test.rb +25 -21
- data/test/{remote_tests → remote/gateways}/remote_plugnpay_test.rb +18 -16
- data/test/{remote_tests → remote/gateways}/remote_protx_test.rb +33 -33
- data/test/remote/gateways/remote_psigate_test.rb +50 -0
- data/test/{remote_tests → remote/gateways}/remote_psl_card_test.rb +27 -26
- data/test/{remote_tests → remote/gateways}/remote_quickpay_test.rb +48 -48
- data/test/{remote_tests → remote/gateways}/remote_realex_test.rb +30 -33
- data/test/remote/gateways/remote_secure_pay_tech_test.rb +37 -0
- data/test/remote/gateways/remote_secure_pay_test.rb +28 -0
- data/test/remote/gateways/remote_skipjack_test.rb +105 -0
- data/test/{remote_tests → remote/gateways}/remote_trans_first_test.rb +7 -10
- data/test/remote/gateways/remote_trust_commerce_test.rb +152 -0
- data/test/{remote_tests → remote/gateways}/remote_usa_epay_test.rb +11 -22
- data/test/{remote_tests → remote/gateways}/remote_verifi_test.rb +27 -27
- data/test/{remote_tests → remote/gateways}/remote_viaklix_test.rb +8 -18
- data/test/{remote_tests → remote/integrations}/remote_gestpay_integration_test.rb +1 -1
- data/test/{remote_tests → remote/integrations}/remote_paypal_integration_test.rb +1 -1
- data/test/test_helper.rb +102 -61
- data/test/unit/avs_result_test.rb +59 -0
- data/test/unit/base_test.rb +33 -39
- data/test/unit/check_test.rb +76 -0
- data/test/unit/credit_card_formatting_test.rb +10 -15
- data/test/unit/credit_card_methods_test.rb +132 -17
- data/test/unit/credit_card_test.rb +157 -228
- data/test/unit/cvv_result_test.rb +33 -0
- data/test/unit/expiry_date_test.rb +21 -0
- data/test/unit/gateways/authorize_net_test.rb +180 -40
- data/test/unit/gateways/bogus_test.rb +2 -3
- data/test/unit/gateways/brain_tree_test.rb +63 -29
- data/test/unit/gateways/card_stream_test.rb +59 -6
- data/test/unit/gateways/cyber_source_test.rb +59 -40
- data/test/unit/gateways/data_cash_test.rb +82 -1
- data/test/unit/gateways/efsnet_test.rb +97 -44
- data/test/unit/gateways/eway_test.rb +55 -42
- data/test/unit/gateways/exact_test.rb +93 -55
- data/test/unit/gateways/gateway_test.rb +7 -0
- data/test/unit/gateways/linkpoint_test.rb +60 -58
- data/test/unit/gateways/moneris_test.rb +67 -76
- data/test/unit/gateways/net_registry_test.rb +351 -419
- data/test/unit/gateways/netbilling_test.rb +54 -0
- data/test/unit/gateways/pay_junction_test.rb +108 -46
- data/test/unit/gateways/pay_secure_test.rb +71 -0
- data/test/unit/gateways/payflow_express_test.rb +0 -8
- data/test/unit/gateways/payflow_test.rb +136 -65
- data/test/unit/gateways/payflow_uk_test.rb +0 -38
- data/test/unit/gateways/payment_express_test.rb +31 -51
- data/test/unit/gateways/paypal_express_test.rb +8 -2
- data/test/unit/gateways/paypal_test.rb +213 -54
- data/test/unit/gateways/plugnpay_test.rb +39 -32
- data/test/unit/gateways/protx_test.rb +45 -33
- data/test/unit/gateways/psigate_test.rb +146 -87
- data/test/unit/gateways/psl_card_test.rb +37 -24
- data/test/unit/gateways/quickpay_test.rb +33 -46
- data/test/unit/gateways/realex_test.rb +32 -31
- data/test/unit/gateways/secure_pay_tech_test.rb +44 -0
- data/test/unit/gateways/secure_pay_test.rb +35 -26
- data/test/unit/gateways/skip_jack_test.rb +125 -0
- data/test/unit/gateways/trans_first_test.rb +24 -37
- data/test/unit/gateways/trust_commerce_test.rb +47 -26
- data/test/unit/gateways/usa_epay_test.rb +52 -41
- data/test/unit/gateways/verifi_test.rb +41 -35
- data/test/unit/gateways/viaklix_test.rb +38 -32
- data/test/unit/generators/test_gateway_generator.rb +46 -0
- data/test/unit/generators/test_generator_helper.rb +20 -0
- data/test/unit/generators/test_integration_generator.rb +53 -0
- data/test/unit/integrations/action_view_helper_test.rb +7 -14
- data/test/unit/integrations/bogus_module_test.rb +4 -0
- data/test/unit/integrations/chronopay_module_test.rb +4 -0
- data/test/unit/integrations/gestpay_module_test.rb +4 -0
- data/test/unit/integrations/helpers/hi_trust_helper_test.rb +16 -0
- data/test/unit/integrations/hi_trust_module_test.rb +13 -0
- data/test/unit/integrations/nochex_module_test.rb +4 -0
- data/test/unit/integrations/notifications/hi_trust_notification_test.rb +38 -0
- data/test/unit/integrations/paypal_module_test.rb +4 -0
- data/test/unit/integrations/returns/chronopay_return_test.rb +11 -0
- data/test/unit/integrations/returns/gestpay_return_test.rb +10 -0
- data/test/unit/integrations/returns/hi_trust_return_test.rb +24 -0
- data/test/unit/integrations/returns/nochex_return_test.rb +10 -0
- data/test/unit/integrations/returns/paypal_return_test.rb +10 -0
- data/test/unit/integrations/returns/return_test.rb +11 -0
- data/test/unit/integrations/returns/two_checkout_return_test.rb +24 -0
- data/test/unit/integrations/two_checkout_module_test.rb +4 -0
- data/test/unit/posts_data_test.rb +86 -0
- data/test/unit/response_test.rb +15 -1
- data/test/unit/utils_test.rb +7 -0
- data/test/unit/validateable_test.rb +10 -6
- metadata +180 -142
- metadata.gz.sig +0 -0
- data/lib/active_merchant/billing/gateways/paypal/api_cert_chain.crt +0 -35
- data/script/generator/base.rb +0 -45
- data/script/generator/generator.rb +0 -24
- data/script/generator/generators/gateway/gateway_generator.rb +0 -14
- data/script/generator/generators/gateway/templates/gateway.rb +0 -73
- data/script/generator/generators/gateway/templates/gateway_test.rb +0 -41
- data/script/generator/generators/gateway/templates/remote_gateway_test.rb +0 -56
- data/script/generator/generators/integration/integration_generator.rb +0 -25
- data/script/generator/generators/integration/templates/helper.rb +0 -34
- data/script/generator/generators/integration/templates/helper_test.rb +0 -54
- data/script/generator/generators/integration/templates/integration.rb +0 -18
- data/script/generator/generators/integration/templates/module_test.rb +0 -9
- data/script/generator/generators/integration/templates/notification.rb +0 -100
- data/script/generator/generators/integration/templates/notification_test.rb +0 -41
- data/script/generator/manifest.rb +0 -20
- data/test/remote_tests/remote_authorize_net_test.rb +0 -113
- data/test/remote_tests/remote_brain_tree_test.rb +0 -78
- data/test/remote_tests/remote_moneris_test.rb +0 -110
- data/test/remote_tests/remote_psigate_test.rb +0 -87
- data/test/remote_tests/remote_secure_pay_test.rb +0 -36
- data/test/remote_tests/remote_trust_commerce_test.rb +0 -136
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
|
2
|
+
module Billing #:nodoc:
|
|
3
|
+
module Integrations #:nodoc:
|
|
4
|
+
module HiTrust
|
|
5
|
+
class Return < ActiveMerchant::Billing::Integrations::Return
|
|
6
|
+
SUCCESS = "00"
|
|
7
|
+
CODES = { "00" => "Operation completed successfully",
|
|
8
|
+
"-1" => "Unable to initialize winsock dll.",
|
|
9
|
+
"-2" => "Can't create stream socket.",
|
|
10
|
+
"-3" => "No Request Message.",
|
|
11
|
+
"-4" => "Can't connect to server.",
|
|
12
|
+
"-5" => "Send socket error.",
|
|
13
|
+
"-6" => "Couldn't receive data.",
|
|
14
|
+
"-7" => "Receive Broken message.",
|
|
15
|
+
"-8" => "Unable to initialize Envirnment.",
|
|
16
|
+
"-9" => "Can't Read Server RSA File.",
|
|
17
|
+
"-10" => "Can't Read Client RSA File.",
|
|
18
|
+
"-11" => "Web Server error.",
|
|
19
|
+
"-12" => "Receive Message type error.",
|
|
20
|
+
"-13" => "No Request Message.",
|
|
21
|
+
"-14" => "No Response Content.",
|
|
22
|
+
"-18" => "Merchant Update URL not found.",
|
|
23
|
+
"-19" => "Server URL not find Domain or IP.",
|
|
24
|
+
"-20" => "Server URL only can fill http or https.",
|
|
25
|
+
"-21" => "Server Config File open error.",
|
|
26
|
+
"-22" => "Server RSA Key File open error.",
|
|
27
|
+
"-23" => "Server RSA Key File read error.",
|
|
28
|
+
"-24" => "Server Config File have some errors, Please to check it.",
|
|
29
|
+
"-25" => "Merchant Config File open error.",
|
|
30
|
+
"-26" => "Merchant RSA Key File open error.",
|
|
31
|
+
"-27" => "Merchant RSA Key File read error.",
|
|
32
|
+
"-28" => "Merchant Config File has some errors, Please to check it.",
|
|
33
|
+
"-29" => "Server Type is unknown.",
|
|
34
|
+
"-30" => "Comm Type is unknown.",
|
|
35
|
+
"-31" => "Input Parameter [ORDERNO] is null or empty.",
|
|
36
|
+
"-32" => "Input Parameter [STOREID] is null or empty.",
|
|
37
|
+
"-33" => "Input Parameter [ORDERDESC] is null or empty.",
|
|
38
|
+
"-34" => "Input Parameter [CURRENCY] is null or empty.",
|
|
39
|
+
"-35" => "Input Parameter [AMOUNT] is null or empty.",
|
|
40
|
+
"-36" => "Input Parameter [ORDERURL] is null or empty.",
|
|
41
|
+
"-37" => "Input Parameter [RETURNURL] is null or empty.",
|
|
42
|
+
"-38" => "Input Parameter [DEPOSIT] is null or empty.",
|
|
43
|
+
"-39" => "Input Parameter [QUERYFLAG] is null or empty.",
|
|
44
|
+
"-40" => "Input Parameter [UPDATEURL] is null or empty.",
|
|
45
|
+
"-41" => "Input Parameter [MERUPDATEURL] is null or empty.",
|
|
46
|
+
"-42" => "Input Parameter [KEY] is null or empty.",
|
|
47
|
+
"-43" => "Input Parameter [MAC] is null or empty.",
|
|
48
|
+
"-44" => "Input Parameter [CIPHER] is null or empty.",
|
|
49
|
+
"-45" => "Input Parameter [TrxType] is wrong.",
|
|
50
|
+
"-100" => "TrustLink Server is closed. Or Merchant Server IP is not consistent with TrustLink Server setting.",
|
|
51
|
+
"-101" => "TrustLink Server receives NULL.",
|
|
52
|
+
"-308" => "Order Number already exists.",
|
|
53
|
+
"positive" => "Response from Bank. Please contact with Acquirer Bank Service or HiTRUST Call Center."
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
def success?
|
|
57
|
+
params['retcode'] == SUCCESS
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def message
|
|
61
|
+
CODES[ params['retcode'] ]
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require File.dirname(__FILE__) + '/nochex/helper.rb'
|
|
2
2
|
require File.dirname(__FILE__) + '/nochex/notification.rb'
|
|
3
|
+
require File.dirname(__FILE__) + '/nochex/return.rb'
|
|
3
4
|
|
|
4
5
|
module ActiveMerchant #:nodoc:
|
|
5
6
|
module Billing #:nodoc:
|
|
@@ -76,6 +77,10 @@ module ActiveMerchant #:nodoc:
|
|
|
76
77
|
def self.notification(post)
|
|
77
78
|
Notification.new(post)
|
|
78
79
|
end
|
|
80
|
+
|
|
81
|
+
def self.return(query_string)
|
|
82
|
+
Return.new(query_string)
|
|
83
|
+
end
|
|
79
84
|
end
|
|
80
85
|
end
|
|
81
86
|
end
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require 'active_merchant/billing/integrations/paypal/helper.rb'
|
|
2
2
|
require 'active_merchant/billing/integrations/paypal/notification.rb'
|
|
3
|
+
require 'active_merchant/billing/integrations/paypal/return.rb'
|
|
3
4
|
|
|
4
5
|
module ActiveMerchant #:nodoc:
|
|
5
6
|
module Billing #:nodoc:
|
|
@@ -29,6 +30,10 @@ module ActiveMerchant #:nodoc:
|
|
|
29
30
|
def self.notification(post)
|
|
30
31
|
Notification.new(post)
|
|
31
32
|
end
|
|
33
|
+
|
|
34
|
+
def self.return(query_string)
|
|
35
|
+
Return.new(query_string)
|
|
36
|
+
end
|
|
32
37
|
end
|
|
33
38
|
end
|
|
34
39
|
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
|
2
|
+
module Billing #:nodoc:
|
|
3
|
+
module Integrations #:nodoc:
|
|
4
|
+
class Return
|
|
5
|
+
attr_accessor :params
|
|
6
|
+
|
|
7
|
+
def initialize(query_string)
|
|
8
|
+
@params = parse(query_string)
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# Successful by default. Overridden in the child class
|
|
12
|
+
def success?
|
|
13
|
+
true
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def message
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def parse(query_string)
|
|
21
|
+
return {} if query_string.blank?
|
|
22
|
+
|
|
23
|
+
query_string.split('&').inject({}) do |memo, chunk|
|
|
24
|
+
next if chunk.empty?
|
|
25
|
+
key, value = chunk.split('=', 2)
|
|
26
|
+
next if key.empty?
|
|
27
|
+
value = value.nil? ? nil : CGI.unescape(value)
|
|
28
|
+
memo[CGI.unescape(key)] = value
|
|
29
|
+
memo
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require File.dirname(__FILE__) + '/two_checkout/helper.rb'
|
|
2
2
|
require File.dirname(__FILE__) + '/two_checkout/notification.rb'
|
|
3
|
+
require File.dirname(__FILE__) + '/two_checkout/return.rb'
|
|
3
4
|
|
|
4
5
|
module ActiveMerchant #:nodoc:
|
|
5
6
|
module Billing #:nodoc:
|
|
@@ -12,6 +13,10 @@ module ActiveMerchant #:nodoc:
|
|
|
12
13
|
def self.notification(post)
|
|
13
14
|
Notification.new(post)
|
|
14
15
|
end
|
|
16
|
+
|
|
17
|
+
def self.return(query_string)
|
|
18
|
+
Return.new(query_string)
|
|
19
|
+
end
|
|
15
20
|
end
|
|
16
21
|
end
|
|
17
22
|
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module ActiveMerchant #:nodoc:
|
|
2
|
+
module Billing #:nodoc:
|
|
3
|
+
module Integrations #:nodoc:
|
|
4
|
+
module TwoCheckout
|
|
5
|
+
class Return < ActiveMerchant::Billing::Integrations::Return
|
|
6
|
+
def success?
|
|
7
|
+
params['credit_card_processed'] == 'Y'
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def message
|
|
11
|
+
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
module ActiveMerchant #:nodoc:
|
|
2
2
|
module Billing #:nodoc:
|
|
3
3
|
|
|
4
|
-
class Error <
|
|
4
|
+
class Error < ActiveMerchantError #:nodoc:
|
|
5
5
|
end
|
|
6
6
|
|
|
7
7
|
class Response
|
|
8
|
-
attr_reader :params
|
|
9
|
-
|
|
10
|
-
attr_reader :test
|
|
11
|
-
attr_reader :authorization
|
|
12
|
-
|
|
8
|
+
attr_reader :params, :message, :test, :authorization, :avs_result, :cvv_result
|
|
9
|
+
|
|
13
10
|
def success?
|
|
14
11
|
@success
|
|
15
12
|
end
|
|
@@ -17,11 +14,18 @@ module ActiveMerchant #:nodoc:
|
|
|
17
14
|
def test?
|
|
18
15
|
@test
|
|
19
16
|
end
|
|
20
|
-
|
|
17
|
+
|
|
18
|
+
def fraud_review?
|
|
19
|
+
@fraud_review
|
|
20
|
+
end
|
|
21
|
+
|
|
21
22
|
def initialize(success, message, params = {}, options = {})
|
|
22
23
|
@success, @message, @params = success, message, params.stringify_keys
|
|
23
24
|
@test = options[:test] || false
|
|
24
|
-
@authorization = options[:authorization]
|
|
25
|
+
@authorization = options[:authorization]
|
|
26
|
+
@fraud_review = options[:fraud_review]
|
|
27
|
+
@avs_result = AVSResult.new(options[:avs_result]).to_hash
|
|
28
|
+
@cvv_result = CVVResult.new(options[:cvv_result]).to_hash
|
|
25
29
|
end
|
|
26
30
|
end
|
|
27
31
|
end
|
|
@@ -2,7 +2,13 @@ module ActiveMerchant #:nodoc:
|
|
|
2
2
|
class ConnectionError < ActiveMerchantError
|
|
3
3
|
end
|
|
4
4
|
|
|
5
|
+
class RetriableConnectionError < ConnectionError
|
|
6
|
+
end
|
|
7
|
+
|
|
5
8
|
module PostsData #:nodoc:
|
|
9
|
+
MAX_RETRIES = 3
|
|
10
|
+
OPEN_TIMEOUT = 60
|
|
11
|
+
READ_TIMEOUT = 60
|
|
6
12
|
|
|
7
13
|
def self.included(base)
|
|
8
14
|
base.class_inheritable_accessor :ssl_strict
|
|
@@ -10,13 +16,18 @@ module ActiveMerchant #:nodoc:
|
|
|
10
16
|
|
|
11
17
|
base.class_inheritable_accessor :pem_password
|
|
12
18
|
base.pem_password = false
|
|
19
|
+
|
|
20
|
+
base.class_inheritable_accessor :retry_safe
|
|
21
|
+
base.retry_safe = false
|
|
13
22
|
end
|
|
14
23
|
|
|
15
24
|
def ssl_post(url, data, headers = {})
|
|
16
25
|
uri = URI.parse(url)
|
|
17
26
|
|
|
18
27
|
http = Net::HTTP.new(uri.host, uri.port)
|
|
19
|
-
http.
|
|
28
|
+
http.open_timeout = OPEN_TIMEOUT
|
|
29
|
+
http.read_timeout = READ_TIMEOUT
|
|
30
|
+
http.use_ssl = true
|
|
20
31
|
|
|
21
32
|
if ssl_strict
|
|
22
33
|
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
|
@@ -36,13 +47,34 @@ module ActiveMerchant #:nodoc:
|
|
|
36
47
|
end
|
|
37
48
|
end
|
|
38
49
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
50
|
+
retry_exceptions do
|
|
51
|
+
begin
|
|
52
|
+
http.post(uri.request_uri, data, headers).body
|
|
53
|
+
rescue EOFError => e
|
|
54
|
+
raise ConnectionError, "The remote server dropped the connection"
|
|
55
|
+
rescue Errno::ECONNRESET => e
|
|
56
|
+
raise ConnectionError, "The remote server reset the connection"
|
|
57
|
+
rescue Errno::ECONNREFUSED => e
|
|
58
|
+
raise RetriableConnectionError, "The remote server refused the connection"
|
|
59
|
+
rescue Timeout::Error, Errno::ETIMEDOUT => e
|
|
60
|
+
raise ConnectionError, "The connection to the remote server timed out"
|
|
61
|
+
end
|
|
45
62
|
end
|
|
46
63
|
end
|
|
64
|
+
|
|
65
|
+
def retry_exceptions
|
|
66
|
+
retries = MAX_RETRIES
|
|
67
|
+
begin
|
|
68
|
+
yield
|
|
69
|
+
rescue RetriableConnectionError => e
|
|
70
|
+
retries -= 1
|
|
71
|
+
retry unless retries.zero?
|
|
72
|
+
raise ConnectionError, e.message
|
|
73
|
+
rescue ConnectionError
|
|
74
|
+
retries -= 1
|
|
75
|
+
retry if retry_safe && !retries.zero?
|
|
76
|
+
raise
|
|
77
|
+
end
|
|
78
|
+
end
|
|
47
79
|
end
|
|
48
80
|
end
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
module ActiveMerchant #:nodoc:
|
|
2
2
|
module RequiresParameters #:nodoc:
|
|
3
3
|
def requires!(hash, *params)
|
|
4
|
-
keys = hash.keys
|
|
5
4
|
params.each do |param|
|
|
6
5
|
if param.is_a?(Array)
|
|
7
|
-
raise ArgumentError.new("Missing required parameter: #{param.first}") unless
|
|
6
|
+
raise ArgumentError.new("Missing required parameter: #{param.first}") unless hash.has_key?(param.first)
|
|
8
7
|
|
|
9
8
|
valid_options = param[1..-1]
|
|
10
9
|
raise ArgumentError.new("Parameter: #{param.first} must be one of #{valid_options.to_sentence(:connector => 'or')}") unless valid_options.include?(hash[param.first])
|
|
11
10
|
else
|
|
12
|
-
raise ArgumentError.new("Missing required parameter: #{param}") unless
|
|
11
|
+
raise ArgumentError.new("Missing required parameter: #{param}") unless hash.has_key?(param)
|
|
13
12
|
end
|
|
14
13
|
end
|
|
15
14
|
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require 'digest/md5'
|
|
2
|
+
|
|
3
|
+
module ActiveMerchant #:nodoc:
|
|
4
|
+
module Utils #:nodoc:
|
|
5
|
+
def generate_unique_id
|
|
6
|
+
md5 = Digest::MD5.new
|
|
7
|
+
now = Time.now
|
|
8
|
+
md5 << now.to_s
|
|
9
|
+
md5 << String(now.usec)
|
|
10
|
+
md5 << String(rand(0))
|
|
11
|
+
md5 << String($$)
|
|
12
|
+
md5 << self.class.name
|
|
13
|
+
md5.hexdigest
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
module_function :generate_unique_id
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -3,8 +3,8 @@ module ActiveMerchant #:nodoc:
|
|
|
3
3
|
def valid?
|
|
4
4
|
errors.clear
|
|
5
5
|
|
|
6
|
-
before_validate if respond_to?(:before_validate)
|
|
7
|
-
validate if respond_to?(:validate)
|
|
6
|
+
before_validate if respond_to?(:before_validate, true)
|
|
7
|
+
validate if respond_to?(:validate, true)
|
|
8
8
|
|
|
9
9
|
errors.empty?
|
|
10
10
|
end
|
|
@@ -62,7 +62,7 @@ module ActiveMerchant #:nodoc:
|
|
|
62
62
|
result = []
|
|
63
63
|
|
|
64
64
|
self.each do |key, messages|
|
|
65
|
-
if key ==
|
|
65
|
+
if key == 'base'
|
|
66
66
|
result << "#{messages.first}"
|
|
67
67
|
else
|
|
68
68
|
result << "#{key.to_s.humanize} #{messages.first}"
|
|
@@ -3,25 +3,38 @@ require 'active_support'
|
|
|
3
3
|
require 'lib/active_merchant'
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
class GatewaySupport
|
|
6
|
+
class GatewaySupport #:nodoc:
|
|
7
|
+
ACTIONS = [:purchase, :authorize, :capture, :void, :credit, :recurring]
|
|
8
|
+
|
|
9
|
+
include ActiveMerchant::Billing
|
|
10
|
+
|
|
7
11
|
attr_reader :gateways
|
|
8
12
|
|
|
9
13
|
def initialize
|
|
10
|
-
@gateways =
|
|
11
|
-
ObjectSpace.each_object(Class) do |c|
|
|
12
|
-
if c.name =~ /Gateway/ && c.ancestors.reject{|a| a == c}.include?(ActiveMerchant::Billing::Gateway)
|
|
13
|
-
gateways << c
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
14
|
+
@gateways = Gateway.implementations.sort_by(&:name)
|
|
17
15
|
@gateways.delete(ActiveMerchant::Billing::BogusGateway)
|
|
18
|
-
@gateways = @gateways.sort_by(&:name)
|
|
19
16
|
end
|
|
20
17
|
|
|
21
18
|
def each_gateway
|
|
22
19
|
@gateways.each{|g| yield g }
|
|
23
20
|
end
|
|
24
21
|
|
|
22
|
+
def features
|
|
23
|
+
width = 15
|
|
24
|
+
|
|
25
|
+
print "Name".center(width + 20)
|
|
26
|
+
ACTIONS.each{|f| print "#{f.to_s.capitalize.center(width)}" }
|
|
27
|
+
puts
|
|
28
|
+
|
|
29
|
+
each_gateway do |g|
|
|
30
|
+
print "#{g.display_name.ljust(width + 20)}"
|
|
31
|
+
ACTIONS.each do |f|
|
|
32
|
+
print "#{(g.instance_methods.include?(f.to_s) ? "Y" : "N").center(width)}"
|
|
33
|
+
end
|
|
34
|
+
puts
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
25
38
|
def to_rdoc
|
|
26
39
|
each_gateway do |g|
|
|
27
40
|
puts "* {#{g.display_name}}[#{g.homepage_url}] - #{g.supported_countries.join(', ')}"
|
data/script/destroy
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
APP_ROOT = File.join(File.dirname(__FILE__), '..')
|
|
3
|
+
|
|
4
|
+
begin
|
|
5
|
+
require 'rubigen'
|
|
6
|
+
rescue LoadError
|
|
7
|
+
require 'rubygems'
|
|
8
|
+
require 'rubigen'
|
|
9
|
+
end
|
|
10
|
+
require 'rubigen/scripts/destroy'
|
|
11
|
+
|
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
|
13
|
+
RubiGen::Base.use_component_sources! [:activemerchant, :rubygems, :test_unit]
|
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
+
APP_ROOT = File.join(File.dirname(__FILE__), '..')
|
|
2
3
|
|
|
3
4
|
begin
|
|
4
|
-
require '
|
|
5
|
+
require 'rubigen'
|
|
5
6
|
rescue LoadError
|
|
6
7
|
require 'rubygems'
|
|
7
|
-
require '
|
|
8
|
+
require 'rubigen'
|
|
8
9
|
end
|
|
10
|
+
require 'rubigen/scripts/generate'
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
ActiveMerchant::Generator::Generator.run(ARGV)
|
|
14
|
-
|
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
|
13
|
+
RubiGen::Base.use_component_sources! [:activemerchant, :rubygems, :test_unit]
|
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|