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.
Files changed (206) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG +310 -294
  3. data/CONTRIBUTERS +13 -0
  4. data/README +55 -31
  5. data/Rakefile +21 -13
  6. data/lib/active_merchant.rb +7 -0
  7. data/lib/active_merchant/billing/avs_result.rb +95 -0
  8. data/lib/active_merchant/billing/base.rb +8 -3
  9. data/lib/active_merchant/billing/check.rb +61 -0
  10. data/lib/active_merchant/billing/credit_card.rb +104 -80
  11. data/lib/active_merchant/billing/credit_card_formatting.rb +11 -8
  12. data/lib/active_merchant/billing/credit_card_methods.rb +76 -32
  13. data/lib/active_merchant/billing/cvv_result.rb +38 -0
  14. data/lib/active_merchant/billing/expiry_date.rb +28 -0
  15. data/lib/active_merchant/billing/gateway.rb +47 -111
  16. data/lib/active_merchant/billing/gateways/authorize_net.rb +508 -121
  17. data/lib/active_merchant/billing/gateways/bogus.rb +26 -32
  18. data/lib/active_merchant/billing/gateways/brain_tree.rb +82 -70
  19. data/lib/active_merchant/billing/gateways/card_stream.rb +43 -15
  20. data/lib/active_merchant/billing/gateways/cyber_source.rb +9 -29
  21. data/lib/active_merchant/billing/gateways/data_cash.rb +18 -38
  22. data/lib/active_merchant/billing/gateways/efsnet.rb +23 -50
  23. data/lib/active_merchant/billing/gateways/eway.rb +8 -19
  24. data/lib/active_merchant/billing/gateways/exact.rb +17 -25
  25. data/lib/active_merchant/billing/gateways/linkpoint.rb +18 -25
  26. data/lib/active_merchant/billing/gateways/moneris.rb +9 -39
  27. data/lib/active_merchant/billing/gateways/net_registry.rb +113 -182
  28. data/lib/active_merchant/billing/gateways/netbilling.rb +168 -0
  29. data/lib/active_merchant/billing/gateways/pay_junction.rb +52 -73
  30. data/lib/active_merchant/billing/gateways/pay_secure.rb +120 -0
  31. data/lib/active_merchant/billing/gateways/payflow.rb +13 -14
  32. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +55 -37
  33. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +4 -0
  34. data/lib/active_merchant/billing/gateways/payflow_express.rb +2 -4
  35. data/lib/active_merchant/billing/gateways/payment_express.rb +11 -30
  36. data/lib/active_merchant/billing/gateways/paypal.rb +3 -14
  37. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +36 -16
  38. data/lib/active_merchant/billing/gateways/paypal_express.rb +1 -2
  39. data/lib/active_merchant/billing/gateways/plugnpay.rb +7 -15
  40. data/lib/active_merchant/billing/gateways/protx.rb +24 -25
  41. data/lib/active_merchant/billing/gateways/psigate.rb +34 -71
  42. data/lib/active_merchant/billing/gateways/psl_card.rb +24 -19
  43. data/lib/active_merchant/billing/gateways/quickpay.rb +10 -24
  44. data/lib/active_merchant/billing/gateways/realex.rb +7 -19
  45. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +113 -0
  46. data/lib/active_merchant/billing/gateways/skip_jack.rb +437 -0
  47. data/lib/active_merchant/billing/gateways/trans_first.rb +5 -14
  48. data/lib/active_merchant/billing/gateways/trust_commerce.rb +100 -39
  49. data/lib/active_merchant/billing/gateways/usa_epay.rb +60 -55
  50. data/lib/active_merchant/billing/gateways/verifi.rb +32 -39
  51. data/lib/active_merchant/billing/gateways/viaklix.rb +31 -37
  52. data/lib/active_merchant/billing/integrations.rb +2 -0
  53. data/lib/active_merchant/billing/integrations/bogus.rb +5 -0
  54. data/lib/active_merchant/billing/integrations/bogus/return.rb +10 -0
  55. data/lib/active_merchant/billing/integrations/chronopay.rb +5 -0
  56. data/lib/active_merchant/billing/integrations/chronopay/return.rb +10 -0
  57. data/lib/active_merchant/billing/integrations/gestpay.rb +5 -0
  58. data/lib/active_merchant/billing/integrations/gestpay/return.rb +10 -0
  59. data/lib/active_merchant/billing/integrations/hi_trust.rb +26 -0
  60. data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +58 -0
  61. data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +57 -0
  62. data/lib/active_merchant/billing/integrations/hi_trust/return.rb +67 -0
  63. data/lib/active_merchant/billing/integrations/nochex.rb +5 -0
  64. data/lib/active_merchant/billing/integrations/nochex/return.rb +10 -0
  65. data/lib/active_merchant/billing/integrations/paypal.rb +5 -0
  66. data/lib/active_merchant/billing/integrations/paypal/return.rb +10 -0
  67. data/lib/active_merchant/billing/integrations/return.rb +35 -0
  68. data/lib/active_merchant/billing/integrations/two_checkout.rb +5 -0
  69. data/lib/active_merchant/billing/integrations/two_checkout/return.rb +17 -0
  70. data/lib/active_merchant/billing/response.rb +12 -8
  71. data/lib/active_merchant/lib/posts_data.rb +39 -7
  72. data/lib/active_merchant/lib/requires_parameters.rb +2 -3
  73. data/lib/active_merchant/lib/utils.rb +18 -0
  74. data/lib/active_merchant/lib/validateable.rb +3 -3
  75. data/lib/support/gateway_support.rb +22 -9
  76. data/script/destroy +14 -0
  77. data/script/generate +7 -7
  78. data/test/fixtures.yml +25 -3
  79. data/test/remote/gateways/remote_authorize_net_test.rb +145 -0
  80. data/test/remote/gateways/remote_brain_tree_test.rb +118 -0
  81. data/test/{remote_tests → remote/gateways}/remote_card_stream_test.rb +56 -68
  82. data/test/{remote_tests → remote/gateways}/remote_cyber_source_test.rb +21 -32
  83. data/test/{remote_tests → remote/gateways}/remote_data_cash_test.rb +2 -2
  84. data/test/{remote_tests → remote/gateways}/remote_efsnet_test.rb +22 -34
  85. data/test/{remote_tests → remote/gateways}/remote_eway_test.rb +18 -15
  86. data/test/{remote_tests → remote/gateways}/remote_exact_test.rb +20 -19
  87. data/test/{remote_tests → remote/gateways}/remote_linkpoint_test.rb +31 -63
  88. data/test/remote/gateways/remote_moneris_test.rb +82 -0
  89. data/test/{remote_tests → remote/gateways}/remote_net_registry_test.rb +19 -54
  90. data/test/remote/gateways/remote_netbilling_test.rb +70 -0
  91. data/test/{remote_tests → remote/gateways}/remote_pay_junction_test.rb +41 -60
  92. data/test/remote/gateways/remote_pay_secure_test.rb +39 -0
  93. data/test/{remote_tests → remote/gateways}/remote_payflow_express_test.rb +2 -2
  94. data/test/{remote_tests → remote/gateways}/remote_payflow_test.rb +34 -38
  95. data/test/{remote_tests → remote/gateways}/remote_payflow_uk_test.rb +13 -12
  96. data/test/{remote_tests → remote/gateways}/remote_payment_express_test.rb +26 -36
  97. data/test/{remote_tests → remote/gateways}/remote_paypal_express_test.rb +3 -3
  98. data/test/{remote_tests → remote/gateways}/remote_paypal_test.rb +25 -21
  99. data/test/{remote_tests → remote/gateways}/remote_plugnpay_test.rb +18 -16
  100. data/test/{remote_tests → remote/gateways}/remote_protx_test.rb +33 -33
  101. data/test/remote/gateways/remote_psigate_test.rb +50 -0
  102. data/test/{remote_tests → remote/gateways}/remote_psl_card_test.rb +27 -26
  103. data/test/{remote_tests → remote/gateways}/remote_quickpay_test.rb +48 -48
  104. data/test/{remote_tests → remote/gateways}/remote_realex_test.rb +30 -33
  105. data/test/remote/gateways/remote_secure_pay_tech_test.rb +37 -0
  106. data/test/remote/gateways/remote_secure_pay_test.rb +28 -0
  107. data/test/remote/gateways/remote_skipjack_test.rb +105 -0
  108. data/test/{remote_tests → remote/gateways}/remote_trans_first_test.rb +7 -10
  109. data/test/remote/gateways/remote_trust_commerce_test.rb +152 -0
  110. data/test/{remote_tests → remote/gateways}/remote_usa_epay_test.rb +11 -22
  111. data/test/{remote_tests → remote/gateways}/remote_verifi_test.rb +27 -27
  112. data/test/{remote_tests → remote/gateways}/remote_viaklix_test.rb +8 -18
  113. data/test/{remote_tests → remote/integrations}/remote_gestpay_integration_test.rb +1 -1
  114. data/test/{remote_tests → remote/integrations}/remote_paypal_integration_test.rb +1 -1
  115. data/test/test_helper.rb +102 -61
  116. data/test/unit/avs_result_test.rb +59 -0
  117. data/test/unit/base_test.rb +33 -39
  118. data/test/unit/check_test.rb +76 -0
  119. data/test/unit/credit_card_formatting_test.rb +10 -15
  120. data/test/unit/credit_card_methods_test.rb +132 -17
  121. data/test/unit/credit_card_test.rb +157 -228
  122. data/test/unit/cvv_result_test.rb +33 -0
  123. data/test/unit/expiry_date_test.rb +21 -0
  124. data/test/unit/gateways/authorize_net_test.rb +180 -40
  125. data/test/unit/gateways/bogus_test.rb +2 -3
  126. data/test/unit/gateways/brain_tree_test.rb +63 -29
  127. data/test/unit/gateways/card_stream_test.rb +59 -6
  128. data/test/unit/gateways/cyber_source_test.rb +59 -40
  129. data/test/unit/gateways/data_cash_test.rb +82 -1
  130. data/test/unit/gateways/efsnet_test.rb +97 -44
  131. data/test/unit/gateways/eway_test.rb +55 -42
  132. data/test/unit/gateways/exact_test.rb +93 -55
  133. data/test/unit/gateways/gateway_test.rb +7 -0
  134. data/test/unit/gateways/linkpoint_test.rb +60 -58
  135. data/test/unit/gateways/moneris_test.rb +67 -76
  136. data/test/unit/gateways/net_registry_test.rb +351 -419
  137. data/test/unit/gateways/netbilling_test.rb +54 -0
  138. data/test/unit/gateways/pay_junction_test.rb +108 -46
  139. data/test/unit/gateways/pay_secure_test.rb +71 -0
  140. data/test/unit/gateways/payflow_express_test.rb +0 -8
  141. data/test/unit/gateways/payflow_test.rb +136 -65
  142. data/test/unit/gateways/payflow_uk_test.rb +0 -38
  143. data/test/unit/gateways/payment_express_test.rb +31 -51
  144. data/test/unit/gateways/paypal_express_test.rb +8 -2
  145. data/test/unit/gateways/paypal_test.rb +213 -54
  146. data/test/unit/gateways/plugnpay_test.rb +39 -32
  147. data/test/unit/gateways/protx_test.rb +45 -33
  148. data/test/unit/gateways/psigate_test.rb +146 -87
  149. data/test/unit/gateways/psl_card_test.rb +37 -24
  150. data/test/unit/gateways/quickpay_test.rb +33 -46
  151. data/test/unit/gateways/realex_test.rb +32 -31
  152. data/test/unit/gateways/secure_pay_tech_test.rb +44 -0
  153. data/test/unit/gateways/secure_pay_test.rb +35 -26
  154. data/test/unit/gateways/skip_jack_test.rb +125 -0
  155. data/test/unit/gateways/trans_first_test.rb +24 -37
  156. data/test/unit/gateways/trust_commerce_test.rb +47 -26
  157. data/test/unit/gateways/usa_epay_test.rb +52 -41
  158. data/test/unit/gateways/verifi_test.rb +41 -35
  159. data/test/unit/gateways/viaklix_test.rb +38 -32
  160. data/test/unit/generators/test_gateway_generator.rb +46 -0
  161. data/test/unit/generators/test_generator_helper.rb +20 -0
  162. data/test/unit/generators/test_integration_generator.rb +53 -0
  163. data/test/unit/integrations/action_view_helper_test.rb +7 -14
  164. data/test/unit/integrations/bogus_module_test.rb +4 -0
  165. data/test/unit/integrations/chronopay_module_test.rb +4 -0
  166. data/test/unit/integrations/gestpay_module_test.rb +4 -0
  167. data/test/unit/integrations/helpers/hi_trust_helper_test.rb +16 -0
  168. data/test/unit/integrations/hi_trust_module_test.rb +13 -0
  169. data/test/unit/integrations/nochex_module_test.rb +4 -0
  170. data/test/unit/integrations/notifications/hi_trust_notification_test.rb +38 -0
  171. data/test/unit/integrations/paypal_module_test.rb +4 -0
  172. data/test/unit/integrations/returns/chronopay_return_test.rb +11 -0
  173. data/test/unit/integrations/returns/gestpay_return_test.rb +10 -0
  174. data/test/unit/integrations/returns/hi_trust_return_test.rb +24 -0
  175. data/test/unit/integrations/returns/nochex_return_test.rb +10 -0
  176. data/test/unit/integrations/returns/paypal_return_test.rb +10 -0
  177. data/test/unit/integrations/returns/return_test.rb +11 -0
  178. data/test/unit/integrations/returns/two_checkout_return_test.rb +24 -0
  179. data/test/unit/integrations/two_checkout_module_test.rb +4 -0
  180. data/test/unit/posts_data_test.rb +86 -0
  181. data/test/unit/response_test.rb +15 -1
  182. data/test/unit/utils_test.rb +7 -0
  183. data/test/unit/validateable_test.rb +10 -6
  184. metadata +180 -142
  185. metadata.gz.sig +0 -0
  186. data/lib/active_merchant/billing/gateways/paypal/api_cert_chain.crt +0 -35
  187. data/script/generator/base.rb +0 -45
  188. data/script/generator/generator.rb +0 -24
  189. data/script/generator/generators/gateway/gateway_generator.rb +0 -14
  190. data/script/generator/generators/gateway/templates/gateway.rb +0 -73
  191. data/script/generator/generators/gateway/templates/gateway_test.rb +0 -41
  192. data/script/generator/generators/gateway/templates/remote_gateway_test.rb +0 -56
  193. data/script/generator/generators/integration/integration_generator.rb +0 -25
  194. data/script/generator/generators/integration/templates/helper.rb +0 -34
  195. data/script/generator/generators/integration/templates/helper_test.rb +0 -54
  196. data/script/generator/generators/integration/templates/integration.rb +0 -18
  197. data/script/generator/generators/integration/templates/module_test.rb +0 -9
  198. data/script/generator/generators/integration/templates/notification.rb +0 -100
  199. data/script/generator/generators/integration/templates/notification_test.rb +0 -41
  200. data/script/generator/manifest.rb +0 -20
  201. data/test/remote_tests/remote_authorize_net_test.rb +0 -113
  202. data/test/remote_tests/remote_brain_tree_test.rb +0 -78
  203. data/test/remote_tests/remote_moneris_test.rb +0 -110
  204. data/test/remote_tests/remote_psigate_test.rb +0 -87
  205. data/test/remote_tests/remote_secure_pay_test.rb +0 -36
  206. data/test/remote_tests/remote_trust_commerce_test.rb +0 -136
