activemerchant 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG +226 -0
  3. data/CONTRIBUTERS +52 -0
  4. data/README +34 -24
  5. data/Rakefile +152 -0
  6. data/gem-public_cert.pem +20 -0
  7. data/init.rb +3 -0
  8. data/lib/active_merchant.rb +3 -1
  9. data/lib/active_merchant/billing/credit_card.rb +21 -17
  10. data/lib/active_merchant/billing/credit_card_methods.rb +17 -19
  11. data/lib/active_merchant/billing/gateway.rb +160 -44
  12. data/lib/active_merchant/billing/gateways.rb +2 -15
  13. data/lib/active_merchant/billing/gateways/authorize_net.rb +21 -21
  14. data/lib/active_merchant/billing/gateways/bogus.rb +6 -6
  15. data/lib/active_merchant/billing/gateways/brain_tree.rb +191 -0
  16. data/lib/active_merchant/billing/gateways/card_stream.rb +207 -0
  17. data/lib/active_merchant/billing/gateways/cyber_source.rb +402 -0
  18. data/lib/active_merchant/billing/gateways/data_cash.rb +41 -97
  19. data/lib/active_merchant/billing/gateways/efsnet.rb +256 -0
  20. data/lib/active_merchant/billing/gateways/eway.rb +77 -29
  21. data/lib/active_merchant/billing/gateways/exact.rb +230 -0
  22. data/lib/active_merchant/billing/gateways/linkpoint.rb +6 -33
  23. data/lib/active_merchant/billing/gateways/moneris.rb +155 -125
  24. data/lib/active_merchant/billing/gateways/net_registry.rb +257 -0
  25. data/lib/active_merchant/billing/gateways/pay_junction.rb +407 -0
  26. data/lib/active_merchant/billing/gateways/payflow.rb +163 -25
  27. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +56 -38
  28. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +10 -1
  29. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +9 -0
  30. data/lib/active_merchant/billing/gateways/payflow_express.rb +36 -11
  31. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +6 -0
  32. data/lib/active_merchant/billing/gateways/payflow_uk.rb +7 -3
  33. data/lib/active_merchant/billing/gateways/payment_express.rb +261 -0
  34. data/lib/active_merchant/billing/gateways/paypal.rb +18 -4
  35. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +31 -15
  36. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +8 -0
  37. data/lib/active_merchant/billing/gateways/paypal_express.rb +33 -8
  38. data/lib/active_merchant/billing/gateways/plugnpay.rb +300 -0
  39. data/lib/active_merchant/billing/gateways/protx.rb +285 -0
  40. data/lib/active_merchant/billing/gateways/psigate.rb +13 -12
  41. data/lib/active_merchant/billing/gateways/psl_card.rb +297 -0
  42. data/lib/active_merchant/billing/gateways/quickpay.rb +197 -0
  43. data/lib/active_merchant/billing/gateways/realex.rb +212 -0
  44. data/lib/active_merchant/billing/gateways/secure_pay.rb +31 -0
  45. data/lib/active_merchant/billing/gateways/trans_first.rb +136 -0
  46. data/lib/active_merchant/billing/gateways/trust_commerce.rb +43 -20
  47. data/lib/active_merchant/billing/gateways/usa_epay.rb +6 -5
  48. data/lib/active_merchant/billing/gateways/verifi.rb +235 -0
  49. data/lib/active_merchant/billing/gateways/viaklix.rb +171 -0
  50. data/lib/active_merchant/billing/integrations/gestpay/helper.rb +0 -2
  51. data/lib/active_merchant/billing/integrations/helper.rb +8 -1
  52. data/lib/active_merchant/billing/integrations/nochex.rb +62 -1
  53. data/lib/active_merchant/billing/integrations/nochex/notification.rb +9 -16
  54. data/lib/active_merchant/billing/integrations/notification.rb +1 -1
  55. data/lib/active_merchant/billing/integrations/paypal/helper.rb +59 -46
  56. data/lib/active_merchant/billing/integrations/paypal/notification.rb +14 -47
  57. data/lib/active_merchant/lib/error.rb +4 -0
  58. data/lib/active_merchant/lib/post_data.rb +22 -0
  59. data/lib/active_merchant/lib/posts_data.rb +23 -5
  60. data/lib/active_merchant/lib/requires_parameters.rb +2 -2
  61. data/lib/active_merchant/lib/validateable.rb +1 -1
  62. data/lib/support/gateway_support.rb +45 -0
  63. data/lib/tasks/cia.rb +1 -1
  64. data/script/generate +14 -0
  65. data/script/generator/base.rb +45 -0
  66. data/script/generator/generator.rb +24 -0
  67. data/script/generator/generators/gateway/gateway_generator.rb +14 -0
  68. data/script/generator/generators/gateway/templates/gateway.rb +73 -0
  69. data/script/generator/generators/gateway/templates/gateway_test.rb +41 -0
  70. data/script/generator/generators/gateway/templates/remote_gateway_test.rb +56 -0
  71. data/script/generator/generators/integration/integration_generator.rb +25 -0
  72. data/script/generator/generators/integration/templates/helper.rb +34 -0
  73. data/script/generator/generators/integration/templates/helper_test.rb +54 -0
  74. data/script/generator/generators/integration/templates/integration.rb +18 -0
  75. data/script/generator/generators/integration/templates/module_test.rb +9 -0
  76. data/script/generator/generators/integration/templates/notification.rb +100 -0
  77. data/script/generator/generators/integration/templates/notification_test.rb +41 -0
  78. data/script/generator/manifest.rb +20 -0
  79. data/test/extra/binding_of_caller.rb +80 -0
  80. data/test/extra/breakpoint.rb +547 -0
  81. data/test/fixtures.yml +251 -0
  82. data/test/remote_tests/remote_authorize_net_test.rb +113 -0
  83. data/test/remote_tests/remote_brain_tree_test.rb +78 -0
  84. data/test/remote_tests/remote_card_stream_test.rb +160 -0
  85. data/test/remote_tests/remote_cyber_source_test.rb +130 -0
  86. data/test/remote_tests/remote_data_cash_test.rb +155 -0
  87. data/test/remote_tests/remote_efsnet_test.rb +93 -0
  88. data/test/remote_tests/remote_eway_test.rb +71 -0
  89. data/test/remote_tests/remote_exact_test.rb +59 -0
  90. data/test/remote_tests/remote_gestpay_integration_test.rb +37 -0
  91. data/test/remote_tests/remote_linkpoint_test.rb +144 -0
  92. data/test/remote_tests/remote_moneris_test.rb +110 -0
  93. data/test/remote_tests/remote_net_registry_test.rb +120 -0
  94. data/test/remote_tests/remote_pay_junction_test.rb +162 -0
  95. data/test/remote_tests/remote_payflow_express_test.rb +50 -0
  96. data/test/remote_tests/remote_payflow_test.rb +241 -0
  97. data/test/remote_tests/remote_payflow_uk_test.rb +172 -0
  98. data/test/remote_tests/remote_payment_express_test.rb +136 -0
  99. data/test/remote_tests/remote_paypal_express_test.rb +49 -0
  100. data/test/remote_tests/remote_paypal_integration_test.rb +14 -0
  101. data/test/remote_tests/remote_paypal_test.rb +163 -0
  102. data/test/remote_tests/remote_plugnpay_test.rb +70 -0
  103. data/test/remote_tests/remote_protx_test.rb +184 -0
  104. data/test/remote_tests/remote_psigate_test.rb +87 -0
  105. data/test/remote_tests/remote_psl_card_test.rb +105 -0
  106. data/test/remote_tests/remote_quickpay_test.rb +182 -0
  107. data/test/remote_tests/remote_realex_test.rb +227 -0
  108. data/test/remote_tests/remote_secure_pay_test.rb +36 -0
  109. data/test/remote_tests/remote_trans_first_test.rb +37 -0
  110. data/test/remote_tests/remote_trust_commerce_test.rb +136 -0
  111. data/test/remote_tests/remote_usa_epay_test.rb +57 -0
  112. data/test/remote_tests/remote_verifi_test.rb +107 -0
  113. data/test/remote_tests/remote_viaklix_test.rb +53 -0
  114. data/test/test_helper.rb +132 -0
  115. data/test/unit/base_test.rb +61 -0
  116. data/test/unit/country_code_test.rb +33 -0
  117. data/test/unit/country_test.rb +64 -0
  118. data/test/unit/credit_card_formatting_test.rb +24 -0
  119. data/test/unit/credit_card_methods_test.rb +37 -0
  120. data/test/unit/credit_card_test.rb +365 -0
  121. data/test/unit/gateways/authorize_net_test.rb +140 -0
  122. data/test/unit/gateways/bogus_test.rb +43 -0
  123. data/test/unit/gateways/brain_tree_test.rb +77 -0
  124. data/test/unit/gateways/card_stream_test.rb +37 -0
  125. data/test/unit/gateways/cyber_source_test.rb +151 -0
  126. data/test/unit/gateways/data_cash_test.rb +23 -0
  127. data/test/unit/gateways/efsnet_test.rb +70 -0
  128. data/test/unit/gateways/eway_test.rb +105 -0
  129. data/test/unit/gateways/exact_test.rb +118 -0
  130. data/test/unit/gateways/gateway_test.rb +24 -0
  131. data/test/unit/gateways/linkpoint_test.rb +165 -0
  132. data/test/unit/gateways/moneris_test.rb +167 -0
  133. data/test/unit/gateways/net_registry_test.rb +478 -0
  134. data/test/unit/gateways/pay_junction_test.rb +61 -0
  135. data/test/unit/gateways/payflow_express_test.rb +165 -0
  136. data/test/unit/gateways/payflow_express_uk_test.rb +14 -0
  137. data/test/unit/gateways/payflow_test.rb +230 -0
  138. data/test/unit/gateways/payflow_uk_test.rb +68 -0
  139. data/test/unit/gateways/payment_express_test.rb +215 -0
  140. data/test/unit/gateways/paypal_express_test.rb +222 -0
  141. data/test/unit/gateways/paypal_test.rb +241 -0
  142. data/test/unit/gateways/plugnpay_test.rb +79 -0
  143. data/test/unit/gateways/protx_test.rb +110 -0
  144. data/test/unit/gateways/psigate_test.rb +110 -0
  145. data/test/unit/gateways/psl_card_test.rb +51 -0
  146. data/test/unit/gateways/quickpay_test.rb +125 -0
  147. data/test/unit/gateways/realex_test.rb +150 -0
  148. data/test/unit/gateways/secure_pay_test.rb +78 -0
  149. data/test/unit/gateways/trans_first_test.rb +125 -0
  150. data/test/unit/gateways/trust_commerce_test.rb +57 -0
  151. data/test/unit/gateways/usa_epay_test.rb +117 -0
  152. data/test/unit/gateways/verifi_test.rb +91 -0
  153. data/test/unit/gateways/viaklix_test.rb +72 -0
  154. data/test/unit/integrations/action_view_helper_test.rb +54 -0
  155. data/test/unit/integrations/bogus_module_test.rb +16 -0
  156. data/test/unit/integrations/chronopay_module_test.rb +9 -0
  157. data/test/unit/integrations/gestpay_module_test.rb +10 -0
  158. data/test/unit/integrations/helpers/bogus_helper_test.rb +28 -0
  159. data/test/unit/integrations/helpers/chronopay_helper_test.rb +67 -0
  160. data/test/unit/integrations/helpers/gestpay_helper_test.rb +100 -0
  161. data/test/unit/integrations/helpers/nochex_helper_test.rb +53 -0
  162. data/test/unit/integrations/helpers/paypal_helper_test.rb +162 -0
  163. data/test/unit/integrations/helpers/two_checkout_helper_test.rb +92 -0
  164. data/test/unit/integrations/nochex_module_test.rb +9 -0
  165. data/test/unit/integrations/notifications/chronopay_notification_test.rb +66 -0
  166. data/test/unit/integrations/notifications/gestpay_notification_test.rb +60 -0
  167. data/test/unit/integrations/notifications/nochex_notification_test.rb +51 -0
  168. data/test/unit/integrations/notifications/notification_test.rb +41 -0
  169. data/test/unit/integrations/notifications/paypal_notification_test.rb +85 -0
  170. data/test/unit/integrations/notifications/two_checkout_notification_test.rb +55 -0
  171. data/test/unit/integrations/paypal_module_test.rb +24 -0
  172. data/test/unit/integrations/two_checkout_module_test.rb +9 -0
  173. data/test/unit/post_data_test.rb +55 -0
  174. data/test/unit/response_test.rb +14 -0
  175. data/test/unit/validateable_test.rb +56 -0
  176. metadata +160 -7
  177. metadata.gz.sig +0 -0
  178. data/lib/active_merchant/billing/gateways/payflow/f73e89fd.0 +0 -17
