activemerchant 1.1.0 → 1.2.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.
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,23 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class DataCashTest < Test::Unit::TestCase
4
+ # 100 Cents
5
+ AMOUNT = 100
6
+
7
+ def setup
8
+ @gateway = DataCashGateway.new(
9
+ :login => 'LOGIN',
10
+ :password => 'PASSWORD'
11
+ )
12
+
13
+ @creditcard = credit_card('4242424242424242')
14
+ end
15
+
16
+ def test_supported_countries
17
+ assert_equal ['GB'], DataCashGateway.supported_countries
18
+ end
19
+
20
+ def test_supported_card_types
21
+ assert_equal [ :visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro, :switch, :solo, :laser ], DataCashGateway.supported_cardtypes
22
+ end
23
+ end
@@ -0,0 +1,70 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class EfsnetTest < Test::Unit::TestCase
4
+ AMOUNT = 100
5
+
6
+ def setup
7
+ @gateway = EfsnetGateway.new(
8
+ :login => 'LOGIN',
9
+ :password => 'PASSWORD'
10
+ )
11
+
12
+ @creditcard = credit_card('4242424242424242')
13
+
14
+ @address = { :address1 => '1234 My Street',
15
+ :address2 => 'Apt 1',
16
+ :company => 'Widgets Inc',
17
+ :city => 'Ottawa',
18
+ :state => 'ON',
19
+ :zip => 'K1C2N6',
20
+ :country => 'Canada',
21
+ :phone => '(555)555-5555'
22
+ }
23
+ @options = {:order_id => 1}
24
+ end
25
+
26
+ def test_successful_request
27
+ @creditcard.number = 1
28
+ assert response = @gateway.purchase(AMOUNT, @creditcard, @options)
29
+ assert_success response
30
+ assert_equal '5555', response.authorization
31
+ assert response.test?
32
+ end
33
+
34
+ def test_unsuccessful_request
35
+ @creditcard.number = 2
36
+ assert response = @gateway.purchase(AMOUNT, @creditcard, @options)
37
+ assert_failure response
38
+ assert response.test?
39
+ end
40
+
41
+ def test_request_error
42
+ @creditcard.number = 3
43
+ assert_raise(Error){ @gateway.purchase(AMOUNT, @creditcard, @options) }
44
+ end
45
+
46
+ def test_authorize_is_valid_xml
47
+ params = {
48
+ :order_id => "order1",
49
+ :transaction_amount => "1.01",
50
+ :account_number => "4242424242424242",
51
+ :expiration_month => "12",
52
+ :expiration_year => "2029",
53
+ }
54
+
55
+ assert data = @gateway.send(:post_data, :credit_card_authorize, params)
56
+ assert REXML::Document.new(data)
57
+ end
58
+
59
+ def test_settle_is_valid_xml
60
+ params = {
61
+ :order_id => "order1",
62
+ :transaction_amount => "1.01",
63
+ :original_transaction_amount => "1.01",
64
+ :original_transaction_id => "1",
65
+ }
66
+
67
+ assert data = @gateway.send(:post_data, :credit_card_settle, params)
68
+ assert REXML::Document.new(data)
69
+ end
70
+ end
@@ -0,0 +1,105 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class EwayTest < Test::Unit::TestCase
4
+ def setup
5
+ @gateway = EwayGateway.new(
6
+ :login => '87654321'
7
+ )
8
+
9
+ @creditcard = credit_card('4646464646464646')
10
+
11
+ @test_params_success = {
12
+ :order_id => '1230123',
13
+ :email => 'bob@testbob.com',
14
+ :address => {
15
+ :address1 => '1234 First St.',
16
+ :address2 => 'Apt. 1',
17
+ :city => 'Melbourne',
18
+ :state => 'ACT',
19
+ :country => 'AU',
20
+ :zip => '12345'
21
+ },
22
+ :description => 'purchased items'
23
+ }
24
+
25
+ @xml_test_parameters = {
26
+ :CustomerID => @test_params_success[:login],
27
+ :CustomerInvoiceRef => @test_params_success[:order_id],
28
+ :TotalAmount => 100,
29
+ :CardNumber => @creditcard.number,
30
+ :CardExpiryMonth => sprintf("%.2i", @creditcard.month),
31
+ :CardExpiryYear => sprintf("%.4i", @creditcard.year)[-2..-1],
32
+ :CustomerFirstName => @creditcard.first_name,
33
+ :CustomerLastName => @creditcard.last_name,
34
+ :CustomerEmail => @test_params_success[:email],
35
+ :CustomerAddress => @test_params_success[:address][:address1],
36
+ :CustomerPostcode => @test_params_success[:address][:zip],
37
+ :CustomerInvoiceDescription => @test_params_success[:description],
38
+ :CardHoldersName => @creditcard.name,
39
+ :TrxnNumber => @test_params_success[:order_id],
40
+ :Option1 => '',
41
+ :Option2 => '',
42
+ :Option3 => ''
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, @test_params_success)
51
+ end
52
+ end
53
+
54
+ def test_amount_style
55
+ assert_equal '1034', @gateway.send(:amount, 1034)
56
+
57
+ assert_raise(ArgumentError) do
58
+ @gateway.send(:amount, '10.34')
59
+ end
60
+ end
61
+
62
+ def test_purchase_is_valid_xml
63
+ assert data = @gateway.send(:post_data, @xml_test_parameters)
64
+ assert REXML::Document.new(data)
65
+ end
66
+
67
+ def test_ensure_does_not_respond_to_authorize
68
+ assert !@gateway.respond_to?(:authorize)
69
+ end
70
+
71
+ def test_ensure_does_not_respond_to_capture
72
+ assert !@gateway.respond_to?(:capture)
73
+ end
74
+
75
+ def test_test_url_without_cvn
76
+ assert_equal EwayGateway::TEST_URL, @gateway.send(:gateway_url, false, true)
77
+ end
78
+
79
+ def test_test_url_with_cvn
80
+ assert_equal EwayGateway::TEST_CVN_URL, @gateway.send(:gateway_url, true, true)
81
+ end
82
+
83
+ def test_live_url_without_cvn
84
+ assert_equal EwayGateway::LIVE_URL, @gateway.send(:gateway_url, false, false)
85
+ end
86
+
87
+ def test_live_url_with_cvn
88
+ assert_equal EwayGateway::LIVE_CVN_URL, @gateway.send(:gateway_url, true, false)
89
+ end
90
+
91
+ def test_add_address
92
+ post = {}
93
+ @gateway.send(:add_address, post, @test_params_success)
94
+ assert_equal '1234 First St., Apt. 1, Melbourne, ACT, AU', post[:CustomerAddress]
95
+ assert_equal @test_params_success[:address][:zip], post[:CustomerPostcode]
96
+ end
97
+
98
+ private
99
+
100
+ def xml_purchase_fixture
101
+ %q{<ewaygateway><ewayCustomerID>87654321</ewayCustomerID><ewayOption3></ewayOption3><ewayCustomerFirstName>Longbob</ewayCustomerFirstName><ewayCustomerAddress>47 Bobway, Bobville, WA, Australia</ewayCustomerAddress><ewayCustomerInvoiceRef>1230123</ewayCustomerInvoiceRef><ewayCardHoldersName>Longbob Longsen</ewayCardHoldersName><ewayTotalAmount>100</ewayTotalAmount><ewayTrxnNumber>1230123</ewayTrxnNumber><ewayCustomerLastName>Longsen</ewayCustomerLastName><ewayCustomerPostcode>2000</ewayCustomerPostcode><ewayCardNumber>4646464646464646</ewayCardNumber><ewayOption1></ewayOption1><ewayCardExpiryMonth>08</ewayCardExpiryMonth><ewayOption2></ewayOption2><ewayCustomerEmail>bob@testbob.com</ewayCustomerEmail><ewayCustomerInvoiceDescription>purchased items</ewayCustomerInvoiceDescription><ewayCardExpiryYear>07</ewayCardExpiryYear></ewaygateway>}
102
+ end
103
+ end
104
+
105
+
@@ -0,0 +1,118 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class ExactTest < Test::Unit::TestCase
4
+ def setup
5
+ @gateway = ExactGateway.new( :login => "A00427-01",
6
+ :password => "testus" )
7
+
8
+ @credit_card = credit_card("4111111111111111")
9
+
10
+ @options = { :address => { :address1 => "1234 Testing Ave.",
11
+ :zip => "55555" } }
12
+ end
13
+
14
+ def test_successful_request
15
+ @credit_card.number = "1"
16
+ assert response = @gateway.purchase(100, @credit_card, {})
17
+ assert_success response
18
+ assert_equal '5555', response.authorization
19
+ assert response.test?
20
+ end
21
+
22
+ def test_unsuccessful_request
23
+ @credit_card.number = "2"
24
+ assert response = @gateway.purchase(100, @credit_card, {})
25
+ assert_failure response
26
+ assert response.test?
27
+ end
28
+
29
+ def test_request_error
30
+ @credit_card.number = "3"
31
+ assert_raise(Error){ @gateway.purchase(100, @credit_card, {}) }
32
+ end
33
+
34
+ def test_expdate
35
+ assert_equal( "%02d%s" % [ @credit_card.month,
36
+ @credit_card.year.to_s[-2..-1] ],
37
+ @gateway.send(:expdate, @credit_card) )
38
+ end
39
+
40
+ def test_successful_purchase
41
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
42
+ assert response = @gateway.purchase(100, @credit_card, {})
43
+ assert_success response
44
+ assert_equal 'ET0426;80928103', response.authorization
45
+ assert response.test?
46
+ assert_equal 'Transaction Normal - VER UNAVAILABLE', response.message
47
+
48
+ ExactGateway::SENSITIVE_FIELDS.each{ |f| assert !response.params.has_key?(f.to_s) }
49
+ end
50
+
51
+ def test_soap_fault
52
+ @gateway.expects(:ssl_post).returns(soap_fault_response)
53
+ assert response = @gateway.purchase(100, @credit_card, {})
54
+ assert_failure response
55
+ assert response.test?
56
+ assert_equal 'Unable to handle request without a valid action parameter. Please supply a valid soap action.', response.message
57
+ end
58
+
59
+ def test_supported_countries
60
+ assert_equal ['CA', 'US'], ExactGateway.supported_countries
61
+ end
62
+
63
+ def test_supported_card_types
64
+ assert_equal [:visa, :master, :american_express, :jcb, :discover], ExactGateway.supported_cardtypes
65
+ end
66
+
67
+ private
68
+ def successful_purchase_response
69
+ <<-RESPONSE
70
+ <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/" xmlns:types="http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/encodedTypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><q1:SendAndCommitResponse xmlns:q1="http://secure2.e-xact.com/vplug-in/transaction/rpc-enc/Response"><SendAndCommitResult href="#id1" /></q1:SendAndCommitResponse><types:TransactionResult id="id1" xsi:type="types:TransactionResult"><ExactID xsi:type="xsd:string">A00427-01</ExactID><Password xsi:type="xsd:string">#######</Password><Transaction_Type xsi:type="xsd:string">00</Transaction_Type><DollarAmount xsi:type="xsd:string">1</DollarAmount><SurchargeAmount xsi:type="xsd:string">0</SurchargeAmount><Card_Number xsi:type="xsd:string">4111111111111111</Card_Number><Verification_Str2 xsi:type="xsd:string">123</Verification_Str2><Transaction_Tag xsi:type="xsd:string">80928103</Transaction_Tag><Authorization_Num xsi:type="xsd:string">ET0426</Authorization_Num><Expiry_Date xsi:type="xsd:string">0909</Expiry_Date><CardHoldersName xsi:type="xsd:string">Active Merchant</CardHoldersName><CVD_Presence_Ind xsi:type="xsd:string">0</CVD_Presence_Ind><ZipCode xsi:type="xsd:string">55555</ZipCode><Secure_AuthRequired xsi:type="xsd:string">0</Secure_AuthRequired><Secure_AuthResult xsi:type="xsd:string">0</Secure_AuthResult><Ecommerce_Flag xsi:type="xsd:string">0</Ecommerce_Flag><CAVV_Algorithm xsi:type="xsd:string">0</CAVV_Algorithm><Language xsi:type="xsd:string">0</Language><LogonMessage xsi:type="xsd:string">Processed by:
71
+ E-xact Transaction Gateway :- Version 8.4.0 B19
72
+ Copyright 2006
73
+ {34:2652}</LogonMessage><Error_Number xsi:type="xsd:string">0</Error_Number><Error_Description xsi:type="xsd:string" /><Transaction_Error xsi:type="xsd:boolean">false</Transaction_Error><Transaction_Approved xsi:type="xsd:boolean">true</Transaction_Approved><EXact_Resp_Code xsi:type="xsd:string">00</EXact_Resp_Code><EXact_Message xsi:type="xsd:string">Transaction Normal</EXact_Message><Bank_Resp_Code xsi:type="xsd:string">00</Bank_Resp_Code><Bank_Message xsi:type="xsd:string">VER UNAVAILABLE </Bank_Message><SequenceNo xsi:type="xsd:string">431</SequenceNo><AVS xsi:type="xsd:string">U</AVS><Retrieval_Ref_No xsi:type="xsd:string">200703280426</Retrieval_Ref_No><MerchantName xsi:type="xsd:string">E-xact ConnectionShop</MerchantName><MerchantAddress xsi:type="xsd:string">Suite 304 - 134 Abbott Street</MerchantAddress><MerchantCity xsi:type="xsd:string">Vancouver</MerchantCity><MerchantProvince xsi:type="xsd:string">BC</MerchantProvince><MerchantCountry xsi:type="xsd:string">Canada</MerchantCountry><MerchantPostal xsi:type="xsd:string">V6B 2K4</MerchantPostal><MerchantURL xsi:type="xsd:string">www.e-xact.com</MerchantURL><CTR xsi:type="xsd:string">========== TRANSACTION RECORD =========
74
+
75
+ E-xact ConnectionShop
76
+ Suite 304 - 134 Abbott Street
77
+ Vancouver, BC V6B 2K4
78
+ www.e-xact.com
79
+
80
+ TYPE: Purchase
81
+
82
+ ACCT: Visa $1.00 USD
83
+
84
+ CARD NUMBER : ############1111
85
+ TRANS. REF. :
86
+ CARD HOLDER : Active Merchant
87
+ EXPIRY DATE : xx/xx
88
+ DATE/TIME : 28 Mar 07 12:04:26
89
+ REFERENCE # : 5999 431 M
90
+ AUTHOR.# : ET0426
91
+
92
+ Approved - Thank You 00
93
+
94
+ SIGNATURE
95
+
96
+
97
+
98
+ _______________________________________
99
+
100
+ </CTR></types:TransactionResult></soap:Body></soap:Envelope>
101
+ RESPONSE
102
+ end
103
+
104
+ def soap_fault_response
105
+ <<-RESPONSE
106
+ <?xml version='1.0' encoding='UTF-8'?>
107
+ <soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
108
+ <soap:Body>
109
+ <soap:Fault>
110
+ <faultcode>soap:Client</faultcode>
111
+ <faultstring>Unable to handle request without a valid action parameter. Please supply a valid soap action.</faultstring>
112
+ <detail/>
113
+ </soap:Fault>
114
+ </soap:Body>
115
+ </soap:Envelope>
116
+ RESPONSE
117
+ end
118
+ end
@@ -0,0 +1,24 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class Gateway < Test::Unit::TestCase
4
+ def test_should_detect_if_a_card_is_supported
5
+ Gateway.supported_cardtypes = [:visa, :bogus]
6
+ assert [:visa, :bogus].all? { |supported_cardtype| Gateway.supports?(supported_cardtype) }
7
+
8
+ Gateway.supported_cardtypes = []
9
+ assert_false [:visa, :bogus].all? { |invalid_cardtype| Gateway.supports?(invalid_cardtype) }
10
+ end
11
+
12
+ def test_should_gateway_uses_ssl_strict_checking_by_default
13
+ assert Gateway.ssl_strict
14
+ end
15
+
16
+ def test_should_be_able_to_look_for_test_mode
17
+ Base.gateway_mode = :test
18
+ assert Gateway.new.test?
19
+
20
+ Base.gateway_mode = :production
21
+ assert_false Gateway.new.test?
22
+ end
23
+
24
+ end
@@ -0,0 +1,165 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class LinkpointResponseTest < Test::Unit::TestCase
4
+ def setup
5
+ Base.gateway_mode = :test
6
+
7
+ @gateway = LinkpointGateway.new(
8
+ :login => 123123,
9
+ :pem => 'PEM'
10
+ )
11
+
12
+ @creditcard = credit_card('4111111111111111')
13
+ end
14
+
15
+ def teardown
16
+ Base.gateway_mode = :test
17
+ end
18
+
19
+ def test_credit_card_formatting
20
+ assert_equal '04', @gateway.send(:format_creditcard_expiry_year, 2004)
21
+ assert_equal '04', @gateway.send(:format_creditcard_expiry_year, '2004')
22
+ assert_equal '04', @gateway.send(:format_creditcard_expiry_year, 4)
23
+ assert_equal '04', @gateway.send(:format_creditcard_expiry_year, '04')
24
+ end
25
+
26
+ def test_authorize
27
+ @creditcard.number = '1'
28
+
29
+ assert response = @gateway.authorize(2400, @creditcard, :order_id => 1000,
30
+ :address1 => '1313 lucky lane',
31
+ :city => 'Lost Angeles',
32
+ :state => 'CA',
33
+ :zip => '90210'
34
+ )
35
+ assert_equal Response, response.class
36
+ assert_equal true, response.success?
37
+ end
38
+
39
+ def test_purchase_success
40
+ @creditcard.number = '1'
41
+
42
+ assert response = @gateway.purchase(2400, @creditcard, :order_id => 1001,
43
+ :address1 => '1313 lucky lane',
44
+ :city => 'Lost Angeles',
45
+ :state => 'CA',
46
+ :zip => '90210'
47
+ )
48
+ assert_equal Response, response.class
49
+ assert_equal true, response.success?
50
+ end
51
+
52
+ def test_purchase_decline
53
+ @creditcard.number = '2'
54
+
55
+ @gateway = LinkpointGateway.new(
56
+ :login => 123123,
57
+ :pem => 'PEM'
58
+ )
59
+
60
+ assert response = @gateway.purchase(100, @creditcard, :order_id => 1002)
61
+ assert_equal Response, response.class
62
+ assert_equal false, response.success?
63
+ end
64
+
65
+ def test_recurring
66
+ @creditcard.number = '1'
67
+
68
+ assert response = @gateway.recurring(2400, @creditcard, :order_id => 1003, :installments => 12, :startdate => "immediate", :periodicity => :monthly)
69
+ assert_equal Response, response.class
70
+ assert_equal true, response.success?
71
+ end
72
+
73
+ def test_amount_style
74
+ assert_equal '10.34', @gateway.send(:amount, 1034)
75
+
76
+ assert_raise(ArgumentError) do
77
+ @gateway.send(:amount, '10.34')
78
+ end
79
+ end
80
+ end
81
+
82
+
83
+ class LinkpointRequestTest < Test::Unit::TestCase
84
+ def setup
85
+ @gateway = LinkpointGateway.new(:login => 123123, :pem => 'PEM')
86
+
87
+ @creditcard = credit_card('4111111111111111')
88
+ end
89
+
90
+
91
+ def test_purchase_is_valid_xml
92
+ parameters = @gateway.send(:parameters, 1000, @creditcard, :ordertype => "SALE", :order_id => 1004,
93
+ :billing_address => {
94
+ :address1 => '1313 lucky lane',
95
+ :city => 'Lost Angeles',
96
+ :state => 'CA',
97
+ :zip => '90210'
98
+ }
99
+ )
100
+
101
+ assert data = @gateway.send(:post_data, parameters)
102
+ assert REXML::Document.new(data)
103
+ end
104
+
105
+
106
+ def test_recurring_is_valid_xml
107
+ parameters = @gateway.send(:parameters, 1000, @creditcard, :ordertype => "SALE", :action => "SUBMIT", :installments => 12, :startdate => "immediate", :periodicity => "monthly", :order_id => 1006,
108
+ :billing_address => {
109
+ :address1 => '1313 lucky lane',
110
+ :city => 'Lost Angeles',
111
+ :state => 'CA',
112
+ :zip => '90210'
113
+ }
114
+ )
115
+ assert data = @gateway.send(:post_data, parameters)
116
+ assert REXML::Document.new(data)
117
+ end
118
+
119
+ def test_declined_purchase_is_valid_xml
120
+ @gateway = LinkpointGateway.new(:login => 123123, :pem => 'PEM')
121
+
122
+ parameters = @gateway.send(:parameters, 1000, @creditcard, :ordertype => "SALE", :order_id => 1005,
123
+ :billing_address => {
124
+ :address1 => '1313 lucky lane',
125
+ :city => 'Lost Angeles',
126
+ :state => 'CA',
127
+ :zip => '90210'
128
+ }
129
+ )
130
+
131
+ assert data = @gateway.send(:post_data, parameters)
132
+ assert REXML::Document.new(data)
133
+ end
134
+
135
+ def test_overriding_test_mode
136
+ Base.gateway_mode = :production
137
+
138
+ gateway = LinkpointGateway.new(
139
+ :login => 'LOGIN',
140
+ :pem => 'PEM',
141
+ :test => true
142
+ )
143
+
144
+ assert gateway.test?
145
+ end
146
+
147
+ def test_using_production_mode
148
+ Base.gateway_mode = :production
149
+
150
+ gateway = LinkpointGateway.new(
151
+ :login => 'LOGIN',
152
+ :pem => 'PEM'
153
+ )
154
+
155
+ assert !gateway.test?
156
+ end
157
+
158
+ def test_supported_countries
159
+ assert_equal ['US'], LinkpointGateway.supported_countries
160
+ end
161
+
162
+ def test_supported_card_types
163
+ assert_equal [:visa, :master, :american_express, :discover], LinkpointGateway.supported_cardtypes
164
+ end
165
+ end