@@ -1,46 +1,36 @@
1
1
  require File.dirname(__FILE__) + '/../../test_helper'
2
2
 
3
3
  class PslCardTest < Test::Unit::TestCase
4
- # 100 Cents
5
- AMOUNT = 100
6
4
 
7
5
  def setup
8
6
  @gateway = PslCardGateway.new(
9
- :login => 'LOGIN',
10
- :password => 'PASSWORD'
11
- )
7
+ :login => 'LOGIN',
8
+ :password => 'PASSWORD'
9
+ )
12
10
 
13
- @creditcard = credit_card('4242424242424242')
14
- end
15
-
16
- def test_successful_purchase
17
- @creditcard.number = 1
18
- assert response = @gateway.purchase(AMOUNT, @creditcard, {})
19
- assert_success response
20
- assert_equal '5555', response.authorization
21
- assert response.test?
11
+ @credit_card = credit_card
12
+ @options = {
13
+ :billing_address => address,
14
+ :description => 'Store purchase'
15
+ }
16
+ @amount = 100
22
17
  end
23
18
 
24
19
  def test_successful_authorization
25
- @creditcard.number = 1
26
- assert response = @gateway.authorize(AMOUNT, @creditcard, {})
20
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
21
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
27
22
  assert_success response
28
- assert_equal '5555', response.authorization
23
+ assert_equal '08012522454901256086', response.authorization
29
24
  assert response.test?
