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,16 +1,56 @@
1
1
  require File.dirname(__FILE__) + '/../../test_helper'
2
2
 
3
3
  class CardStreamTest < Test::Unit::TestCase
4
- # 100 Cents
5
- AMOUNT = 100
6
-
7
4
  def setup
8
5
  @gateway = CardStreamGateway.new(
9
6
  :login => 'LOGIN',
10
7
  :password => 'PASSWORD'
11
8
  )
12
-
13
- @creditcard = credit_card('4242424242424242')
9
+
10
+ @amount = 100
11
+ @credit_card = credit_card('4242424242424242')
12
+ @options = { :order_id => '1', :billing_address => address }
13
+ end
14
+
15
+ def test_successful_purchase
16
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
17
+
18
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
19
+ assert_instance_of Response, response
20
+ assert_success response
21
+ assert_equal '08010706065208191057', response.authorization
22
+ end
23
+
24
+ def test_failed_purchase
25
+ @gateway.expects(:ssl_post).returns(failed_purchase_response)
26
+
27
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
28
+ assert_instance_of Response, response
29
+ assert_failure response
30
+ end
31
+
32
+ def test_successful_avs_result
33
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
34
+
35
+ response = @gateway.purchase(@amount, @credit_card, @options)
36
+ assert_equal 'Y', response.avs_result['street_match']
37
+ assert_equal 'Y', response.avs_result['postal_match']
38
+ end
39
+
40
+ def test_failed_avs_result
41
+ @gateway.expects(:ssl_post).returns(successful_purchase_failed_avs_cvv_response)
42
+
43
+ response = @gateway.purchase(@amount, @credit_card, @options)
44
+ assert_equal 'N', response.cvv_result['code']
45
+ assert_equal 'N', response.avs_result['street_match']
46
+ assert_equal 'N', response.avs_result['postal_match']
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']
14
54
  end
15
55
 
16
56
  def test_supported_countries
@@ -18,7 +58,7 @@ class CardStreamTest < Test::Unit::TestCase
18
58
  end
19
59
 
20
60
  def test_supported_card_types
21
- assert_equal [:visa, :master, :american_express, :discover, :jcb, :maestro, :solo, :switch], CardStreamGateway.supported_cardtypes
61
+ assert_equal [:visa, :master, :american_express, :diners_club, :discover, :jcb, :maestro, :solo, :switch], CardStreamGateway.supported_cardtypes
22
62
  end
23
63
 
24
64
  def test_default_currency
@@ -34,4 +74,17 @@ class CardStreamTest < Test::Unit::TestCase
34
74
  @gateway.send(:add_amount, params, 1000, :currency => 'USD')
35
75
  assert_equal '840', params[:CurrencyCode]
36
76
  end
77
+
78
+ private
79
+ def successful_purchase_response
80
+ 'VPResponseCode=00&VPCrossReference=08010706065208191057&VPMessage=AUTHCODE:08191&VPTransactionUnique=c3871e2d005b924bf81565537caba82d&VPOrderDesc=Store purchase&VPBillingCountry=826&VPCardName=Longbob Longsen&VPBillingPostCode=LE10 2RT&VPAmountRecieved=100&VPAVSCV2ResponseCode=222100&VPCV2ResultMessage=CV2 Matched&VPAVSResultMessage=Postcode Matched&VPAVSAddressMessage=Address Numeric Matched&VPCardType=MC&VPBillingAddress=25 The Larches, Narborough, Leicester&VPReturnPoint=0090'
81
+ end
82
+
83
+ def successful_purchase_failed_avs_cvv_response
84
+ 'VPResponseCode=00&VPCrossReference=08010706065208191057&VPMessage=AUTHCODE:08191&VPTransactionUnique=c3871e2d005b924bf81565537caba82d&VPOrderDesc=Store purchase&VPBillingCountry=826&VPCardName=Longbob Longsen&VPBillingPostCode=LE10 2RT&VPAmountRecieved=100&VPAVSCV2ResponseCode=444100&VPCV2ResultMessage=CV2 Matched&VPAVSResultMessage=Postcode Matched&VPAVSAddressMessage=Address Numeric Matched&VPCardType=MC&VPBillingAddress=25 The Larches, Narborough, Leicester&VPReturnPoint=0090'
85
+ end
86
+
87
+ def failed_purchase_response
88
+ 'VPResponseCode=05&VPCrossReference=NoCrossReference&VPMessage=CARD DECLINED&VPTransactionUnique=d966e18a2983faff3715a541983792e0&VPOrderDesc=Store purchase&VPBillingCountry=826&VPCardName=Longbob Longsen&VPBillingPostCode=LE10 2RT&VPAmountRecieved=NA&VPAVSCV2ResponseCode=222100&VPCV2ResultMessage=CV2 Matched&VPAVSResultMessage=Postcode Matched&VPAVSAddressMessage=Address Numeric Matched&VPCardType=MC&VPBillingAddress=25 The Larches, Narborough, Leicester&VPReturnPoint=0090'
89
+ end
37
90
  end
