tomriley-active_merchant 1.4.2.3 → 1.4.2.4

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 (38) hide show
  1. data/CHANGELOG +14 -0
  2. data/CONTRIBUTERS +12 -0
  3. data/active_merchant.gemspec +3 -2
  4. data/init.rb +0 -1
  5. data/lib/active_merchant/billing/credit_card_methods.rb +1 -1
  6. data/lib/active_merchant/billing/expiry_date.rb +10 -4
  7. data/lib/active_merchant/billing/gateway.rb +4 -0
  8. data/lib/active_merchant/billing/gateways/authorize_net.rb +12 -1
  9. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +2 -1
  10. data/lib/active_merchant/billing/gateways/bogus.rb +19 -0
  11. data/lib/active_merchant/billing/gateways/eway.rb +6 -1
  12. data/lib/active_merchant/billing/gateways/first_pay.rb +172 -0
  13. data/lib/active_merchant/billing/gateways/merchant_ware.rb +283 -0
  14. data/lib/active_merchant/billing/gateways/ogone.rb +259 -0
  15. data/lib/active_merchant/billing/gateways/paypal.rb +22 -9
  16. data/lib/active_merchant/billing/gateways/{protx.rb → sage_pay.rb} +45 -12
  17. data/lib/active_merchant/billing/integrations/nochex/notification.rb +1 -1
  18. data/lib/active_merchant/billing/response.rb +9 -1
  19. data/test/fixtures.yml +16 -1
  20. data/test/remote/gateways/remote_first_pay_test.rb +87 -0
  21. data/test/remote/gateways/remote_merchant_ware_test.rb +113 -0
  22. data/test/remote/gateways/remote_ogone_test.rb +108 -0
  23. data/test/remote/gateways/remote_paypal_test.rb +12 -1
  24. data/test/remote/gateways/remote_protx_three_d_secure_test.rb +259 -0
  25. data/test/remote/gateways/{remote_protx_test.rb → remote_sage_pay_test.rb} +8 -8
  26. data/test/unit/credit_card_methods_test.rb +9 -0
  27. data/test/unit/expiry_date_test.rb +12 -1
  28. data/test/unit/gateways/bogus_test.rb +31 -0
  29. data/test/unit/gateways/first_pay_test.rb +125 -0
  30. data/test/unit/gateways/gateway_test.rb +6 -0
  31. data/test/unit/gateways/merchant_ware_test.rb +188 -0
  32. data/test/unit/gateways/ogone_test.rb +256 -0
  33. data/test/unit/gateways/paypal_test.rb +49 -0
  34. data/test/unit/gateways/sage_pay_test.rb +183 -0
  35. data/test/unit/integrations/notifications/nochex_notification_test.rb +1 -1
  36. data/test/unit/response_test.rb +16 -0
  37. metadata +16 -5
  38. data/test/unit/gateways/protx_test.rb +0 -139
@@ -1,15 +1,15 @@
1
1
  require 'test_helper'
2
2
 
3
- # Some of the standard tests have been removed at Protx test
3
+ # Some of the standard tests have been removed at SagePay test
4
4
  # server is pants and accepts anything and says Status=OK. (shift)
5
5
  # The tests for American Express will only pass if your account is
6
6
  # American express enabled.
7
- class RemoteProtxTest < Test::Unit::TestCase
7
+ class RemoteSagePayTest < Test::Unit::TestCase
8
8
  # set to true to run the tests in the simulated environment
9
- ProtxGateway.simulate = false
9
+ SagePayGateway.simulate = false
10
10
 
11
11
  def setup
12
- @gateway = ProtxGateway.new(fixtures(:protx))
12
+ @gateway = SagePayGateway.new(fixtures(:sage_pay))
13
13
 