30
25
  end
31
26
 
32
27
  def test_unsuccessful_request
33
- @creditcard.number = 2
34
- assert response = @gateway.purchase(AMOUNT, @creditcard, {})
28
+ @gateway.expects(:ssl_post).returns(unsuccessful_purchase_response)
29
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
35
30
  assert_failure response
36
31
  assert response.test?
37
32
  end
38
33
 
39
- def test_request_error
40
- @creditcard.number = 3
41
- assert_raise(Error){ @gateway.purchase(AMOUNT, @creditcard, {}) }
42
- end
43
-
44
34
  def test_supported_countries
45
35
  assert_equal ['GB'], PslCardGateway.supported_countries
46
36
  end
@@ -48,4 +38,27 @@ class PslCardTest < Test::Unit::TestCase
48
38
  def test_supported_card_types
49
39
  assert_equal [ :visa, :master, :american_express, :diners_club, :jcb, :switch, :solo, :maestro ], PslCardGateway.supported_cardtypes
50
40
  end
41
+
42
+ def test_avs_result
43
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
44
+
45
+ response = @gateway.purchase(@amount, @credit_card, @options)
46
+ assert_equal 'Y', response.avs_result['code']
47
+ end
48
+
49
+ def test_cvv_result
50
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
51
+
52
+ response = @gateway.purchase(@amount, @credit_card, @options)
53
+ assert_equal 'M', response.cvv_result['code']
54
+ end
55
+
56
+ private
57
+ def successful_purchase_response
58
+ "ResponseCode=00&Message=AUTHCODE:01256&CrossReference=08012522454901256086&First4=4543&Last4=9982&ExpMonth=12&ExpYear=2010&AVSCV2Check=ALL MATCH&Amount=1000&QAAddress=76 Roseby Avenue Manchester&QAPostcode=M63X 7TH&MerchantName=Merchant Name&QAName=John Smith"
59
+ end
60
+
61
+ def unsuccessful_purchase_response
62
+ "ResponseCode=05&Message=CARD DECLINED&QAAddress=The Parkway Larches Approach Hull North Humberside&QAPostcode=HU7 9OP&MerchantName=Merchant Name&QAName="
63
+ end
51
64
  end
