activemerchant 1.1.0 → 1.2.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 +226 -0
- data/CONTRIBUTERS +52 -0
- data/README +34 -24
- data/Rakefile +152 -0
- data/gem-public_cert.pem +20 -0
- data/init.rb +3 -0
- data/lib/active_merchant.rb +3 -1
- data/lib/active_merchant/billing/credit_card.rb +21 -17
- data/lib/active_merchant/billing/credit_card_methods.rb +17 -19
- data/lib/active_merchant/billing/gateway.rb +160 -44
- data/lib/active_merchant/billing/gateways.rb +2 -15
- data/lib/active_merchant/billing/gateways/authorize_net.rb +21 -21
- data/lib/active_merchant/billing/gateways/bogus.rb +6 -6
- data/lib/active_merchant/billing/gateways/brain_tree.rb +191 -0
- data/lib/active_merchant/billing/gateways/card_stream.rb +207 -0
- data/lib/active_merchant/billing/gateways/cyber_source.rb +402 -0
- data/lib/active_merchant/billing/gateways/data_cash.rb +41 -97
- data/lib/active_merchant/billing/gateways/efsnet.rb +256 -0
- data/lib/active_merchant/billing/gateways/eway.rb +77 -29
- data/lib/active_merchant/billing/gateways/exact.rb +230 -0
- data/lib/active_merchant/billing/gateways/linkpoint.rb +6 -33
- data/lib/active_merchant/billing/gateways/moneris.rb +155 -125
- data/lib/active_merchant/billing/gateways/net_registry.rb +257 -0
- data/lib/active_merchant/billing/gateways/pay_junction.rb +407 -0
- data/lib/active_merchant/billing/gateways/payflow.rb +163 -25
- data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +56 -38
- data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +10 -1
- data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +9 -0
- data/lib/active_merchant/billing/gateways/payflow_express.rb +36 -11
- data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +6 -0
- data/lib/active_merchant/billing/gateways/payflow_uk.rb +7 -3
- data/lib/active_merchant/billing/gateways/payment_express.rb +261 -0
- data/lib/active_merchant/billing/gateways/paypal.rb +18 -4
- data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +31 -15
- data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +8 -0
- data/lib/active_merchant/billing/gateways/paypal_express.rb +33 -8
- data/lib/active_merchant/billing/gateways/plugnpay.rb +300 -0
- data/lib/active_merchant/billing/gateways/protx.rb +285 -0
- data/lib/active_merchant/billing/gateways/psigate.rb +13 -12
- data/lib/active_merchant/billing/gateways/psl_card.rb +297 -0
- data/lib/active_merchant/billing/gateways/quickpay.rb +197 -0
- data/lib/active_merchant/billing/gateways/realex.rb +212 -0
- data/lib/active_merchant/billing/gateways/secure_pay.rb +31 -0
- data/lib/active_merchant/billing/gateways/trans_first.rb +136 -0
- data/lib/active_merchant/billing/gateways/trust_commerce.rb +43 -20
- data/lib/active_merchant/billing/gateways/usa_epay.rb +6 -5
- data/lib/active_merchant/billing/gateways/verifi.rb +235 -0
- data/lib/active_merchant/billing/gateways/viaklix.rb +171 -0
- data/lib/active_merchant/billing/integrations/gestpay/helper.rb +0 -2
- data/lib/active_merchant/billing/integrations/helper.rb +8 -1
- data/lib/active_merchant/billing/integrations/nochex.rb +62 -1
- data/lib/active_merchant/billing/integrations/nochex/notification.rb +9 -16
- data/lib/active_merchant/billing/integrations/notification.rb +1 -1
- data/lib/active_merchant/billing/integrations/paypal/helper.rb +59 -46
- data/lib/active_merchant/billing/integrations/paypal/notification.rb +14 -47
- data/lib/active_merchant/lib/error.rb +4 -0
- data/lib/active_merchant/lib/post_data.rb +22 -0
- data/lib/active_merchant/lib/posts_data.rb +23 -5
- data/lib/active_merchant/lib/requires_parameters.rb +2 -2
- data/lib/active_merchant/lib/validateable.rb +1 -1
- data/lib/support/gateway_support.rb +45 -0
- data/lib/tasks/cia.rb +1 -1
- data/script/generate +14 -0
- data/script/generator/base.rb +45 -0
- data/script/generator/generator.rb +24 -0
- data/script/generator/generators/gateway/gateway_generator.rb +14 -0
- data/script/generator/generators/gateway/templates/gateway.rb +73 -0
- data/script/generator/generators/gateway/templates/gateway_test.rb +41 -0
- data/script/generator/generators/gateway/templates/remote_gateway_test.rb +56 -0
- data/script/generator/generators/integration/integration_generator.rb +25 -0
- data/script/generator/generators/integration/templates/helper.rb +34 -0
- data/script/generator/generators/integration/templates/helper_test.rb +54 -0
- data/script/generator/generators/integration/templates/integration.rb +18 -0
- data/script/generator/generators/integration/templates/module_test.rb +9 -0
- data/script/generator/generators/integration/templates/notification.rb +100 -0
- data/script/generator/generators/integration/templates/notification_test.rb +41 -0
- data/script/generator/manifest.rb +20 -0
- data/test/extra/binding_of_caller.rb +80 -0
- data/test/extra/breakpoint.rb +547 -0
- data/test/fixtures.yml +251 -0
- data/test/remote_tests/remote_authorize_net_test.rb +113 -0
- data/test/remote_tests/remote_brain_tree_test.rb +78 -0
- data/test/remote_tests/remote_card_stream_test.rb +160 -0
- data/test/remote_tests/remote_cyber_source_test.rb +130 -0
- data/test/remote_tests/remote_data_cash_test.rb +155 -0
- data/test/remote_tests/remote_efsnet_test.rb +93 -0
- data/test/remote_tests/remote_eway_test.rb +71 -0
- data/test/remote_tests/remote_exact_test.rb +59 -0
- data/test/remote_tests/remote_gestpay_integration_test.rb +37 -0
- data/test/remote_tests/remote_linkpoint_test.rb +144 -0
- data/test/remote_tests/remote_moneris_test.rb +110 -0
- data/test/remote_tests/remote_net_registry_test.rb +120 -0
- data/test/remote_tests/remote_pay_junction_test.rb +162 -0
- data/test/remote_tests/remote_payflow_express_test.rb +50 -0
- data/test/remote_tests/remote_payflow_test.rb +241 -0
- data/test/remote_tests/remote_payflow_uk_test.rb +172 -0
- data/test/remote_tests/remote_payment_express_test.rb +136 -0
- data/test/remote_tests/remote_paypal_express_test.rb +49 -0
- data/test/remote_tests/remote_paypal_integration_test.rb +14 -0
- data/test/remote_tests/remote_paypal_test.rb +163 -0
- data/test/remote_tests/remote_plugnpay_test.rb +70 -0
- data/test/remote_tests/remote_protx_test.rb +184 -0
- data/test/remote_tests/remote_psigate_test.rb +87 -0
- data/test/remote_tests/remote_psl_card_test.rb +105 -0
- data/test/remote_tests/remote_quickpay_test.rb +182 -0
- data/test/remote_tests/remote_realex_test.rb +227 -0
- data/test/remote_tests/remote_secure_pay_test.rb +36 -0
- data/test/remote_tests/remote_trans_first_test.rb +37 -0
- data/test/remote_tests/remote_trust_commerce_test.rb +136 -0
- data/test/remote_tests/remote_usa_epay_test.rb +57 -0
- data/test/remote_tests/remote_verifi_test.rb +107 -0
- data/test/remote_tests/remote_viaklix_test.rb +53 -0
- data/test/test_helper.rb +132 -0
- data/test/unit/base_test.rb +61 -0
- data/test/unit/country_code_test.rb +33 -0
- data/test/unit/country_test.rb +64 -0
- data/test/unit/credit_card_formatting_test.rb +24 -0
- data/test/unit/credit_card_methods_test.rb +37 -0
- data/test/unit/credit_card_test.rb +365 -0
- data/test/unit/gateways/authorize_net_test.rb +140 -0
- data/test/unit/gateways/bogus_test.rb +43 -0
- data/test/unit/gateways/brain_tree_test.rb +77 -0
- data/test/unit/gateways/card_stream_test.rb +37 -0
- data/test/unit/gateways/cyber_source_test.rb +151 -0
- data/test/unit/gateways/data_cash_test.rb +23 -0
- data/test/unit/gateways/efsnet_test.rb +70 -0
- data/test/unit/gateways/eway_test.rb +105 -0
- data/test/unit/gateways/exact_test.rb +118 -0
- data/test/unit/gateways/gateway_test.rb +24 -0
- data/test/unit/gateways/linkpoint_test.rb +165 -0
- data/test/unit/gateways/moneris_test.rb +167 -0
- data/test/unit/gateways/net_registry_test.rb +478 -0
- data/test/unit/gateways/pay_junction_test.rb +61 -0
- data/test/unit/gateways/payflow_express_test.rb +165 -0
- data/test/unit/gateways/payflow_express_uk_test.rb +14 -0
- data/test/unit/gateways/payflow_test.rb +230 -0
- data/test/unit/gateways/payflow_uk_test.rb +68 -0
- data/test/unit/gateways/payment_express_test.rb +215 -0
- data/test/unit/gateways/paypal_express_test.rb +222 -0
- data/test/unit/gateways/paypal_test.rb +241 -0
- data/test/unit/gateways/plugnpay_test.rb +79 -0
- data/test/unit/gateways/protx_test.rb +110 -0
- data/test/unit/gateways/psigate_test.rb +110 -0
- data/test/unit/gateways/psl_card_test.rb +51 -0
- data/test/unit/gateways/quickpay_test.rb +125 -0
- data/test/unit/gateways/realex_test.rb +150 -0
- data/test/unit/gateways/secure_pay_test.rb +78 -0
- data/test/unit/gateways/trans_first_test.rb +125 -0
- data/test/unit/gateways/trust_commerce_test.rb +57 -0
- data/test/unit/gateways/usa_epay_test.rb +117 -0
- data/test/unit/gateways/verifi_test.rb +91 -0
- data/test/unit/gateways/viaklix_test.rb +72 -0
- data/test/unit/integrations/action_view_helper_test.rb +54 -0
- data/test/unit/integrations/bogus_module_test.rb +16 -0
- data/test/unit/integrations/chronopay_module_test.rb +9 -0
- data/test/unit/integrations/gestpay_module_test.rb +10 -0
- data/test/unit/integrations/helpers/bogus_helper_test.rb +28 -0
- data/test/unit/integrations/helpers/chronopay_helper_test.rb +67 -0
- data/test/unit/integrations/helpers/gestpay_helper_test.rb +100 -0
- data/test/unit/integrations/helpers/nochex_helper_test.rb +53 -0
- data/test/unit/integrations/helpers/paypal_helper_test.rb +162 -0
- data/test/unit/integrations/helpers/two_checkout_helper_test.rb +92 -0
- data/test/unit/integrations/nochex_module_test.rb +9 -0
- data/test/unit/integrations/notifications/chronopay_notification_test.rb +66 -0
- data/test/unit/integrations/notifications/gestpay_notification_test.rb +60 -0
- data/test/unit/integrations/notifications/nochex_notification_test.rb +51 -0
- data/test/unit/integrations/notifications/notification_test.rb +41 -0
- data/test/unit/integrations/notifications/paypal_notification_test.rb +85 -0
- data/test/unit/integrations/notifications/two_checkout_notification_test.rb +55 -0
- data/test/unit/integrations/paypal_module_test.rb +24 -0
- data/test/unit/integrations/two_checkout_module_test.rb +9 -0
- data/test/unit/post_data_test.rb +55 -0
- data/test/unit/response_test.rb +14 -0
- data/test/unit/validateable_test.rb +56 -0
- metadata +160 -7
- metadata.gz.sig +0 -0
- data/lib/active_merchant/billing/gateways/payflow/f73e89fd.0 +0 -17
@@ -0,0 +1,67 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../test_helper'
|
2
|
+
|
3
|
+
class ChronopayHelperTest < Test::Unit::TestCase
|
4
|
+
include ActiveMerchant::Billing::Integrations
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@helper = Chronopay::Helper.new('order-500','003176-0001-0001', :amount => 500, :currency => 'CAD')
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_basic_helper_fields
|
11
|
+
assert_field 'cs1', 'order-500'
|
12
|
+
assert_field 'product_id', '003176-0001-0001'
|
13
|
+
assert_field 'product_price', '500'
|
14
|
+
assert_field 'product_price_currency', 'CAD'
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_customer_fields
|
18
|
+
@helper.customer :first_name => 'Cody', :last_name => 'Fauser'
|
19
|
+
assert_field 'f_name', 'Cody'
|
20
|
+
assert_field 's_name', 'Fauser'
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_address_mapping
|
24
|
+
@helper.billing_address :country => 'CAN',
|
25
|
+
:address1 => '1 My Street',
|
26
|
+
:city => 'Ottawa',
|
27
|
+
:state => 'On',
|
28
|
+
:zip => '90210'
|
29
|
+
|
30
|
+
assert_field 'country', 'CAN'
|
31
|
+
assert_field 'street', '1 My Street'
|
32
|
+
assert_field 'state', 'On'
|
33
|
+
assert_field 'zip', '90210'
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_country_code_mapping
|
37
|
+
@helper.billing_address :country => 'CA'
|
38
|
+
assert_field 'country', 'CAN'
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_province_code_mapping_non_us
|
42
|
+
@helper.billing_address :country => 'DE', :state => 'Berlin'
|
43
|
+
assert_field 'country', 'DEU'
|
44
|
+
assert_field 'state', 'XX'
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_state_code_mapping_us
|
48
|
+
@helper.billing_address :country => 'US', :state => 'CA'
|
49
|
+
assert_field 'country', 'USA'
|
50
|
+
assert_field 'state', 'CA'
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_unknown_mapping
|
54
|
+
assert_nothing_raised do
|
55
|
+
@helper.company_address :address => '500 Dwemthy Fox Road'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_setting_invalid_address_field
|
60
|
+
fields = @helper.fields.dup
|
61
|
+
@helper.billing_address :street => 'My Street'
|
62
|
+
|
63
|
+
# Will still set the state code to 'XX'
|
64
|
+
fields['state'] = 'XX'
|
65
|
+
assert_equal fields, @helper.fields
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../test_helper'
|
2
|
+
|
3
|
+
class GestpayHelperTest < Test::Unit::TestCase
|
4
|
+
include ActiveMerchant::Billing::Integrations
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@helper = Gestpay::Helper.new('order-500','1234567', :amount => '5.00', :currency => 'EUR')
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_basic_helper_fields
|
11
|
+
assert_field 'ShopLogin', '1234567'
|
12
|
+
assert_field 'PAY1_AMOUNT', '5.00'
|
13
|
+
assert_field 'PAY1_SHOPTRANSACTIONID', 'order-500'
|
14
|
+
assert_field 'PAY1_UICCODE', '242'
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_italian_currency
|
18
|
+
@helper = Gestpay::Helper.new('order-500','1234567', :amount => '5.00', :currency => 'ITL')
|
19
|
+
assert_field 'PAY1_UICCODE', '18'
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_invalid_currency
|
23
|
+
assert_raise(StandardError) do
|
24
|
+
Gestpay::Helper.new('order-500','1234567', :amount => '5.00', :currency => 'CAD')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_customer_fields
|
29
|
+
@helper.customer :first_name => 'Cody', :last_name => 'Fauser', :email => 'cody@example.com'
|
30
|
+
assert_field 'PAY1_CHNAME', 'Cody Fauser'
|
31
|
+
assert_field 'PAY1_CHEMAIL', 'cody@example.com'
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_get_encryption_string
|
35
|
+
@helper.expects(:ssl_get).returns(encrypted_string_response)
|
36
|
+
assert_equal encrypted_string, @helper.send(:get_encrypted_string)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_get_encryption_string_fails
|
40
|
+
@helper.expects(:ssl_get).returns('#error#1132-Not accepted call: shop is not in active state#/error#\r\n')
|
41
|
+
|
42
|
+
assert_raise(StandardError) do
|
43
|
+
@helper.send(:get_encrypted_string)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_get_encryption_string_returns_empty_response
|
48
|
+
@helper.expects(:ssl_get).returns('')
|
49
|
+
|
50
|
+
assert_raise(StandardError) do
|
51
|
+
@helper.send(:get_encrypted_string)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_form_fields
|
56
|
+
@helper.expects(:ssl_get).returns(encrypted_string_response)
|
57
|
+
assert_equal '1234567', @helper.form_fields['a']
|
58
|
+
assert_equal encrypted_string, @helper.form_fields['b']
|
59
|
+
end
|
60
|
+
|
61
|
+
# Doesn't do any address mapping
|
62
|
+
def test_address_mapping
|
63
|
+
assert_nothing_raised do
|
64
|
+
@helper.billing_address :address1 => '1 My Street',
|
65
|
+
:address2 => '',
|
66
|
+
:city => 'Leeds',
|
67
|
+
:state => 'Yorkshire',
|
68
|
+
:zip => 'LS2 7EE',
|
69
|
+
:country => 'CA'
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def test_unknown_address_mapping
|
74
|
+
total_fields = @helper.fields.size
|
75
|
+
@helper.billing_address :farm => 'CA'
|
76
|
+
assert_equal total_fields, @helper.fields.size
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_unknown_mapping
|
80
|
+
assert_nothing_raised do
|
81
|
+
@helper.company_address :address => '500 Dwemthy Fox Road'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_setting_invalid_address_field
|
86
|
+
fields = @helper.fields.dup
|
87
|
+
@helper.billing_address :street => 'My Street'
|
88
|
+
assert_equal fields, @helper.fields
|
89
|
+
end
|
90
|
+
|
91
|
+
private
|
92
|
+
|
93
|
+
def encrypted_string_response
|
94
|
+
'#cryptstring#F7DEB36478FD84760F9134F23C922697272D57DE6D4518EB9B4D468B769D9A3A8071B6EB160B35CB412FC1820C7CC12D17B3141855B1ED55468613702A2E213DDE9DE5B0209E13C416448AE833525959F05693172D7F0656#/cryptstring#'
|
95
|
+
end
|
96
|
+
|
97
|
+
def encrypted_string
|
98
|
+
'F7DEB36478FD84760F9134F23C922697272D57DE6D4518EB9B4D468B769D9A3A8071B6EB160B35CB412FC1820C7CC12D17B3141855B1ED55468613702A2E213DDE9DE5B0209E13C416448AE833525959F05693172D7F0656'
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../test_helper'
|
2
|
+
|
3
|
+
class NochexHelperTest < Test::Unit::TestCase
|
4
|
+
include ActiveMerchant::Billing::Integrations
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@helper = Nochex::Helper.new('order-500','cody@example.com', :amount => 500, :currency => 'GBP')
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_basic_helper_fields
|
11
|
+
assert_field 'email', 'cody@example.com'
|
12
|
+
|
13
|
+
# Nochex requires 2 decimal places on the amount
|
14
|
+
assert_field 'amount', '5.00'
|
15
|
+
assert_field 'ordernumber', 'order-500'
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_customer_fields
|
19
|
+
@helper.customer :first_name => 'Cody', :last_name => 'Fauser', :email => 'cody@example.com'
|
20
|
+
assert_field 'firstname', 'Cody'
|
21
|
+
assert_field 'lastname', 'Fauser'
|
22
|
+
assert_field 'email_address_sender', 'cody@example.com'
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_address_mapping
|
26
|
+
@helper.billing_address :address1 => '1 My Street',
|
27
|
+
:city => 'Leeds',
|
28
|
+
:state => 'Yorkshire',
|
29
|
+
:zip => 'LS2 7EE'
|
30
|
+
|
31
|
+
assert_field 'firstline', '1 My Street'
|
32
|
+
assert_field 'town', 'Leeds'
|
33
|
+
assert_field 'county', 'Yorkshire'
|
34
|
+
assert_field 'postcode', 'LS2 7EE'
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_unknown_address_mapping
|
38
|
+
@helper.billing_address :country => 'CA'
|
39
|
+
assert_equal 3, @helper.fields.size
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_unknown_mapping
|
43
|
+
assert_nothing_raised do
|
44
|
+
@helper.company_address :address => '500 Dwemthy Fox Road'
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_setting_invalid_address_field
|
49
|
+
fields = @helper.fields.dup
|
50
|
+
@helper.billing_address :street => 'My Street'
|
51
|
+
assert_equal fields, @helper.fields
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,162 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../test_helper'
|
2
|
+
|
3
|
+
class PaypalHelperTest < Test::Unit::TestCase
|
4
|
+
include ActiveMerchant::Billing::Integrations
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@helper = Paypal::Helper.new(1,'cody@example.com', :amount => 500, :currency => 'CAD')
|
8
|
+
@url = 'http://example.com'
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_static_fields
|
12
|
+
assert_field 'cmd', '_ext-enter'
|
13
|
+
assert_field 'redirect_cmd', '_xclick'
|
14
|
+
assert_field 'quantity', '1'
|
15
|
+
assert_field 'item_name', 'Store purchase'
|
16
|
+
assert_field 'no_shipping', '1'
|
17
|
+
assert_field 'no_note', '1'
|
18
|
+
assert_field 'charset', 'utf-8'
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_basic_helper_fields
|
22
|
+
assert_field 'item_number', '1'
|
23
|
+
assert_field 'custom', '1'
|
24
|
+
assert_field 'business', 'cody@example.com'
|
25
|
+
assert_field 'amount', '500'
|
26
|
+
assert_field 'currency_code', 'CAD'
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_invoice
|
30
|
+
@helper.invoice = 'Shopify shirt'
|
31
|
+
assert_field 'invoice', 'Shopify shirt'
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_notification_url
|
35
|
+
@helper.notify_url = @url
|
36
|
+
assert_field 'notify_url', @url
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_return_url
|
40
|
+
@helper.return_url = @url
|
41
|
+
assert_field 'return', @url
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_cancel_return_url
|
45
|
+
@helper.cancel_return_url = @url
|
46
|
+
assert_field 'cancel_return', @url
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_customer_fields
|
50
|
+
@helper.customer :first_name => 'Cody',
|
51
|
+
:last_name => 'Fauser',
|
52
|
+
:email => 'cody@example.com'
|
53
|
+
|
54
|
+
assert_field 'first_name', 'Cody'
|
55
|
+
assert_field 'last_name', 'Fauser'
|
56
|
+
assert_field 'email', 'cody@example.com'
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_shipping_address
|
60
|
+
@helper.shipping_address :country => 'CA',
|
61
|
+
:address1 => '1 My Street',
|
62
|
+
:city => 'Ottawa',
|
63
|
+
:zip => '90210',
|
64
|
+
:phone => '(555)123-4567'
|
65
|
+
|
66
|
+
assert_field 'country', 'CA'
|
67
|
+
assert_field 'address1', '1 My Street'
|
68
|
+
assert_field 'zip', '90210'
|
69
|
+
assert_field 'night_phone_a', '555'
|
70
|
+
assert_field 'night_phone_b', '123'
|
71
|
+
assert_field 'night_phone_c', '4567'
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_phone_parsing
|
75
|
+
@helper.shipping_address :phone => '111-222-3333'
|
76
|
+
|
77
|
+
assert_field 'night_phone_a', '111'
|
78
|
+
assert_field 'night_phone_b', '222'
|
79
|
+
assert_field 'night_phone_c', '3333'
|
80
|
+
end
|
81
|
+
|
82
|
+
|
83
|
+
def test_province
|
84
|
+
@helper.shipping_address :country => 'CA',
|
85
|
+
:state => 'On'
|
86
|
+
|
87
|
+
assert_field 'country', 'CA'
|
88
|
+
assert_field 'state', 'Ontario'
|
89
|
+
end
|
90
|
+
|
91
|
+
def test_state
|
92
|
+
@helper.shipping_address :country => 'US',
|
93
|
+
:state => 'TX'
|
94
|
+
|
95
|
+
assert_field 'country', 'US'
|
96
|
+
assert_field 'state', 'TX'
|
97
|
+
end
|
98
|
+
|
99
|
+
def test_shipping
|
100
|
+
@helper.shipping '7.99'
|
101
|
+
assert_field 'shipping', '7.99'
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_tax
|
105
|
+
@helper.tax '14.99'
|
106
|
+
assert_field 'tax', '14.99'
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_country_code
|
110
|
+
@helper.shipping_address :country => 'CAN'
|
111
|
+
assert_field 'country', 'CA'
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_setting_invalid_address_field
|
115
|
+
fields = @helper.fields.dup
|
116
|
+
fields["state"] = 'N/A'
|
117
|
+
|
118
|
+
@helper.shipping_address :street => 'My Street'
|
119
|
+
assert_equal fields, @helper.fields
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_setting_item_name
|
123
|
+
@helper.item_name = 'Really Cool Gizmo'
|
124
|
+
assert_field 'item_name', 'Really Cool Gizmo'
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_setting_quantity
|
128
|
+
@helper.quantity = '10'
|
129
|
+
assert_field 'quantity', '10'
|
130
|
+
end
|
131
|
+
|
132
|
+
def test_setting_no_shipping
|
133
|
+
@helper.no_shipping = '0'
|
134
|
+
assert_field 'no_shipping', '0'
|
135
|
+
end
|
136
|
+
|
137
|
+
def test_setting_no_note
|
138
|
+
@helper.no_note = '0'
|
139
|
+
assert_field 'no_note', '0'
|
140
|
+
end
|
141
|
+
|
142
|
+
def test_uk_shipping_address_with_no_state
|
143
|
+
@helper.shipping_address :country => 'GB',
|
144
|
+
:state => ''
|
145
|
+
|
146
|
+
assert_field 'state', 'N/A'
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_default_bn
|
150
|
+
assert_field 'bn', ActiveMerchant::Billing::Integrations::Helper.application_id
|
151
|
+
end
|
152
|
+
|
153
|
+
def test_override_bn
|
154
|
+
identifier = 'CodeGenies_ShoppingCart_IC_CA'
|
155
|
+
|
156
|
+
Paypal::Helper.application_id = identifier
|
157
|
+
|
158
|
+
@helper = Paypal::Helper.new(1,'cody@example.com', :amount => 500, :currency => 'CAD')
|
159
|
+
assert_field 'bn', identifier
|
160
|
+
end
|
161
|
+
|
162
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../test_helper'
|
2
|
+
|
3
|
+
class TwoCheckoutHelperTest < Test::Unit::TestCase
|
4
|
+
include ActiveMerchant::Billing::Integrations
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@helper = TwoCheckout::Helper.new('order-500','cody@example.com', :amount => '5.00', :currency => 'USD')
|
8
|
+
end
|
9
|
+
|
10
|
+
def teardown
|
11
|
+
ActiveMerchant::Billing::Base.integration_mode = :test
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_basic_helper_fields
|
15
|
+
assert_field 'sid', 'cody@example.com'
|
16
|
+
|
17
|
+
assert_field 'total', '5.00'
|
18
|
+
assert_field 'cart_order_id', 'order-500'
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_customer_fields
|
22
|
+
@helper.customer :first_name => 'Cody', :last_name => 'Fauser', :email => 'cody@example.com', :phone => '(555)555-5555'
|
23
|
+
assert_field 'card_holder_name', 'Cody Fauser'
|
24
|
+
assert_field 'email', 'cody@example.com'
|
25
|
+
assert_field 'phone', '(555)555-5555'
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_address_mapping
|
29
|
+
@helper.billing_address :address1 => '1 My Street',
|
30
|
+
:address2 => 'Apt. 1',
|
31
|
+
:city => 'Leeds',
|
32
|
+
:state => 'Yorkshire',
|
33
|
+
:zip => 'LS2 7EE',
|
34
|
+
:country => 'CA'
|
35
|
+
|
36
|
+
assert_field 'street_address', '1 My Street'
|
37
|
+
assert_field 'street_address2', 'Apt. 1'
|
38
|
+
assert_field 'city', 'Leeds'
|
39
|
+
assert_field 'state', 'Yorkshire'
|
40
|
+
assert_field 'zip', 'LS2 7EE'
|
41
|
+
assert_field 'country', 'CA'
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_shipping_address
|
45
|
+
@helper.shipping_address :address1 => '1 My Street',
|
46
|
+
:address2 => 'Apt. 1',
|
47
|
+
:city => 'London',
|
48
|
+
:state => 'Whales',
|
49
|
+
:zip => 'LS2 7E1',
|
50
|
+
:country => 'UK'
|
51
|
+
|
52
|
+
assert_field 'ship_city', 'London'
|
53
|
+
assert_field 'ship_street_address', '1 My Street'
|
54
|
+
assert_field 'ship_state', 'Whales'
|
55
|
+
assert_field 'ship_zip', 'LS2 7E1'
|
56
|
+
assert_field 'ship_country', 'UK'
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_unknown_address_mapping
|
60
|
+
@helper.billing_address :farm => 'CA'
|
61
|
+
assert_equal 5, @helper.fields.size
|
62
|
+
end
|
63
|
+
|
64
|
+
def test_unknown_mapping
|
65
|
+
assert_nothing_raised do
|
66
|
+
@helper.company_address :address => '500 Dwemthy Fox Road'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_setting_invalid_address_field
|
71
|
+
fields = @helper.fields.dup
|
72
|
+
@helper.billing_address :street => 'My Street'
|
73
|
+
assert_equal fields, @helper.fields
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_test_mode
|
77
|
+
@helper = TwoCheckout::Helper.new('order-500','cody@example.com', :amount => '5.00', :currency => 'USD')
|
78
|
+
assert_field 'demo', 'Y'
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_force_test_mode
|
82
|
+
ActiveMerchant::Billing::Base.integration_mode = :production
|
83
|
+
@helper = TwoCheckout::Helper.new('order-500','cody@example.com', :amount => '5.00', :currency => 'USD', :test => true)
|
84
|
+
assert_field 'demo', 'Y'
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_production_mode
|
88
|
+
ActiveMerchant::Billing::Base.integration_mode = :production
|
89
|
+
@helper = TwoCheckout::Helper.new('order-500','cody@example.com', :amount => '5.00', :currency => 'USD')
|
90
|
+
assert !@helper.fields.has_key?("demo")
|
91
|
+
end
|
92
|
+
end
|