@@ -1,21 +1,19 @@
1
1
  require File.dirname(__FILE__) + '/../../test_helper'
2
2
 
3
3
  class CyberSourceTest < Test::Unit::TestCase
4
- LOGIN = 'YourLogin'
5
- TRANSACTION_KEY = 'GenerateThisInTheBusinessCenter'
6
- AMOUNT = 100
7
-
8
4
  def setup
9
5
  Base.gateway_mode = :test
6
+
10
7
  @gateway = CyberSourceGateway.new(
11
- :login => LOGIN,
12
- :password => TRANSACTION_KEY , :test => true
8
+ :login => 'l',
9
+ :password => 'p'
13
10
  )
14
11
 
15
- @creditcard = credit_card('4111111111111111', :type => 'visa')
12
+ @amount = 100
13
+ @credit_card = credit_card('4111111111111111', :type => 'visa')
16
14
  @declined_card = credit_card('801111111111111', :type => 'visa')
17
15
 
18
- @options = { :address => {
16
+ @options = { :billing_address => {
19
17
  :address1 => '1234 My Street',
20
18
  :address2 => 'Apt 1',
21
19
  :company => 'Widgets Inc',
@@ -27,17 +25,17 @@ class CyberSourceTest < Test::Unit::TestCase
27
25
  },
28
26
 
29
27
  :email => 'someguy1232@fakeemail.net',
30
- :order_id => 'test1111111111111111',
28
+ :order_id => '1000',
31
29
  :line_items => [
32
30
  {
33
- :declared_value => 100,
31
+ :declared_value => @amount,
34
32
  :quantity => 2,
35
33
  :code => 'default',
36
34
  :description => 'Giant Walrus',
37
35
  :sku => 'WA323232323232323'
38
36
  },
39
37
  {
40
- :declared_value => 100,
38
+ :declared_value => @amount,
41
39
  :quantity => 2,
42
40
  :description => 'Marble Snowcone',
43
41
  :sku => 'FAKE1232132113123'
@@ -47,35 +45,27 @@ class CyberSourceTest < Test::Unit::TestCase
47
45
  }
48
46
  end
49
47
 
50
- def test_purchase_success
51
- @creditcard.number = 1
48
+ def test_successful_purchase
49
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
52
50
 
53
- assert response = @gateway.purchase(100, @creditcard, @options)
54
- assert_equal Response, response.class
55
- assert_equal '#0001', response.params['receiptid']
56
- assert_equal true, response.success?
51
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
52
+ assert_equal 'Successful transaction', response.message
53
+ assert_success response
54
+ assert_equal "#{@options[:order_id]};#{response.params['requestID']};#{response.params['requestToken']}", response.authorization
55
+ assert response.test?
57
56
  end
58
57
 
59
- def test_purchase_error
60
- @creditcard.number = 2
58
+ def test_unsuccessful_authorization
59
+ @gateway.expects(:ssl_post).returns(unsuccessful_authorization_response)
61
60
 
62
- assert response = @gateway.purchase(100, @creditcard, @options)
63
- assert_equal Response, response.class
64
- assert_equal '#0001', response.params['receiptid']
65
- assert_equal false, response.success?
66
- end
67
-
68
- def test_purchase_exceptions
69
- @creditcard.number = 3
70
-
71
- assert_raise(Error) do
72
- assert response = @gateway.purchase(100, @creditcard, @options)
73
- end
61
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
62
+ assert_instance_of Response, response
63
+ assert_failure response
74
64
  end
75
65
 
76
66
  def test_successful_auth_request
77
67
  @gateway.stubs(:ssl_post).returns(successful_authorization_response)
78
- assert response = @gateway.authorize(AMOUNT, @creditcard, @options)
68
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
79
69
  assert_equal Response, response.class
80
70
  assert response.success?
81
71
  assert response.test?
@@ -83,7 +73,7 @@ class CyberSourceTest < Test::Unit::TestCase
83
73
 
84
74
  def test_successful_tax_request
85
75
  @gateway.stubs(:ssl_post).returns(successful_tax_response)
86
- assert response = @gateway.calculate_tax(@creditcard, @options)
76
+ assert response = @gateway.calculate_tax(@credit_card, @options)
87
77
  assert_equal Response, response.class
88
78
  assert response.success?
89
79
  assert response.test?
@@ -91,38 +81,60 @@ class CyberSourceTest < Test::Unit::TestCase
91
81
 
92
82
  def test_successful_capture_request
93
83
  @gateway.stubs(:ssl_post).returns(successful_authorization_response, successful_capture_response)
94
- assert response = @gateway.authorize(AMOUNT, @creditcard, @options)
84
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
95
85
  assert response.success?
96
86
  assert response.test?
97
- assert response_capture = @gateway.capture(AMOUNT, response.authorization)
87
+ assert response_capture = @gateway.capture(@amount, response.authorization)
98
88
  assert response_capture.success?
99
89
  assert response_capture.test?
100
90
  end
101
91
 
102
92
  def test_successful_purchase_request
103
93
  @gateway.stubs(:ssl_post).returns(successful_capture_response)
104
- assert response = @gateway.purchase(AMOUNT, @creditcard, @options)
94
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
105
95
  assert response.success?
106
96
  assert response.test?
107
97
  end
108
98
 
109
99
  def test_requires_error_on_purchase_without_order_id
110
- assert_raise(ArgumentError){ @gateway.purchase(AMOUNT, @creditcard, @options.delete_if{|key, val| key == :order_id}) }
100
+ assert_raise(ArgumentError){ @gateway.purchase(@amount, @credit_card, @options.delete_if{|key, val| key == :order_id}) }
111
101
  end
112
102
 
113
103
  def test_requires_error_on_authorization_without_order_id
114
- assert_raise(ArgumentError){ @gateway.purchase(AMOUNT, @creditcard, @options.delete_if{|key, val| key == :order_id}) }
104
+ assert_raise(ArgumentError){ @gateway.purchase(@amount, @credit_card, @options.delete_if{|key, val| key == :order_id}) }
115
105
  end
116
106
 
117
107
  def test_requires_error_on_tax_calculation_without_line_items
118
- assert_raise(ArgumentError){ @gateway.calculate_tax(@creditcard, @options.delete_if{|key, val| key == :line_items})}
108
+ assert_raise(ArgumentError){ @gateway.calculate_tax(@credit_card, @options.delete_if{|key, val| key == :line_items})}
119
109
  end
120
110
 
121
111
  def test_default_currency
122
112
  assert_equal 'USD', CyberSourceGateway.default_currency
123
113
  end
114
+
115
+ def test_avs_result
116
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
117
+
118
+ response = @gateway.purchase(@amount, @credit_card, @options)
119
+ assert_equal 'Y', response.avs_result['code']
120
+ end
121
+
122
+ def test_cvv_result
123
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
124
+
125
+ response = @gateway.purchase(@amount, @credit_card, @options)
126
+ assert_equal 'M', response.cvv_result['code']
127
+ end
124
128
 
125
129
  private
130
+
131
+ def successful_purchase_response
132
+ <<-XML
133
+ <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
134
+ <soap:Header>
135
+ <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-2636690"><wsu:Created>2008-01-15T21:42:03.343Z</wsu:Created></wsu:Timestamp></wsse:Security></soap:Header><soap:Body><c:replyMessage xmlns:c="urn:schemas-cybersource-com:transaction-data-1.26"><c:merchantReferenceCode>b0a6cf9aa07f1a8495f89c364bbd6a9a</c:merchantReferenceCode><c:requestID>2004333231260008401927</c:requestID><c:decision>ACCEPT</c:decision><c:reasonCode>100</c:reasonCode><c:requestToken>Afvvj7Ke2Fmsbq0wHFE2sM6R4GAptYZ0jwPSA+R9PhkyhFTb0KRjoE4+ynthZrG6tMBwjAtT</c:requestToken><c:purchaseTotals><c:currency>USD</c:currency></c:purchaseTotals><c:ccAuthReply><c:reasonCode>100</c:reasonCode><c:amount>1.00</c:amount><c:authorizationCode>123456</c:authorizationCode><c:avsCode>Y</c:avsCode><c:avsCodeRaw>Y</c:avsCodeRaw><c:cvCode>M</c:cvCode><c:cvCodeRaw>M</c:cvCodeRaw><c:authorizedDateTime>2008-01-15T21:42:03Z</c:authorizedDateTime><c:processorResponse>00</c:processorResponse><c:authFactorCode>U</c:authFactorCode></c:ccAuthReply></c:replyMessage></soap:Body></soap:Envelope>
136
+ XML
137
+ end
126
138
 
127
139
  def successful_authorization_response
128
140
  <<-XML
@@ -130,7 +142,14 @@ class CyberSourceTest < Test::Unit::TestCase
130
142
  <soap:Header>
131
143
  <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-32551101"><wsu:Created>2007-07-12T18:31:53.838Z</wsu:Created></wsu:Timestamp></wsse:Security></soap:Header><soap:Body><c:replyMessage xmlns:c="urn:schemas-cybersource-com:transaction-data-1.26"><c:merchantReferenceCode>TEST11111111111</c:merchantReferenceCode><c:requestID>1842651133440156177166</c:requestID><c:decision>ACCEPT</c:decision><c:reasonCode>100</c:reasonCode><c:requestToken>AP4JY+Or4xRonEAOERAyMzQzOTEzMEM0MFZaNUZCBgDH3fgJ8AEGAMfd+AnwAwzRpAAA7RT/</c:requestToken><c:purchaseTotals><c:currency>USD</c:currency></c:purchaseTotals><c:ccAuthReply><c:reasonCode>100</c:reasonCode><c:amount>1.00</c:amount><c:authorizationCode>004542</c:authorizationCode><c:avsCode>A</c:avsCode><c:avsCodeRaw>I7</c:avsCodeRaw><c:authorizedDateTime>2007-07-12T18:31:53Z</c:authorizedDateTime><c:processorResponse>100</c:processorResponse><c:reconciliationID>23439130C40VZ2FB</c:reconciliationID></c:ccAuthReply></c:replyMessage></soap:Body></soap:Envelope>
132
144
  XML
133
-
145
+ end
146
+
147
+ def unsuccessful_authorization_response
148
+ <<-XML
149
+ <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
150
+ <soap:Header>
151
+ <wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-28121162"><wsu:Created>2008-01-15T21:50:41.580Z</wsu:Created></wsu:Timestamp></wsse:Security></soap:Header><soap:Body><c:replyMessage xmlns:c="urn:schemas-cybersource-com:transaction-data-1.26"><c:merchantReferenceCode>a1efca956703a2a5037178a8a28f7357</c:merchantReferenceCode><c:requestID>2004338415330008402434</c:requestID><c:decision>REJECT</c:decision><c:reasonCode>231</c:reasonCode><c:requestToken>Afvvj7KfIgU12gooCFE2/DanQIApt+G1OgTSA+R9PTnyhFTb0KRjgFY+ynyIFNdoKKAghwgx</c:requestToken><c:ccAuthReply><c:reasonCode>231</c:reasonCode></c:ccAuthReply></c:replyMessage></soap:Body></soap:Envelope>
152
+ XML
134
153
  end
135
154
 
136
155
  def successful_tax_response
@@ -10,7 +10,54 @@ class DataCashTest < Test::Unit::TestCase
10
10
  :password => 'PASSWORD'
11
11
  )
12
12
 
13
- @creditcard = credit_card('4242424242424242')
13
+ @credit_card = credit_card('4242424242424242')
14
+
15
+ @address = {
16
+ :name => 'Mark McBride',
17
+ :address1 => 'Flat 12/3',
18
+ :address2 => '45 Main Road',
19
+ :city => 'London',
20
+ :state => 'None',
21
+ :country => 'GBR',
22
+ :zip => 'A987AA',
23
+ :phone => '(555)555-5555'
24
+ }
25
+
26
+ @options = {
27
+ :order_id => generate_unique_id,
28
+ :billing_address => @address
29
+ }
30
+ end
31
+
32
+ def test_successful_purchase
33
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
34
+
35
+ response = @gateway.purchase(@amount, @credit_card, @options)
36
+ assert_instance_of Response, response
37
+ assert_success response
38
+ assert response.test?
39
+ assert_equal 'The transaction was successful', response.message
40
+ assert_equal '4400200050664928;123456789', response.authorization
41
+ end
42
+
43
+ def test_unsuccessful_purchase
44
+ @gateway.expects(:ssl_post).returns(failed_purchase_response)
45
+
46
+ response = @gateway.purchase(@amount, @credit_card, @options)
47
+ assert_instance_of Response, response
48
+ assert_failure response
49
+ assert response.test?
50
+ assert_equal 'Invalid reference number', response.message
51
+ end
52
+
53
+ def test_error_
54
+ @gateway.expects(:ssl_post).returns(failed_purchase_response)
55
+
56
+ response = @gateway.purchase(@amount, @credit_card, @options)
57
+ assert_instance_of Response, response
58
+ assert_failure response
59
+ assert response.test?
60
+ assert_equal 'Invalid reference number', response.message
14
61
  end
15
62
 
16
63
  def test_supported_countries
@@ -20,4 +67,38 @@ class DataCashTest < Test::Unit::TestCase
20
67
  def test_supported_card_types
21
68
  assert_equal [ :visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro, :switch, :solo, :laser ], DataCashGateway.supported_cardtypes
22
69
  end
70
+
71
+ private
72
+ def failed_purchase_response
73
+ <<-XML
74
+ <Response>
75
+ <status>22</status>
76
+ <time>1196414665</time>
77
+ <mode>TEST</mode>
78
+ <country>United Kingdom</country>
79
+ <merchantreference>2d24cc91284c1ed5c65d8821f1e752c7</merchantreference>
80
+ <issuer>Clydesdale Bank PLC</issuer>
81
+ <reason>Invalid reference number</reason>
82
+ <card_scheme>Solo</card_scheme>
83
+ <datacash_reference>4400200050664928</datacash_reference>
84
+ </Response>
85
+ XML
86
+ end
87
+
88
+ def successful_purchase_response
89
+ <<-XML
90
+ <Response>
91
+ <status>1</status>
92
+ <time>1196414665</time>
93
+ <mode>TEST</mode>
94
+ <country>United Kingdom</country>
95
+ <merchantreference>2d24cc91284c1ed5c65d8821f1e752c7</merchantreference>
96
+ <issuer>Clydesdale Bank PLC</issuer>
97
+ <reason>The transaction was successful</reason>
98
+ <card_scheme>Visa</card_scheme>
99
+ <datacash_reference>4400200050664928</datacash_reference>
100
+ <authcode>123456789</authcode>
101
+ </Response>
102
+ XML
103
+ end
23
104
  end
@@ -1,7 +1,6 @@
1
1
  require File.dirname(__FILE__) + '/../../test_helper'
2
2
 
3
3
  class EfsnetTest < Test::Unit::TestCase
4
- AMOUNT = 100
5
4
 
6
5
  def setup
7
6
  @gateway = EfsnetGateway.new(
@@ -9,62 +8,116 @@ class EfsnetTest < Test::Unit::TestCase
9
8
  :password => 'PASSWORD'
10
9
  )
11
10
 
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}
11
+ @credit_card = credit_card('4242424242424242')
12
+ @amount = 100
13
+ @options = { :order_id => 1, :billing_address => address }
24
14
  end
25
15
 
26
- def test_successful_request
27
- @creditcard.number = 1
28
- assert response = @gateway.purchase(AMOUNT, @creditcard, @options)
16
+ def test_successful_purchase
17
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
18
+
19
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
20
+ assert_instance_of Response, response
29
21
  assert_success response
30
- assert_equal '5555', response.authorization
31
22
  assert response.test?
23
+ assert_equal '100018347764;1.00', response.authorization
24
+ assert_equal 'Approved', response.message
25
+
32
26
  end
33
27
 
34
- def test_unsuccessful_request
35
- @creditcard.number = 2
36
- assert response = @gateway.purchase(AMOUNT, @creditcard, @options)
28
+ def test_unsuccessful_purchase
29
+ @gateway.expects(:ssl_post).returns(unsuccessful_purchase_response)
30
+
31
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
32
+ assert_instance_of Response, response
37
33
  assert_failure response
38
34
  assert response.test?
39
- end
40
-
41
- def test_request_error
42
- @creditcard.number = 3
43
- assert_raise(Error){ @gateway.purchase(AMOUNT, @creditcard, @options) }
35
+ assert_equal 'Declined', response.message
44
36
  end
45
37
 
46
38
  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)
39
+ params = {
40
+ :order_id => "order1",
41
+ :transaction_amount => "1.01",
42
+ :account_number => "4242424242424242",
43
+ :expiration_month => "12",
44
+ :expiration_year => "2029",
45
+ }
46
+
47
+ assert data = @gateway.send(:post_data, :credit_card_authorize, params)
48
+ assert REXML::Document.new(data)
57
49
  end
58
50
 
59
51
  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)