@@ -1,56 +1,48 @@
1
1
  require File.dirname(__FILE__) + '/../../test_helper'
2
2
 
3
3
  class QuickpayTest < Test::Unit::TestCase
4
- # 100 Cents
5
- AMOUNT = 100
6
-
7
4
  def setup
8
5
  @gateway = QuickpayGateway.new(
9
6
  :login => 'LOGIN',
10
7
  :password => 'PASSWORD'
11
8
  )
12
9
 
13
- @creditcard = CreditCard.new(
14
- :number => '4242424242424242',
15
- :month => 8,
16
- :year => 2008,
17
- :first_name => 'Longbob',
18
- :last_name => 'Longsen'
19
- )
10
+ @credit_card = credit_card('4242424242424242')
11
+ @amount = 100
12
+ @options = { :order_id => '1', :billing_address => address }
20
13
  end
21
14
 
22
15
  def test_successful_purchase
23
- @creditcard.number = 1
24
- assert response = @gateway.purchase(AMOUNT, @creditcard, {})
16
+ @gateway.expects(:ssl_post).times(2).returns(successful_authorization_response, successful_capture_response)
17
+
18
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
25
19
  assert_success response
26
- assert_equal '5555', response.authorization
20
+ assert_equal '2865261', response.authorization
27
21
  assert response.test?