@@ -0,0 +1,57 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class TrustCommerceTest < Test::Unit::TestCase
4
+ def setup
5
+ #TCLink rescue NameError assert false, 'Trust Commerce test cases require "tclink" library from http://www.trustcommerce.com/tclink.html'
6
+
7
+ @gateway = TrustCommerceGateway.new(
8
+ :login => 'TestMerchant',
9
+ :password => 'password'
10
+ )
11
+
12
+ @creditcard = credit_card('4111111111111111')
13
+ end
14
+
15
+ def test_purchase_success
16
+ @creditcard.number = '1'
17
+
18
+ assert response = @gateway.purchase(100, @creditcard, :demo => 'y')
19
+ assert_equal Response, response.class
20
+ assert_equal '#0001', response.params['receiptid']
21
+ assert_equal true, response.success?
22
+ end
23
+
24
+ def test_purchase_error
25
+ @creditcard.number = '2'
26
+
27
+ assert response = @gateway.purchase(100, @creditcard, :demo => 'y')
28
+ assert_equal Response, response.class
29
+ assert_equal '#0001', response.params['receiptid']
30
+ assert_equal false, response.success?
31
+
32
+ end
33
+
34
+ def test_purchase_exceptions
35
+ @creditcard.number = '3'
36
+
37
+ assert_raise(Error) do
38
+ assert response = @gateway.purchase(100, @creditcard, :demo => 'y')
39
+ end
40
+ end
41
+
42
+ def test_amount_style
43
+ assert_equal '1034', @gateway.send(:amount, 1034)
44
+
45
+ assert_raise(ArgumentError) do
46
+ @gateway.send(:amount, '10.34')
47
+ end
48
+ end
49
+
50
+ def test_supported_countries
51
+ assert_equal ['US'], TrustCommerceGateway.supported_countries
52
+ end
53
+
54
+ def test_supported_card_types
55
+ assert_equal [:visa, :master, :discover, :american_express, :diners_club, :jcb], TrustCommerceGateway.supported_cardtypes
56
+ end
57
+ end
@@ -0,0 +1,117 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class UsaEpayTest < Test::Unit::TestCase
4
+ def setup
5
+ @gateway = UsaEpayGateway.new(
6
+ :login => 'LOGIN'
7
+ )
8
+
9
+ @creditcard = credit_card('4242424242424242')
10
+
11
+ @address = { :address1 => '1234 My Street',
12
+ :address2 => 'Apt 1',
13
+ :company => 'Widgets Inc',
14
+ :city => 'Ottawa',
15
+ :state => 'ON',
16
+ :zip => 'K1C2N6',
17
+ :country => 'Canada',
18
+ :phone => '(555)555-5555'
19
+ }
20
+ end
21
+
22
+ def test_successful_request
23
+ @creditcard.number = 1
24
+ assert response = @gateway.purchase(100, @creditcard, {})
25
+ assert_success response
26
+ assert_equal '5555', response.authorization
27
+ assert response.test?
28
+ end
29
+
30
+ def test_unsuccessful_request
31
+ @creditcard.number = 2
32
+ assert response = @gateway.purchase(100, @creditcard, {})
33
+ assert_failure response
34
+ assert response.test?
35
+ end
36
+
37
+ def test_request_error
38
+ @creditcard.number = 3
39
+ assert_raise(Error){ @gateway.purchase(100, @creditcard, {}) }
40
+ end
41
+
42
+ def test_address_key_prefix
43
+ assert_equal 'bill', @gateway.send(:address_key_prefix, :billing)
44
+ assert_equal 'ship', @gateway.send(:address_key_prefix, :shipping)
45
+ assert_nil @gateway.send(:address_key_prefix, :vacation)
46
+ end
47
+
48
+ def test_address_key
49
+ assert_equal :shipfname, @gateway.send(:address_key, 'ship', 'fname')
50
+ end
51
+
52
+ def test_add_address
53
+ post = {}
54
+ options = { :address => @address }
55
+ @gateway.send(:add_address, post, @creditcard, options)
56
+ assert_address(:shipping, post)
57
+ assert_equal 20, post.keys.size
58
+ end
59
+
60
+ def test_add_billing_address
61
+ post = {}
62
+ options = { :billing_address => @address }
63
+ @gateway.send(:add_address, post, @creditcard, options)
64
+ assert_address(:billing, post)
65
+ assert_equal 20, post.keys.size
66
+ end
67
+
68
+ def test_add_billing_and_shipping_addresses
69
+ post = {}
70
+ options = { :address => @address,
71
+ :billing_address => @address
72
+ }
73
+ @gateway.send(:add_address, post, @creditcard, options)
74
+ assert_address(:shipping, post)
75
+ assert_address(:billing, post)
76
+ assert_equal 20, post.keys.size
77
+ end
78
+
79
+ def test_amount_style
80
+ assert_equal '10.34', @gateway.send(:amount, 1034)
81
+
82
+ assert_raise(ArgumentError) do
83
+ @gateway.send(:amount, '10.34')
84
+ end
85
+ end
86
+
87
+ def test_supported_countries
88
+ assert_equal ['US'], UsaEpayGateway.supported_countries
89
+ end
90
+
91
+ def test_supported_card_types
92
+ assert_equal [:visa, :master, :american_express], UsaEpayGateway.supported_cardtypes
93
+ end
94
+
95
+ private
96
+ def assert_address(type, post)
97
+ prefix = key_prefix(type)
98
+ assert_equal @creditcard.first_name, post[key(prefix, 'fname')]
99
+ assert_equal @creditcard.last_name, post[key(prefix, 'lname')]
100
+ assert_equal @address[:company], post[key(prefix, 'company')]
101
+ assert_equal @address[:address1], post[key(prefix, 'street')]
102
+ assert_equal @address[:address2], post[key(prefix, 'street2')]
103
+ assert_equal @address[:city], post[key(prefix, 'city')]
104
+ assert_equal @address[:state], post[key(prefix, 'state')]
105
+ assert_equal @address[:zip], post[key(prefix, 'zip')]
106
+ assert_equal @address[:country], post[key(prefix, 'country')]
107
+ assert_equal @address[:phone], post[key(prefix, 'phone')]
108
+ end
109
+
110
+ def key_prefix(type)
111
+ @gateway.send(:address_key_prefix, type)
112
+ end
113
+
114
+ def key(prefix, key)
115
+ @gateway.send(:address_key, prefix, key)
116
+ end
117
+ end
@@ -0,0 +1,91 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class VerifiTest < Test::Unit::TestCase
4
+ include ActiveMerchant::Billing
5
+
6
+ LOGIN = 'demo'
7
+ PASSWORD = 'password'
8
+
9
+ def setup
10
+ @gateway = VerifiGateway.new(
11
+ :login => LOGIN,
12
+ :password => PASSWORD
13
+ )
14
+
15
+ @creditcard = credit_card('4111111111111111')
16
+
17
+ @options = {
18
+ :order_id => 37,
19
+ :email => "paul@domain.com",
20
+ :address => {
21
+ :address1 => '164 Waverley Street',
22
+ :address2 => 'APT #7',
23
+ :country => 'US',
24
+ :city => 'Boulder',
25
+ :state => 'CO',
26
+ :zip => 12345
27
+ }
28
+ }
29
+ end
30
+
31
+ def test_purchase_success
32
+ @creditcard.number = 1
33
+
34
+ assert response = @gateway.purchase(100, @creditcard, @options)
35
+ assert_success response
36
+ end
37
+
38
+ def test_purchase_error
39
+ @creditcard.number = 2
40
+
41
+ assert response = @gateway.purchase(10, @creditcard, @options)
42
+ assert_failure response
43
+ end
44
+
45
+ def test_purchase_exceptions
46
+ @creditcard.number = 3
47
+
48
+ assert_raise(Error) do
49
+ assert response = @gateway.purchase(Money.new(100), @creditcard, { :order_id => 1 } )
50
+ end
51
+ end
52
+
53
+ def test_amount_style
54
+ assert_equal '10.34', @gateway.send(:amount, Money.new(1034))
55
+ assert_equal '10.34', @gateway.send(:amount, 1034)
56
+
57
+ assert_raise(ArgumentError) do
58
+ @gateway.send(:amount, '10.34')
59
+ end
60
+ end
61
+
62
+ def test_add_description
63
+ result = {}
64
+ @gateway.send(:add_invoice_data, result, :description => 'My Purchase is great')
65
+ assert_equal 'My Purchase is great', result[:orderdescription]
66
+
67
+ end
68
+
69
+ def test_purchase_meets_minimum_requirements
70
+ post = VerifiGateway::VerifiPostData.new
71
+ post[:amount] = "1.01"
72
+
73
+ @gateway.send(:add_creditcard, post, @creditcard)
74
+
75
+ assert data = @gateway.send(:post_data, :authorization, post)
76
+
77
+ minimum_requirements.each do |key|
78
+ assert_not_nil(data =~ /#{key}=/)
79
+ end
80
+
81
+ end
82
+
83
+ private
84
+
85
+ def minimum_requirements
86
+ %w(type username password ccnumber ccexp amount)
87
+ end
88
+
89
+ #EXAMPLE RESPONSE: response=3&responsetext=Invalid+Card&authcode=&transactionid=12345&avsresponse=&cvvresponse=
90
+
91
+ end
@@ -0,0 +1,72 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+ class ViaklixTest < Test::Unit::TestCase
3
+ include ActiveMerchant::Billing
4
+ def setup
5
+ @gateway = ViaklixGateway.new(
6
+ :login => 'LOGIN',
7
+ :password => 'PIN'
8
+ )
9
+
10
+ @creditcard = credit_card('4242424242424242')
11
+
12
+ @options = {
13
+ :order_id => '37',
14
+ :email => "paul@domain.com",
15
+ :description => 'Test Transaction',
16
+ :address => {
17
+ :address1 => '164 Waverley Street',
18
+ :address2 => 'APT #7',
19
+ :country => 'US',
20
+ :city => 'Boulder',
21
+ :state => 'CO',
22
+ :zip => '12345'
23
+ }
24
+ }
25
+ end
26
+
27
+ def test_purchase_success
28
+ @creditcard.number = 1
29
+
30
+ assert response = @gateway.purchase(100, @creditcard)
31
+ assert_equal Response, response.class
32
+ assert_equal '#0001', response.params['receiptid']
33
+ assert_equal true, response.success?
34
+ end
35
+
36
+ def test_purchase_error
37
+ @creditcard.number = 2
38
+
39
+ assert response = @gateway.purchase(100, @creditcard, :order_id => 1)
40
+ assert_equal Response, response.class
41
+ assert_equal '#0001', response.params['receiptid']
42
+ assert_equal false, response.success?
43
+
44
+ end
45
+
46
+ def test_purchase_exceptions
47
+ @creditcard.number = 3
48
+
49
+ assert_raise(Error) do
50
+ assert response = @gateway.purchase(100, @creditcard, :order_id => 1)
51
+ end
52
+ end
53
+
54
+ def test_invalid_login
55
+ @gateway.expects(:ssl_post).returns(invalid_login_response)
56
+
57
+ assert response = @gateway.purchase(100, @creditcard, :order_id => 1)
58
+
59
+ assert_equal '7000', response.params['result']
60
+ assert_equal 'The viaKLIX ID and/or User ID supplied in the authorization request is invalid.', response.params['result_message']
61
+ assert_failure response
62
+ end
63
+
64
+ private
65
+
66
+ def invalid_login_response
67
+ <<-RESPONSE
68
+ ssl_result=7000\r
69
+ ssl_result_message=The viaKLIX ID and/or User ID supplied in the authorization request is invalid.\r
70
+ RESPONSE
71
+ end
72
+ end
@@ -0,0 +1,54 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+ begin
3
+ if respond_to? :gem
4
+ gem 'actionpack'
5
+ else
6
+ require_gem 'actionpack'
7
+ end
8
+ rescue LoadError
9
+ raise StandardError, "This test needs ActionPack installed as gem to run"
10
+ end
11
+
12
+ require 'action_controller'
13
+ require 'action_controller/test_process'
14
+ require 'active_merchant/billing/integrations/action_view_helper'
15
+
16
+ class ActionViewHelperTest < Test::Unit::TestCase
17
+ include ActiveMerchant::Billing::Integrations::ActionViewHelper
18
+ include ActionView::Helpers::FormHelper
19
+ include ActionView::Helpers::FormTagHelper
20
+ include ActionView::Helpers::UrlHelper
21
+ include ActionView::Helpers::TagHelper
22
+ include ActionView::Helpers::TextHelper
23
+
24
+ def setup
25
+ @controller = Class.new do
26
+ attr_reader :url_for_options
27
+ def url_for(options, *parameters_for_method_reference)
28
+ @url_for_options = options
29
+ end
30
+ end
31
+ @controller = @controller.new
32
+ end
33
+
34
+ def test_basic_payment_service
35
+ _erbout = ''
36
+
37
+ payment_service_for('order-1','test', :service => :bogus){}
38
+
39
+ expected = [
40
+ '<form action="http://www.bogus.com" method="post">',
41
+ '<input id="order" name="order" type="hidden" value="order-1" />',
42
+ '<input id="account" name="account" type="hidden" value="test" />',
43
+ "</form>"
44
+ ]
45
+
46
+ _erbout.each_line do |line|
47
+ assert expected.include?(line.chomp), "Failed to match #{line}"
48
+ end
49
+ end
50
+
51
+ def test_payment_service_no_block_given
52
+ assert_raise(ArgumentError){ payment_service_for }
53
+ end
54
+ end
@@ -0,0 +1,16 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class BogusModuleTest < Test::Unit::TestCase
4
+ include ActiveMerchant::Billing::Integrations
5
+
6
+ def test_notification_method
7
+ assert_instance_of Bogus::Notification, Bogus.notification('name=cody')
8
+ end
9
+
10
+ def test_service_url
11
+ new = 'http://www.unbogus.com'
12
+ assert_equal 'http://www.bogus.com', Bogus.service_url
13
+ Bogus.service_url = new
14
+ assert_equal new, Bogus.service_url
15
+ end
16
+ end
@@ -0,0 +1,9 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class ChronopayModuleTest < Test::Unit::TestCase
4
+ include ActiveMerchant::Billing::Integrations
5
+
6
+ def test_notification_method
7
+ assert_instance_of Chronopay::Notification, Chronopay.notification('name=cody')
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class GestpayModuleTest < Test::Unit::TestCase
4
+ include ActiveMerchant::Billing::Integrations
5
+
6
+ def test_notification_method
7
+ Gestpay::Notification.any_instance.expects(:ssl_get).returns('#decryptstring#a=9000000&b=PAY1_UICCODE=242*P1*PAY1_AMOUNT=1234.56*P1*PAY1_TRANSACTIONRESULT=OK*P1*PAY1_BANKTRANSACTIONID=ABCD1234*P1*PAY1_SHOPTRANSACTIONID=1000#/decryptstring#')
8
+ assert_instance_of Gestpay::Notification, Gestpay.notification('a=900000&b=F7DEB36478FD84760F9134F23C922697272D57DE6D4518EB9B4D468B769D9A3A8071B6EB160B35CB412FC1820C7CC12D17B3141855B1ED55468613702A2E213DDE9DE5B0209E13C416448AE833525959F05693172D7F0656')
9
+ end
10
+ end
@@ -0,0 +1,28 @@
1
+ require File.dirname(__FILE__) + '/../../../test_helper'
2
+
3
+ class BogusHelperTest < Test::Unit::TestCase
4
+ include ActiveMerchant::Billing::Integrations
5
+
6
+ def setup
7
+ @helper = Bogus::Helper.new('order-500','cfauser', :amount => 500, :currency => 'CAD')
8
+ end
9
+
10
+ def test_basic_helper_fields
11
+ assert_field 'order', 'order-500'
12
+ assert_field 'account', 'cfauser'
13
+ assert_field 'amount', '500'
14
+ assert_field 'currency', 'CAD'
15
+ end
16
+
17
+ def test_customer_fields
18
+ @helper.customer :first_name => 'Cody', :last_name => 'Fauser'
19
+ assert_field 'first_name', 'Cody'
20
+ assert_field 'last_name', 'Fauser'
21
+ end
22
+
23
+ def test_setting_unknown_field
24
+ fields = @helper.fields.dup
25
+ @helper.space_shuttle :name => 'Rockety'
26
+ assert_equal fields, @helper.fields
27
+ end
28
+ end