52
+ params = {
53
+ :order_id => "order1",
54
+ :transaction_amount => "1.01",
55
+ :original_transaction_amount => "1.01",
56
+ :original_transaction_id => "1",
57
+ }
58
+
59
+ assert data = @gateway.send(:post_data, :credit_card_settle, params)
60
+ assert REXML::Document.new(data)
61
+ end
62
+
63
+ def test_avs_result
64
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
65
+
66
+ response = @gateway.purchase(@amount, @credit_card, @options)
67
+ assert_equal 'N', response.avs_result['code']
68
+ end
69
+
70
+ def test_cvv_result
71
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
72
+
73
+ response = @gateway.purchase(@amount, @credit_card, @options)
74
+ assert_equal 'M', response.cvv_result['code']
75
+ end
76
+
77
+ private
78
+ def successful_purchase_response
79
+ <<-XML
80
+ <?xml version="1.0"?>
81
+ <Reply>
82
+ <TransactionReply>
83
+ <ResponseCode>0</ResponseCode>
84
+ <ResultCode>00</ResultCode>
85
+ <ResultMessage>APPROVED</ResultMessage>
86
+ <TransactionID>100018347764</TransactionID>
87
+ <AVSResponseCode>N</AVSResponseCode>
88
+ <CVVResponseCode>M</CVVResponseCode>
89
+ <ApprovalNumber>123456</ApprovalNumber>
90
+ <AuthorizationNumber>123456</AuthorizationNumber>
91
+ <TransactionDate>080117</TransactionDate>
92
+ <TransactionTime>163222</TransactionTime>
93
+ <ReferenceNumber>1</ReferenceNumber>
94
+ <AccountNumber>XXXXXXXXXXXX2224</AccountNumber>
95
+ <TransactionAmount>1.00</TransactionAmount>
96
+ </TransactionReply>
97
+ </Reply>
98
+ XML
99
+ end
100
+
101
+ def unsuccessful_purchase_response
102
+ <<-XML
103
+ <?xml version="1.0"?>
104
+ <Reply>
105
+ <TransactionReply>
106
+ <ResponseCode>256</ResponseCode>
107
+ <ResultCode>04</ResultCode>
108
+ <ResultMessage>DECLINED</ResultMessage>
109
+ <TransactionID>100018347784</TransactionID>
110
+ <AVSResponseCode>N</AVSResponseCode>
111
+ <CVVResponseCode/>
112
+ <ApprovalNumber/>
113
+ <AuthorizationNumber/>
114
+ <TransactionDate>080117</TransactionDate>
115
+ <TransactionTime>163946</TransactionTime>
116
+ <ReferenceNumber>1</ReferenceNumber>
117
+ <AccountNumber>XXXXXXXXXXXX2224</AccountNumber>
118
+ <TransactionAmount>1.56</TransactionAmount>
119
+ </TransactionReply>
120
+ </Reply>
121
+ XML
69
122
  end
70
123
  end