28
22
  end
29
23
 
30
24
  def test_successful_authorization
31
- @creditcard.number = 1
32
- assert response = @gateway.authorize(AMOUNT, @creditcard, {})
25
+ @gateway.expects(:ssl_post).returns(successful_authorization_response)
26
+
27
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
33
28
  assert_success response
34
- assert_equal '5555', response.authorization
29
+ assert_equal '2865261', response.authorization
35
30
  assert response.test?
36
31
  end
37
32
 
38
- def test_unsuccessful_request
39
- @creditcard.number = 2
40
- assert response = @gateway.purchase(AMOUNT, @creditcard, {})
33
+ def test_failed_authorization
34
+ @gateway.expects(:ssl_post).returns(failed_authorization_response)
35
+
36
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
41
37
  assert_failure response
38
+ assert_equal 'Missing/error in card verification data', response.message
42
39
  assert response.test?
43
40
  end
44
-
45
- def test_request_error
46
- @creditcard.number = 3
47
- assert_raise(Error){ @gateway.purchase(AMOUNT, @creditcard, {}) }
48
- end
49
41
 
50
42
  def test_parsing_response_with_errors
51
43
  @gateway.expects(:ssl_post).returns(error_response)
52
44
 
53
- response = @gateway.purchase(AMOUNT, @creditcard, :order_id => '1000')
45
+ response = @gateway.purchase(@amount, @credit_card, @options)
54
46
  assert_failure response
55
47
  assert_equal '008', response.params['qpstat']
56
48
  assert_equal 'Missing/error in cardnumberMissing/error in expirationdateMissing/error in card verification dataMissing/error in amountMissing/error in ordernumMissing/error in currency', response.params['qpstatmsg']
@@ -60,15 +52,15 @@ class QuickpayTest < Test::Unit::TestCase
60
52
  def test_merchant_error
61
53
  @gateway.expects(:ssl_post).returns(merchant_error)
62
54
 