14
14
  @amex = CreditCard.new(
15
15
  :number => '374200000000004',
@@ -148,7 +148,7 @@ class RemoteProtxTest < Test::Unit::TestCase
148
148
  def test_successful_purchase_and_void
149
149
  assert purchase = @gateway.purchase(@amount, @mastercard, @options)
150
150
  assert_success purchase
151
-
151
+
152
152
  assert void = @gateway.void(purchase.authorization)
153
153
  assert_success void
154
154
  end
@@ -199,11 +199,11 @@ class RemoteProtxTest < Test::Unit::TestCase
199
199
  assert response.test?
200
200
  assert !response.authorization.blank?
201
201
  end
202
-
202
+
203
203
  def test_invalid_login
204
- message = ProtxGateway.simulate ? 'VSP Simulator cannot find your vendor name. Ensure you have have supplied a Vendor field with your VSP Vendor name assigned to it.' : '3034 : The Vendor or VendorName value is required.'
204
+ message = SagePayGateway.simulate ? 'VSP Simulator cannot find your vendor name. Ensure you have have supplied a Vendor field with your VSP Vendor name assigned to it.' : '3034 : The Vendor or VendorName value is required.'
205
205
 
206
- gateway = ProtxGateway.new(
206
+ gateway = SagePayGateway.new(
207
207
  :login => ''
208
208
  )
209
209
  assert response = gateway.purchase(@amount, @mastercard, @options)
@@ -118,6 +118,15 @@ class CreditCardMethodsTest < Test::Unit::TestCase
118
118
 
119
119
  # Alternate format
120
120
  assert_equal 'laser', CreditCard.type?('6706950000000000000')
121
+
122
+ # Alternate format (16 digits)
123
+ assert_equal 'laser', CreditCard.type?('6706123456789012')
124
+
125
+ # New format (16 digits)
126
+ assert_equal 'laser', CreditCard.type?('6709123456789012')
127
+
128
+ # Ulster bank (Ireland) with 12 digits
129
+ assert_equal 'laser', CreditCard.type?('677117111234')
121
130
  end
122
131
 
123
132
  def test_should_detect_when_an_argument_type_does_not_match_calculated_type
@@ -8,7 +8,7 @@ class ExpiryDateTest < Test::Unit::TestCase
8
8
  end
9
9
 
10
10
  def test_today_should_not_be_expired
11
- today = Time.now
11
+ today = Time.now.utc
12
12
  date = CreditCard::ExpiryDate.new(today.month, today.year)
13
13
  assert_false date.expired?
14
14
  end
@@ -18,4 +18,15 @@ class ExpiryDateTest < Test::Unit::TestCase
18
18
  date = CreditCard::ExpiryDate.new(next_month.month, next_month.year)
19
19
  assert_false date.expired?
20
20
  end
21
+
22
+ def test_invalid_date
23
+ expiry = CreditCard::ExpiryDate.new(13, 2009)
24
+ assert_equal Time.at(0).utc, expiry.expiration
25
+ end
26
+
27
+ def test_month_and_year_coerced_to_integer
28
+ expiry = CreditCard::ExpiryDate.new("13", "2009")
29
+ assert_equal 13, expiry.month
30
+ assert_equal 2009, expiry.year
31
+ end
21
32
  end
@@ -20,6 +20,33 @@ class BogusTest < Test::Unit::TestCase
20
20
  @gateway.purchase(1000, @creditcard)
21
21
  end
22
22
 
23
+ def test_3d_secure_authorize
24
+ response = @gateway.authorize(1000, credit_card('4'))
25
+ assert response.three_d_secure?
26
+ assert_equal BogusGateway::THREE_D_PA_REQ, response.pa_req
27
+ assert_equal BogusGateway::THREE_D_MD, response.md
28
+ assert_equal BogusGateway::THREE_D_ACS_URL, response.acs_url
29
+ end
30
+
31
+ def test_3d_secure_purchase
32
+ response = @gateway.purchase(1000, credit_card('4'))
33
+ assert response.three_d_secure?
34
+ assert_equal BogusGateway::THREE_D_PA_REQ, response.pa_req
35
+ assert_equal BogusGateway::THREE_D_MD, response.md
36
+ assert_equal BogusGateway::THREE_D_ACS_URL, response.acs_url
37
+ end
38
+
39
+ def test_3d_complete
40
+ response = @gateway.three_d_complete(BogusGateway::THREE_D_PA_RES, BogusGateway::THREE_D_MD)
41
+ assert_equal BogusGateway::SUCCESS_MESSAGE, response.message
42
+
43
+ response = @gateway.three_d_complete('incorrect PaRes', BogusGateway::THREE_D_MD)
44
+ assert_equal BogusGateway::FAILURE_MESSAGE, response.message
45
+
46
+ response = @gateway.three_d_complete(BogusGateway::THREE_D_PA_RES, 'incorrect MD')
47
+ assert_equal BogusGateway::FAILURE_MESSAGE, response.message
48
+ end
49
+
23
50
  def test_credit
24
51
  @gateway.credit(1000, @response.params["transid"])
25
52
  end
@@ -36,6 +63,10 @@ class BogusTest < Test::Unit::TestCase
36
63
  @gateway.unstore('1')
37
64
  end
38
65
 
66
+ def test_supports_3d_secure
67
+ assert @gateway.supports_3d_secure
68
+ end
69
+
39
70
  def test_supported_countries
40
71
  assert_equal ['US'], BogusGateway.supported_countries
41
72
  end
@@ -0,0 +1,125 @@
1
+ require 'test_helper'
2
+
3
+ class FirstPayTest < Test::Unit::TestCase
4
+ def setup
5
+ @gateway = FirstPayGateway.new(:login => 'login', :password => 'password')
6
+
7
+ @credit_card = credit_card
8
+ @amount = 100
9
+
10
+ @options = {
11
+ :order_id => '1',
12
+ :billing_address => address,
13
+ :description => 'Store Purchase',
14
+ :ip => '127.0.0.1',
15
+ :email => 'test@test.com'
16
+ }
17
+ end
18
+
19
+ def test_successful_purchase
20
+ @gateway.expects(:ssl_post).returns(successful_purchase_response)
21
+
22
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
23
+ assert_success response
24
+
25
+ # Replace with authorization number from the successful response
26
+ assert_equal '57097598', response.authorization
27
+ assert response.test?
28
+ end
29
+
30
+ def test_failed_purchase
31
+ @gateway.expects(:ssl_post).returns(failed_purchase_response)
32
+
33
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
34
+ assert_failure response
35
+ assert_equal('DECLINE', response.message)
36
+ assert response.test?
37
+ end
38
+
39
+ def test_error_on_purchase
40
+ @gateway.expects(:ssl_post).returns(error_response)
41
+
42
+ assert response = @gateway.purchase(@amount, @credit_card, @options)
43
+ assert ! response.success?
44
+ assert_equal('704-MISSING BASIC DATA TYPE:card, exp, zip, addr, member, amount', response.message)
45
+ assert response.test?
46
+ end
47
+
48
+ def test_successful_credit
49
+ @gateway.expects(:ssl_post).returns(successful_credit_response)
50
+ @options[:credit_card] = @credit_card
51
+
52
+ assert response = @gateway.credit(@amount, '123456', @options)
53
+ assert_success response
54
+
55
+ assert_equal '53147613', response.authorization
56
+ assert response.test?
57
+ end
58
+
59
+ def test_failed_credit
60
+ @options[:credit_card] = @credit_card
61
+ @gateway.expects(:ssl_post).returns(failed_credit_response)
62
+
63
+ assert response = @gateway.credit(@amount, '123456', @options)
64
+ assert_failure response
65
+ assert_equal('PARENT TRANSACTION NOT FOUND', response.message)
66
+ assert response.test?
67
+ end
68
+
69
+ def test_failed_unlinked_credit
70
+ assert_raise ArgumentError do
71
+ @gateway.credit(@amount, @credit_card)
72
+ end
73
+ end
74
+
75
+ def test_successful_void
76
+ @gateway.expects(:ssl_post).returns(successful_void_response)
77
+ @options[:transactionid] = '123456'
78
+
79
+ assert response = @gateway.void(@amount, @credit_card, @options)
80
+ assert_success response
81
+
82
+ assert_equal '53147623', response.authorization
83
+ assert response.test?
84
+ end
85
+
86
+ def test_failed_void
87
+ @gateway.expects(:ssl_post).returns(failed_void_response)
88
+
89
+ assert response = @gateway.void(@amount, @credit_card, @options)
90
+ assert_failure response
91
+ assert_equal('PARENT TRANSACTION NOT FOUND', response.message)
92
+ assert response.test?
93
+ end
94
+
95
+
96
+ private
97
+
98
+ def successful_purchase_response
99
+ "CAPTURED:056708:NA:X:Jun 02 2009:241:NLS:NLS:NLS:57097598:9999:NA:NA:NA:NA:NA:NA:NA"
100
+ end
101
+
102
+ def failed_purchase_response
103
+ "NOT CAPTURED:DECLINE:NA:NA:Dec 11 2003:278654:NLS:NLS:NLS:53147611:200312111612:NA:NA:NA:NA:NA:NA"
104
+ end
105
+
106
+ def successful_credit_response
107
+ "CAPTURED:945101216:199641568:NA:Dec 11 2003:278655:NLS:NLS:NLS:53147613:200312111613:NA:NA:NA:NA:NA"
108
+ end
109
+
110
+ def failed_credit_response
111
+ "NOT CAPTURED:PARENT TRANSACTION NOT FOUND:NA:NA:Dec 11 2003:278614:NLS:NLS:NLS:53147499:200311251526:NA:NA:NA:NA:NA"
112
+ end
113
+
114
+ def successful_void_response
115
+ "CAPTURED:000000:NA:Y:Dec 11 2003:278659:NLS:NLS:NLS:53147623:200312111628:NA:NA:NA:NA:NA"
116
+ end
117
+
118
+ def failed_void_response
119
+ "NOT CAPTURED:PARENT TRANSACTION NOT FOUND:NA:NA:Dec 11 2003:278644:NLS:NLS:NLS:53147562:200311251526:NA:NA:NA:NA:NA"
120
+ end
121
+
122
+ def error_response
123
+ '!ERROR! 704-MISSING BASIC DATA TYPE:card, exp, zip, addr, member, amount'
124
+ end
125
+ end
@@ -9,6 +9,12 @@ class GatewayTest < Test::Unit::TestCase
9
9
  assert_false [:visa, :bogus].all? { |invalid_cardtype| Gateway.supports?(invalid_cardtype) }
10
10
  end
11
11
 
12
+ def test_should_be_able_to_check_for_3d_secure_support
13
+ assert !Gateway.supports_3d_secure
14
+ Gateway.supports_3d_secure = true
15
+ assert Gateway.supports_3d_secure
16
+ end
17
+
12
18
  def test_should_gateway_uses_ssl_strict_checking_by_default
13
19
  assert Gateway.ssl_strict
14
20
  end
@@ -0,0 +1,188 @@
1
+ require 'test_helper'
2
+
3
+ class MerchantWareTest < Test::Unit::TestCase
4
+ def setup
5
+ @gateway = MerchantWareGateway.new(
6
+ :login => 'login',
7
+ :password => 'password',
8
+ :name => 'name'
9
+ )
10
+
11
+ @credit_card = credit_card
12
+ @amount = 100
13
+
14
+ @options = {
15
+ :order_id => '1',
16
+ :billing_address => address
17
+ }
18
+ end
19
+
20
+ def test_successful_authorization
21
+ @gateway.expects(:ssl_post).returns(successful_authorization_response)
22
+
23
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
24
+ assert_instance_of Response, response
25
+ assert_success response
26
+
27
+ assert_equal '4706382;1', response.authorization
28
+ assert_equal "APPROVED", response.message
29
+ assert response.test?
30
+ end
31
+
32
+ def test_soap_fault_during_authorization
33
+ response_500 = stub(:code => "500", :message => "Internal Server Error", :body => fault_authorization_response)
34
+ @gateway.expects(:ssl_post).raises(ActiveMerchant::ResponseError.new(response_500))
35
+
36
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
37
+ assert_instance_of Response, response
38
+ assert_failure response
39
+ assert response.test?
40
+
41
+ assert_nil response.authorization
42
+ assert_equal "Server was unable to process request. ---> strPAN should be at least 13 to at most 19 characters in size. Parameter name: strPAN", response.message
43
+ assert_equal response_500.code, response.params["http_code"]
44
+ assert_equal response_500.message, response.params["http_message"]
45
+ end
46
+
47
+ def test_failed_authorization
48
+ @gateway.expects(:ssl_post).returns(failed_authorization_response)
49
+
50
+ assert response = @gateway.authorize(@amount, @credit_card, @options)
51
+ assert_instance_of Response, response
52
+ assert_failure response
53
+ assert response.test?
54
+
55
+ assert_nil response.authorization
56
+ assert_equal "transaction type not supported by version", response.message
57
+ assert_equal "FAILED", response.params["status"]
58
+ assert_equal "1014", response.params["failure_code"]
59
+ end
60
+
61
+ def test_failed_void
62
+ @gateway.expects(:ssl_post).returns(failed_void_response)
63
+
64
+ assert response = @gateway.void("1")
65
+ assert_instance_of Response, response
66
+ assert_failure response
67
+ assert response.test?
68
+
69
+ assert_nil response.authorization
70
+ assert_equal "decline", response.message
71
+ assert_equal "DECLINED", response.params["status"]
72
+ assert_equal "1012", response.params["failure_code"]
73
+ end
74
+
75
+ def test_avs_result
76
+ @gateway.expects(:ssl_post).returns(successful_authorization_response)
77
+
78
+ response = @gateway.authorize(@amount, @credit_card, @options)
79
+ assert_equal 'N', response.avs_result['code']
80
+ end
81
+
82
+ def test_cvv_result
83
+ @gateway.expects(:ssl_post).returns(successful_authorization_response)
84
+
85
+ response = @gateway.authorize(@amount, @credit_card, @options)
86
+ assert_equal 'M', response.cvv_result['code']
87
+ end
88
+
89
+ private
90
+
91
+ def successful_authorization_response
92
+ <<-XML
93
+ <?xml version="1.0" encoding="utf-8"?>
94
+ <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">
95
+ <soap:Body>
96
+ <IssueKeyedPreAuthResponse xmlns="http://merchantwarehouse.com/MerchantWARE/Client/TransactionRetail">
97
+ <IssueKeyedPreAuthResult>
98
+ <ReferenceID>4706382</ReferenceID>
99
+ <OrderNumber>1</OrderNumber>
100
+ <TXDate>7/3/2009 2:05:04 AM</TXDate>
101
+ <ApprovalStatus>APPROVED</ApprovalStatus>
102
+ <AuthCode>VI0100</AuthCode>
103
+ <CardHolder>Longbob Longsen</CardHolder>
104
+ <Amount>1.00</Amount>
105
+ <Type>5</Type>
106
+ <CardNumber>************4242</CardNumber>
107
+ <CardType>0</CardType>
108
+ <AVSResponse>N</AVSResponse>
109
+ <CVResponse>M</CVResponse>
110
+ <POSEntryType>1</POSEntryType>
111
+ </IssueKeyedPreAuthResult>
112
+ </IssueKeyedPreAuthResponse>
113
+ </soap:Body>
114
+ </soap:Envelope>
115
+ XML
116
+ end
117
+
118
+ def fault_authorization_response
119
+ <<-XML
120
+ <?xml version="1.0" encoding="utf-8"?>
121
+ <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">
122
+ <soap:Body>
123
+ <soap:Fault>
124
+ <faultcode>soap:Server</faultcode>
125
+ <faultstring>Server was unable to process request. ---&gt; strPAN should be at least 13 to at most 19 characters in size.
126
+ Parameter name: strPAN</faultstring>
127
+ <detail/>
128
+ </soap:Fault>
129
+ </soap:Body>
130
+ </soap:Envelope>
131
+ XML
132
+ end
133
+
134
+ def failed_authorization_response
135
+ <<-XML
136
+ <?xml version="1.0" encoding="utf-8"?>
137
+ <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">
138
+ <soap:Body>
139
+ <IssueKeyedPreAuthResponse xmlns="http://merchantwarehouse.com/MerchantWARE/Client/TransactionRetail">
140
+ <IssueKeyedPreAuthResult>
141
+ <ReferenceID/>
142
+ <OrderNumber>1</OrderNumber>
143
+ <TXDate>7/3/2009 3:04:33 AM</TXDate>
144
+ <ApprovalStatus>FAILED;1014;transaction type not supported by version</ApprovalStatus>
145
+ <AuthCode/>
146
+ <CardHolder>Longbob Longsen</CardHolder>
147
+ <Amount>1.00</Amount>
148
+ <Type>5</Type>
149
+ <CardNumber>*********0123</CardNumber>
150
+ <CardType>0</CardType>
151
+ <AVSResponse/>
152
+ <CVResponse/>
153
+ <POSEntryType>1</POSEntryType>
154
+ </IssueKeyedPreAuthResult>
155
+ </IssueKeyedPreAuthResponse>
156
+ </soap:Body>
157
+ </soap:Envelope>
158
+ XML
159
+ end
160
+
161
+ def failed_void_response
162
+ <<-XML
163
+ <?xml version="1.0" encoding="utf-8"?>
164
+ <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">
165
+ <soap:Body>
166
+ <IssueVoidResponse xmlns="http://merchantwarehouse.com/MerchantWARE/Client/TransactionRetail">
167
+ <IssueVoidResult>
168
+ <ReferenceID>4707277</ReferenceID>
169
+ <OrderNumber/>
170
+ <TXDate>7/3/2009 3:28:38 AM</TXDate>
171
+ <ApprovalStatus>DECLINED;1012;decline</ApprovalStatus>
172
+ <AuthCode/>
173
+ <CardHolder/>
174
+ <Amount/>
175
+ <Type>3</Type>
176
+ <CardNumber/>
177
+ <CardType>0</CardType>
178
+ <AVSResponse/>
179
+ <CVResponse/>
180
+ <POSEntryType>0</POSEntryType>
181
+ </IssueVoidResult>
182
+ </IssueVoidResponse>
183
+ </soap:Body>
184
+ </soap:Envelope>
185
+ XML
186
+ end
187
+
188
+ end