63
- response = @gateway.purchase(AMOUNT, @creditcard, :order_id => '1000')
55
+ response = @gateway.purchase(@amount, @credit_card, @options)
64
56
  assert_failure response
65
57
  assert_equal response.message, 'Missing/error in merchant'
66
58
  end
67
59
 
68
60
  def test_parsing_successful_response
69
- @gateway.expects(:ssl_post).returns(successful_response)
61
+ @gateway.expects(:ssl_post).returns(successful_authorization_response)
70
62
 
71
- response = @gateway.authorize(AMOUNT, @creditcard, :order_id => '1000')
63
+ response = @gateway.authorize(@amount, @credit_card, @options)
72
64
 
73
65
  assert_success response
74
66
  assert_equal 'OK', response.message
@@ -81,7 +73,7 @@ class QuickpayTest < Test::Unit::TestCase
81
73
  assert_equal '104680', response.params['ordernum']
82
74
  assert_equal 'cody@example.com', response.params['merchantemail']
83
75
  assert_equal 'Visa', response.params['cardtype']
84
- assert_equal AMOUNT.to_s, response.params['amount']
76
+ assert_equal @amount.to_s, response.params['amount']
85
77
  assert_equal 'OK', response.params['qpstatmsg']
86
78
  assert_equal 'Shopify', response.params['merchant']
87
79
  assert_equal '1110', response.params['msgtype']
@@ -96,30 +88,25 @@ class QuickpayTest < Test::Unit::TestCase
96
88
  assert_equal [ :dankort, :forbrugsforeningen, :visa, :master, :american_express, :diners_club, :jcb, :maestro ], QuickpayGateway.supported_cardtypes
97
89
  end
98
90
 
99
-
100
91
  private
101
92
 
102
93
  def error_response
103
- <<-XML
104
- <?xml version='1.0' encoding='ISO-8859-1'?>
105
-
106
- <values qpstat='008' qpstatmsg='Missing/error in cardnumberMissing/error in expirationdateMissing/error in card verification dataMissing/error in amountMissing/error in ordernumMissing/error in currency'/>
107
- XML
94
+ "<?xml version='1.0' encoding='ISO-8859-1'?><values qpstat='008' qpstatmsg='Missing/error in cardnumberMissing/error in expirationdateMissing/error in card verification dataMissing/error in amountMissing/error in ordernumMissing/error in currency'/>"
108
95
  end
109
96
 
110
97
  def merchant_error
111
- <<-XML
112
- <?xml version='1.0' encoding='ISO-8859-1'?>
113
-
114
- <values qpstat='008' qpstatmsg='Missing/error in merchant'/>
115
- XML
98
+ "<?xml version='1.0' encoding='ISO-8859-1'?><values qpstat='008' qpstatmsg='Missing/error in merchant'/>"
116
99
  end
117
100
 
118
- def successful_response
119
- <<-XML
120
- <?xml version='1.0' encoding='ISO-8859-1'?>
121
-
122
- <values qpstat='000' transaction='2865261' time='070425223705' ordernum='104680' merchantemail='cody@example.com' pbsstat='000' cardtype='Visa' amount='100' qpstatmsg='OK' merchant='Shopify' msgtype='1110' currency='USD'/>
123
- XML
101
+ def successful_authorization_response
102
+ "<?xml version='1.0' encoding='ISO-8859-1'?><values qpstat='000' transaction='2865261' time='070425223705' ordernum='104680' merchantemail='cody@example.com' pbsstat='000' cardtype='Visa' amount='100' qpstatmsg='OK' merchant='Shopify' msgtype='1110' currency='USD'/>"
103
+ end
104
+
105
+ def successful_capture_response
106
+ '<?xml version="1.0" encoding="ISO-8859-1"?><values msgtype="1230" amount="100" time="080107061755" pbsstat="000" qpstat="000" qpstatmsg="OK" currency="DKK" ordernum="4820346075804536193" transaction="2865261" merchant="Shopify" merchantemail="pixels@jadedpixel.com" />'
107
+ end
108
+
109
+ def failed_authorization_response
110
+ '<?xml version="1.0" encoding="ISO-8859-1"?><values qpstat="008" qpstatmsg="Missing/error in card verification data" />'
124
111
  end
125
112
  end
@@ -2,8 +2,7 @@ require File.dirname(__FILE__) + '/../../test_helper'
2
2
  require 'digest/sha1'
3
3
 
4
4
  class RealexTest < Test::Unit::TestCase
5
- AMOUNT = 100
6
-
5
+
7
6
  def setup
8
7
  @login = 'your_merchant_id'
9
8
  @password = 'your_secret'
@@ -20,7 +19,7 @@ class RealexTest < Test::Unit::TestCase
20
19
  :account => 'bill_web_cengal'
21
20
  )
22
21
 
23
- @creditcard = CreditCard.new(
22
+ @credit_card = CreditCard.new(
24
23
  :number => '4263971921001307',
25
24
  :month => 8,
26
25
  :year => 2008,
@@ -28,6 +27,12 @@ class RealexTest < Test::Unit::TestCase
28
27
  :last_name => 'Longsen',
29
28
  :type => 'visa'
30
29
  )
30
+
31
+ @options = {
32
+ :order_id => '1'
33
+ }
34
+
35
+ @amount = 100
31
36
  end
32
37
 
33
38
 
@@ -43,40 +48,23 @@ class RealexTest < Test::Unit::TestCase
43
48
  result = Digest::SHA1.hexdigest(result + "." + @password)
44
49
  assert_equal "06a8b619cbd76024676401e5a83e7e5453521af3", result
45
50
  end
46
-
47
-
48
- def test_successful_request
49
- @creditcard.number = 1
50
- assert response = @gateway.purchase(AMOUNT, @creditcard, :order_id => 1)
51
- assert_success response
52
- assert_equal '5555', response.authorization
53
- assert response.test?
54
- end
55
51
 
56
- def test_unsuccessful_request
57
- @creditcard.number = 2
58
- assert response = @gateway.purchase(AMOUNT, @creditcard, :order_id => 1)
59
- assert_failure response
60
- assert response.test?
61
- end
62
-
63
- def test_request_error
64
- @creditcard.number = 3
65
- assert_raise(Error){ @gateway.purchase(AMOUNT, @creditcard, :order_id => 1) }
66
- end
67
-
68
52
  def test_successful_purchase
69
- @gateway.expects(:ssl_post).returns(successful_response)
53
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
70
54
 
71
- response = @gateway.purchase(AMOUNT, @creditcard, :order_id => 1)
55
+ response = @gateway.purchase(@amount, @credit_card, @options)
56
+ assert_instance_of Response, response
72
57
  assert_success response
58
+ assert response.test?
73
59
  end
74
60
 
75
61
  def test_unsuccessful_purchase
76
- @gateway.expects(:ssl_post).returns(unsuccessful_response)
62
+ @gateway.expects(:ssl_post).returns(unsuccessful_purchase_response)
77
63
 
78
- response = @gateway.purchase(AMOUNT, @creditcard, :order_id => 1)
64
+ response = @gateway.purchase(@amount, @credit_card, @options)
65
+ assert_instance_of Response, response
79
66
  assert_failure response
67
+ assert response.test?
80
68
  end
81
69
 
82
70
  def test_supported_countries
@@ -87,10 +75,23 @@ class RealexTest < Test::Unit::TestCase
87
75
  assert_equal [ :visa, :master, :american_express, :diners_club, :switch, :solo, :laser ], RealexGateway.supported_cardtypes
88
76
  end
89
77
 
78
+ def test_avs_result_not_supported
79
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
80
+
81
+ response = @gateway.purchase(@amount, @credit_card, @options)
82
+ assert_nil response.avs_result['code']
83
+ end
84
+
85
+ def test_cvv_result
86
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
87
+
88
+ response = @gateway.purchase(@amount, @credit_card, @options)
89
+ assert_equal 'M', response.cvv_result['code']
90
+ end
90
91
 
91
92
  private
92
93
 
93
- def successful_response
94
+ def successful_purchase_response
94
95
  <<-RESPONSE
95
96
  <response timestamp='20010427043422'>
96
97
  <merchantid>your merchant id</merchantid>
@@ -119,7 +120,7 @@ class RealexTest < Test::Unit::TestCase
119
120
  RESPONSE
120
121
  end
121
122
 
122
- def unsuccessful_response
123
+ def unsuccessful_purchase_response
123
124
  <<-RESPONSE
124
125
  <response timestamp='20010427043422'>
125
126
  <merchantid>your merchant id</merchantid>
@@ -127,7 +128,7 @@ class RealexTest < Test::Unit::TestCase
127
128
  <orderid>order id from request</orderid>
128
129
  <authcode>authcode received</authcode>
129
130
  <result>01</result>
130
- <message>message returned from system</message>
131
+ <message>[ test system ] message returned from system</message>
131
132
  <pasref> realex payments reference</pasref>
132
133
  <cvnresult>M</cvnresult>
133
134
  <batchid>batch id for this transaction (if any)</batchid>
@@ -0,0 +1,44 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class SecurePayTechTest < Test::Unit::TestCase
4
+ def setup
5
+ @gateway = SecurePayTechGateway.new(
6
+ :login => 'x',
7
+ :password => 'y'
8
+ )
9
+
10
+ @amount = 100
11
+ @credit_card = credit_card('4987654321098769')
12
+ @options = {
13
+ :billing_address => address
14
+ }
15
+ end
16
+
17
+ def test_successful_purchase
18
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
19
+
20
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
21
+ assert_instance_of Response, response
22
+ assert_success response
23
+ assert response.test?
24
+ assert_equal '4--120119220646821', response.authorization
25
+ end
26
+
27
+ def test_unsuccessful_purchase
28
+ @gateway.expects(:ssl_post).returns(unsuccessful_purchase_response)
29
+
30
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
31
+ assert_instance_of Response, response
32
+ assert_failure response
33
+ assert response.test?
34
+ end
35
+
36
+ private
37
+ def successful_purchase_response
38
+ "1,4--120119220646821,000000014511,23284,014511,20080125\r\n"
39
+ end
40
+
41
+ def unsuccessful_purchase_response
42
+ "4,4--120119180936527,000000014510,23283,014510,20080125\r\n"
43
+ end
44
+ end
@@ -1,7 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/../../test_helper'
2
2
 
3
3
  class SecurePayTest < Test::Unit::TestCase
4
- include ActiveMerchant::Billing
5
4
 
6
5
  def setup
7
6
  @gateway = SecurePayGateway.new(
@@ -9,31 +8,21 @@ class SecurePayTest < Test::Unit::TestCase
9
8
  :password => 'Y'
10
9
  )
11
10
 
12
- @creditcard = CreditCard.new(
13
- :number => '4242424242424242',
14
- :month => 8,
15
- :year => 2006,
16
- :first_name => 'Longbob',
17
- :last_name => 'Longsen'
18
- )
11
+ @credit_card = credit_card
12
+
13
+ @options = {
14
+ :order_id => generate_unique_id,
15
+ :description => 'Store purchase',
16
+ :billing_address => address
17
+ }
18
+
19
+ @amount = 100
19
20
  end
20
21
 
21
22
  def test_failed_purchase
22
23
  @gateway.stubs(:ssl_post).returns(failure_response)
23
24
 
24
- assert response = @gateway.purchase(100, @creditcard,
25
- :order_id => generate_order_id,
26
- :description => 'Store purchase',
27
- :billing_address => {
28
- :first_name => 'Cody',
29
- :last_name => 'Fauser',
30
- :address1 => '1234 Test St.',
31
- :city => 'Ottawa',
32
- :state => 'ON',
33
- :country => 'Canada',
34
- :zip => 'K2P7G2'
35
- }
36
- )
25
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
37
26
  assert_failure response
38
27
  assert response.test?
39
28
  assert_equal 'This transaction has been declined', response.message
@@ -43,17 +32,29 @@ class SecurePayTest < Test::Unit::TestCase
43
32
  def test_successful_purchase
44
33
  @gateway.stubs(:ssl_post).returns(successful_purchase_response)
45
34
 
46
- assert response = @gateway.purchase(100, @creditcard,
47
- :order_id => generate_order_id,
48
- :description => 'Store purchase'
49
- )
50
-
35
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
51
36
  assert_success response
52
37
  assert response.test?
53
38
  assert_equal 'This transaction has been approved', response.message
54
39
  assert response.authorization
55
40
  end
56
41
 
42
+
43
+ def test_avs_result
44
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
45
+
46
+ response = @gateway.purchase(@amount, @credit_card)
47
+ assert_equal 'X', response.avs_result['code']
48
+ end
49
+
50
+ def test_cvv_result_not_supported
51
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
52
+
53
+ response = @gateway.purchase(@amount, @credit_card)
54
+ assert_nil response.cvv_result['code']
55
+ end
56
+
57
+
57
58
  def test_undefine_unsupported_methods
58
59
  assert @gateway.respond_to?(:purchase)
59
60
 
@@ -62,6 +63,14 @@ class SecurePayTest < Test::Unit::TestCase
62
63
  end
63
64
  end
64
65
 
66
+ def test_supported_countries_are_inherited
67
+ assert_equal AuthorizeNetGateway.supported_countries, SecurePayGateway.supported_countries
68
+ end
69
+
70
+ def test_supported_card_types_are_inherited
71
+ assert_equal AuthorizeNetGateway.supported_cardtypes, SecurePayGateway.supported_cardtypes
72
+ end
73
+
65
74
  private
66
75
 
67
76
  def successful_purchase_response