activemerchant 1.4.1 → 1.4.2

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 (46) hide show
  1. data.tar.gz.sig +0 -0
  2. data/CHANGELOG +28 -0
  3. data/Rakefile +2 -4
  4. data/lib/active_merchant/billing/credit_card.rb +2 -0
  5. data/lib/active_merchant/billing/gateways/authorize_net.rb +13 -0
  6. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +1 -1
  7. data/lib/active_merchant/billing/gateways/bogus.rb +13 -1
  8. data/lib/active_merchant/billing/gateways/braintree.rb +13 -5
  9. data/lib/active_merchant/billing/gateways/card_stream.rb +1 -5
  10. data/lib/active_merchant/billing/gateways/moneris.rb +1 -1
  11. data/lib/active_merchant/billing/gateways/pay_junction.rb +9 -3
  12. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +2 -8
  13. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +1 -1
  14. data/lib/active_merchant/billing/gateways/psl_card.rb +7 -3
  15. data/lib/active_merchant/billing/gateways/quickpay.rb +84 -54
  16. data/lib/active_merchant/billing/gateways/sage.rb +1 -0
  17. data/lib/active_merchant/billing/gateways/trust_commerce.rb +5 -1
  18. data/lib/active_merchant/billing/gateways/wirecard.rb +20 -19
  19. data/lib/active_merchant/billing/integrations.rb +1 -0
  20. data/lib/active_merchant/billing/integrations/quickpay.rb +18 -0
  21. data/lib/active_merchant/billing/integrations/quickpay/helper.rb +72 -0
  22. data/lib/active_merchant/billing/integrations/quickpay/notification.rb +74 -0
  23. data/lib/active_merchant/lib/country.rb +21 -3
  24. data/lib/active_merchant/lib/posts_data.rb +54 -34
  25. data/lib/active_merchant/lib/requires_parameters.rb +1 -1
  26. data/test/fixtures.yml +19 -3
  27. data/test/remote/gateways/remote_braintree_test.rb +11 -4
  28. data/test/remote/gateways/remote_card_stream_test.rb +20 -20
  29. data/test/remote/gateways/remote_psl_card_test.rb +23 -4
  30. data/test/remote/gateways/remote_quickpay_test.rb +17 -9
  31. data/test/remote/gateways/remote_wirecard_test.rb +3 -2
  32. data/test/test_helper.rb +3 -2
  33. data/test/unit/credit_card_test.rb +7 -0
  34. data/test/unit/gateways/authorize_net_cim_test.rb +2 -5
  35. data/test/unit/gateways/authorize_net_test.rb +16 -6
  36. data/test/unit/gateways/bogus_test.rb +4 -0
  37. data/test/unit/gateways/moneris_test.rb +1 -1
  38. data/test/unit/gateways/payflow_test.rb +6 -2
  39. data/test/unit/gateways/quickpay_test.rb +8 -8
  40. data/test/unit/gateways/trust_commerce_test.rb +12 -0
  41. data/test/unit/integrations/helpers/quickpay_helper_test.rb +40 -0
  42. data/test/unit/integrations/notifications/quickpay_notification_test.rb +69 -0
  43. data/test/unit/integrations/quickpay_module_test.rb +9 -0
  44. metadata +10 -5
  45. metadata.gz.sig +0 -0
  46. data/lib/tasks/cia.rb +0 -90
@@ -6,7 +6,7 @@ module ActiveMerchant #:nodoc:
6
6
  raise ArgumentError.new("Missing required parameter: #{param.first}") unless hash.has_key?(param.first)
7
7
 
8
8
  valid_options = param[1..-1]
9
- raise ArgumentError.new("Parameter: #{param.first} must be one of #{valid_options.to_sentence(:connector => 'or')}") unless valid_options.include?(hash[param.first])
9
+ raise ArgumentError.new("Parameter: #{param.first} must be one of #{valid_options.to_sentence(:words_connector => 'or')}") unless valid_options.include?(hash[param.first])
10
10
  else
11
11
  raise ArgumentError.new("Missing required parameter: #{param}") unless hash.has_key?(param)
12
12
  end
data/test/fixtures.yml CHANGED
@@ -172,11 +172,27 @@ psl_visa_address:
172
172
  address2:
173
173
  address3:
174
174
  city:
175
- zip:
175
+ zip:
176
+
177
+ psl_visa_debit:
178
+ first_name:
179
+ last_name:
180
+ number:
181
+ month:
182
+ year:
183
+ verification_value:
184
+
185
+ psl_visa_debit_address:
186
+ address1:
187
+ address2:
188
+ address3:
189
+ city:
190
+ state:
191
+ zip:
176
192
 
177
193
  quickpay:
178
- login: X
179
- password: Y
194
+ login: 89898989
195
+ password: "n5KrR5e2538awi9hUk6728LHTQ6E4uG1z4IFSb2pPN9j76DqJ2vA4698X315M1cd"
180
196
 
181
197
  realex:
182
198
  login: X
@@ -5,7 +5,8 @@ class RemoteBraintreeTest < Test::Unit::TestCase
5
5
  @gateway = BraintreeGateway.new(fixtures(:braintree))
6
6
 
7
7
  @amount = rand(10000) + 1001
8
- @credit_card = credit_card('4111111111111111', :type => 'visa')
8
+ @credit_card = credit_card('4111111111111111')
9
+ @check = check()
9
10
  @declined_amount = rand(99)
10
11
  @options = { :order_id => generate_unique_id,
11
12
  :billing_address => address
@@ -33,7 +34,7 @@ class RemoteBraintreeTest < Test::Unit::TestCase
33
34
  :account_holder_type => 'personal',
34
35
  :account_type => 'checking'
35
36
  )
36
- assert response = @gateway.purchase(@amount, check, @options)
37
+ assert response = @gateway.purchase(@amount, @check, @options)
37
38
  assert_equal 'This transaction has been approved', response.message
38
39
  assert_success response
39
40
  end
@@ -48,7 +49,7 @@ class RemoteBraintreeTest < Test::Unit::TestCase
48
49
 
49
50
  def test_successful_add_to_vault_with_store_method
50
51
  assert response = @gateway.store(@credit_card)
51
- assert_equal 'This transaction has been approved', response.message
52
+ assert_equal 'Customer Added', response.message
52
53
  assert_success response
53
54
  assert_not_nil response.params["customer_vault_id"]
54
55
  end
@@ -76,11 +77,17 @@ class RemoteBraintreeTest < Test::Unit::TestCase
76
77
  def test_add_to_vault_with_custom_vault_id_with_store_method
77
78
  @options[:billing_id] = rand(100000)+10001
78
79
  assert response = @gateway.store(@credit_card, @options.dup)
79
- assert_equal 'This transaction has been approved', response.message
80
+ assert_equal 'Customer Added', response.message
80
81
  assert_success response
81
82
  assert_equal @options[:billing_id], response.params["customer_vault_id"].to_i
82
83
  end
83
84
 
85
+ def test_add_to_vault_with_store_and_check
86
+ assert response = @gateway.store(@check, @options)
87
+ assert_equal 'Customer Added', response.message
88
+ assert_success response
89
+ end
90
+
84
91
  def test_update_vault
85
92
  test_add_to_vault_with_custom_vault_id
86
93
  @credit_card = credit_card('4111111111111111', :month => 10)
@@ -7,38 +7,38 @@ class RemoteCardStreamTest < Test::Unit::TestCase
7
7
  @gateway = CardStreamGateway.new(fixtures(:card_stream))
8
8
 
9
9
  @amex = credit_card('374245455400001',
10
- :month => 12,
11
- :year => 2009,
12
- :verification_value => 4887,
10
+ :month => '12',
11
+ :year => '2009',
12
+ :verification_value => '4887',
13
13
  :type => :american_express
14
14
  )
15
15
 
16
- @uk_maestro = credit_card('6759016800000120097',
17
- :month => 6,
18
- :year => 2009,
19
- :issue_number => 1,
20
- :verification_value => 701,
16
+ @uk_maestro = credit_card('675940410531100173',
17
+ :month => '12',
18
+ :year => '2008',
19
+ :issue_number => '0',
20
+ :verification_value => '134',
21
21
  :type => :switch
22
22
  )
23
23
 
24
- @solo = credit_card('6334960300099354',
25
- :month => 6,
26
- :year => 2008,
27
- :issue_number => 1,
28
- :verification_value => 227,
24
+ @solo = credit_card('676740340572345678',
25
+ :month => '12',
26
+ :year => '2008',
27
+ :issue_number => '1',
28
+ :verification_value => '773',
29
29
  :type => :solo
30
30
  )
31
31
 
32
32
  @mastercard = credit_card('5301250070000191',
33
- :month => 12,
34
- :year => 2009,
35
- :verification_value => 419,
33
+ :month => '12',
34
+ :year => '2009',
35
+ :verification_value => '419',
36
36
  :type => :master
37
37
  )
38
38
 
39
39
  @declined_card = credit_card('4000300011112220',
40
- :month => 9,
41
- :year => 2009
40
+ :month => '9',
41
+ :year => '2009'
42
42
  )
43
43
 
44
44
  @mastercard_options = {
@@ -135,13 +135,13 @@ class RemoteCardStreamTest < Test::Unit::TestCase
135
135
  :password => ''
136
136
  )
137
137
  assert response = gateway.purchase(100, @mastercard, @mastercard_options)
138
- assert_equal 'Merchant ID or Password Error', response.message
138
+ assert_equal 'MERCHANT ID MISSING', response.message
139
139
  assert_failure response
140
140
  end
141
141
 
142
142
  def test_unsupported_merchant_currency
143
143
  assert response = @gateway.purchase(100, @mastercard, @mastercard_options.update(:currency => 'USD'))
144
- assert_equal "ERROR 5456:CURRENCY NOT SUPPORTED FOR THIS MERCHANT ACCOUNT", response.message
144
+ assert_equal "ERROR 1052", response.message
145
145
  assert_failure response
146
146
  assert response.test?
147
147
  end
@@ -16,6 +16,9 @@ class RemotePslCardTest < Test::Unit::TestCase
16
16
  @visa = CreditCard.new(fixtures(:psl_visa))
17
17
  @visa_address = fixtures(:psl_visa_address)
18
18
 
19
+ @visa_debit = CreditCard.new(fixtures(:psl_visa_debit))
20
+ @visa_address = fixtures(:psl_visa_debit_address)
21
+
19
22
  # The test results are determined by the amount of the transaction
20
23
  @accept_amount = 1000
21
24
  @referred_amount = 6000
@@ -31,6 +34,22 @@ class RemotePslCardTest < Test::Unit::TestCase
31
34
  assert response.test?
32
35
  end
33
36
 
37
+ def test_successful_visa_debit_purchase
38
+ response = @gateway.purchase(@accept_amount, @visa_debit,
39
+ :billing_address => @visa_debit_address
40
+ )
41
+ assert_success response
42
+ end
43
+
44
+ # Fix regression discovered in production
45
+ def test_visa_debit_purchase_should_not_send_debit_info_if_present
46
+ @visa_debit.start_month = "07"
47
+ response = @gateway.purchase(@accept_amount, @visa_debit,
48
+ :billing_address => @visa_debit_address
49
+ )
50
+ assert_success response
51
+ end
52
+
34
53
  def test_successful_visa_purchase_specifying_currency
35
54
  response = @gateway.purchase(@accept_amount, @visa,
36
55
  :billing_address => @visa_address,
@@ -73,8 +92,8 @@ class RemotePslCardTest < Test::Unit::TestCase
73
92
  end
74
93
 
75
94
  def test_successful_authorization
76
- response = @gateway.authorize(@accept_amount, @uk_maestro,
77
- :billing_address => @uk_maestro_address
95
+ response = @gateway.authorize(@accept_amount, @visa,
96
+ :billing_address => @visa_address
78
97
  )
79
98
  assert_success response
80
99
  assert response.test?
@@ -92,8 +111,8 @@ class RemotePslCardTest < Test::Unit::TestCase
92
111
  end
93
112
 
94
113
  def test_successful_authorization_and_capture
95
- authorization = @gateway.authorize(@accept_amount, @uk_maestro,
96
- :billing_address => @uk_maestro_address
114
+ authorization = @gateway.authorize(@accept_amount, @visa,
115
+ :billing_address => @visa_address
97
116
  )
98
117
  assert_success authorization
99
118
  assert authorization.test?
@@ -6,7 +6,7 @@ class RemoteQuickpayTest < Test::Unit::TestCase
6
6
 
7
7
  @amount = 100
8
8
  @options = {
9
- :order_id => generate_unique_id,
9
+ :order_id => generate_unique_id[0...10],
10
10
  :billing_address => address
11
11
  }
12
12
 
@@ -65,7 +65,7 @@ class RemoteQuickpayTest < Test::Unit::TestCase
65
65
  end
66
66
 
67
67
  def test_successful_diners_club_authorization
68
- assert response = @gateway.authorize(@amount, @diners_club, @options)
68
+ assert response = @gateway.authorize(@amount, @diners_club, @options)
69
69
  assert_success response
70
70
  assert !response.authorization.blank?
71
71
  assert_equal 'Diners', response.params['cardtype']
@@ -75,7 +75,7 @@ class RemoteQuickpayTest < Test::Unit::TestCase
75
75
  assert response = @gateway.authorize(@amount, @diners_club_dk, @options)
76
76
  assert_success response
77
77
  assert !response.authorization.blank?
78
- assert_equal 'Diners', response.params['cardtype']
78
+ assert_equal 'Diners-DK', response.params['cardtype']
79
79
  end
80
80
 
81
81
  def test_successful_maestro_authorization
@@ -89,7 +89,7 @@ class RemoteQuickpayTest < Test::Unit::TestCase
89
89
  assert response = @gateway.authorize(@amount, @maestro_dk, @options)
90
90
  assert_success response
91
91
  assert !response.authorization.blank?
92
- assert_equal 'Maestro', response.params['cardtype']
92
+ assert_equal 'Maestro-DK', response.params['cardtype']
93
93
  end
94
94
 
95
95
  def test_successful_mastercard_dk_authorization
@@ -122,9 +122,10 @@ class RemoteQuickpayTest < Test::Unit::TestCase
122
122
 
123
123
  def test_unsuccessful_purchase_with_missing_cvv2
124
124
  assert response = @gateway.purchase(@amount, @visa_no_cvv2, @options)
125
- assert_equal 'Missing/error in card verification data', response.message
126
- assert_failure response
127
- assert response.authorization.blank?
125
+ # Quickpay has made the cvd field optional in order to support forbrugsforeningen cards which don't have them
126
+ assert_equal 'OK', response.message
127
+ assert_success response
128
+ assert !response.authorization.blank?
128
129
  end
129
130
 
130
131
  def test_successful_authorize_and_capture
@@ -140,7 +141,7 @@ class RemoteQuickpayTest < Test::Unit::TestCase
140
141
  def test_failed_capture
141
142
  assert response = @gateway.capture(@amount, '')
142
143
  assert_failure response
143
- assert_equal 'Missing/error in transaction number', response.message
144
+ assert_equal 'Missing field: transaction', response.message
144
145
  end
145
146
 
146
147
  def test_successful_purchase_and_void
@@ -170,13 +171,20 @@ class RemoteQuickpayTest < Test::Unit::TestCase
170
171
  assert_success credit
171
172
  end
172
173
 
174
+ def test_successful_store_and_reference_purchase
175
+ assert store = @gateway.store(@visa, @options.merge(:description => "New subscription"))
176
+ assert_success store
177
+ assert purchase = @gateway.purchase(@amount, store.authorization, @options.merge(:order_id => generate_unique_id[0...10]))
178
+ assert_success purchase
179
+ end
180
+
173
181
  def test_invalid_login
174
182
  gateway = QuickpayGateway.new(
175
183
  :login => '',
176
184
  :password => ''
177
185
  )
178
186
  assert response = gateway.purchase(@amount, @visa, @options)
179
- assert_equal 'Missing/error in merchant', response.message
187
+ assert_equal 'Invalid merchant id', response.message
180
188
  assert_failure response
181
189
  end
182
190
  end
@@ -56,14 +56,15 @@ class RemoteWirecardTest < Test::Unit::TestCase
56
56
 
57
57
  def test_wrong_creditcard_purchase
58
58
  assert response = @gateway.purchase(@amount, @declined_card, @options)
59
+ assert response.test?
59
60
  assert_failure response
60
- assert response.message[ /Credit card number not allowed in demo mode/ ]
61
+ assert response.message[ /Credit card number not allowed in demo mode/ ], "Got wrong response message"
61
62
  end
62
63
 
63
64
  def test_unauthorized_capture
64
65
  assert response = @gateway.capture(@amount, "1234567890123456789012")
65
66
  assert_failure response
66
- assert response.message == "Could not find referenced transaction for GuWID 1234567890123456789012."
67
+ assert_equal "Could not find referenced transaction for GuWID 1234567890123456789012.", response.message
67
68
  end
68
69
 
69
70
  def test_invalid_login
data/test/test_helper.rb CHANGED
@@ -112,8 +112,9 @@ end
112
112
  module Test
113
113
  module Unit
114
114
  class TestCase
115
- LOCAL_CREDENTIALS = ENV['HOME'] + '/.active_merchant/fixtures.yml' unless defined?(LOCAL_CREDENTIALS)
116
- DEFAULT_CREDENTIALS = File.dirname(__FILE__) + '/fixtures.yml' unless defined?(DEFAULT_CREDENTIALS)
115
+ HOME_DIR = RUBY_PLATFORM =~ /mswin32/ ? ENV['HOMEPATH'] : ENV['HOME'] unless defined?(HOME_DIR)
116
+ LOCAL_CREDENTIALS = File.join(HOME_DIR.to_s, '.active_merchant/fixtures.yml') unless defined?(LOCAL_CREDENTIALS)
117
+ DEFAULT_CREDENTIALS = File.join(File.dirname(__FILE__), 'fixtures.yml') unless defined?(DEFAULT_CREDENTIALS)
117
118
 
118
119
  include ActiveMerchant::Billing
119
120
  include ActiveMerchant::Assertions
@@ -152,6 +152,13 @@ class CreditCardTest < Test::Unit::TestCase
152
152
  assert_valid @visa
153
153
  end
154
154
 
155
+
156
+ def test_should_be_valid_with_start_month_and_year_as_string
157
+ @solo.start_month = '2'
158
+ @solo.start_year = '2007'
159
+ assert_valid @solo
160
+ end
161
+
155
162
  def test_should_identify_wrong_cardtype
156
163
  c = credit_card(:type => 'master')
157
164
  assert_not_valid c
@@ -44,11 +44,8 @@ class AuthorizeNetCimTest < Test::Unit::TestCase
44
44
  end
45
45
 
46
46
  def test_expdate_formatting
47
- assert_equal '2009-09', @gateway.send(:expdate, @credit_card)
48
-
49
- assert_equal '2013-11', @gateway.send(:expdate, credit_card('4111111111111111',
50
- :month => 11,
51
- :year => 2013))
47
+ assert_equal '2009-09', @gateway.send(:expdate, credit_card('4111111111111111', :month => "9", :year => "2009"))
48
+ assert_equal '2013-11', @gateway.send(:expdate, credit_card('4111111111111111', :month => "11", :year => "2013"))
52
49
  end
53
50
 
54
51
  def test_should_create_customer_profile_request
@@ -73,6 +73,20 @@ class AuthorizeNetTest < Test::Unit::TestCase
73
73
  assert_equal 'My Purchase is great', result[:description]
74
74
  end
75
75
 
76
+ def test_add_duplicate_window_without_duplicate_window
77
+ result = {}
78
+ ActiveMerchant::Billing::AuthorizeNetGateway.duplicate_window = nil
79
+ @gateway.send(:add_duplicate_window, result)
80
+ assert_nil result[:duplicate_window]
81
+ end
82
+
83
+ def test_add_duplicate_window_with_duplicate_window
84
+ result = {}
85
+ ActiveMerchant::Billing::AuthorizeNetGateway.duplicate_window = 0
86
+ @gateway.send(:add_duplicate_window, result)
87
+ assert_equal 0, result[:duplicate_window]
88
+ end
89
+
76
90
  def test_purchase_is_valid_csv
77
91
  params = { :amount => '1.01' }
78
92
 
@@ -193,15 +207,11 @@ class AuthorizeNetTest < Test::Unit::TestCase
193
207
  end
194
208
 
195
209
  def test_expdate_formatting
196
- assert_equal '2009-09', @gateway.send(:arb_expdate, @credit_card)
197
-
198
- assert_equal '2013-11', @gateway.send(:arb_expdate, credit_card('4111111111111111',
199
- :month => 11,
200
- :year => 2013))
210
+ assert_equal '2009-09', @gateway.send(:arb_expdate, credit_card('4111111111111111', :month => "9", :year => "2009"))
211
+ assert_equal '2013-11', @gateway.send(:arb_expdate, credit_card('4111111111111111', :month => "11", :year => "2013"))
201
212
  end
202
213
 
203
214
  private
204
-
205
215
  def post_data_fixture
206
216
  'x_encap_char=%24&x_card_num=4242424242424242&x_exp_date=0806&x_card_code=123&x_type=AUTH_ONLY&x_first_name=Longbob&x_version=3.1&x_login=X&x_last_name=Longsen&x_tran_key=Y&x_relay_response=FALSE&x_delim_data=TRUE&x_delim_char=%2C&x_amount=1.01'
207
217
  end
@@ -23,6 +23,10 @@ class BogusTest < Test::Unit::TestCase
23
23
  def test_credit
24
24
  @gateway.credit(1000, @response.params["transid"])
25
25
  end
26
+
27
+ def test_void
28
+ @gateway.void(@response.params["transid"])
29
+ end
26
30
 
27
31
  def test_store
28
32
  @gateway.store(@creditcard)
@@ -87,7 +87,7 @@ class MonerisTest < Test::Unit::TestCase
87
87
  end
88
88
 
89
89
  def test_supported_card_types
90
- assert_equal [:visa, :master], MonerisGateway.supported_cardtypes
90
+ assert_equal [:visa, :master, :american_express], MonerisGateway.supported_cardtypes
91
91
  end
92
92
 
93
93
  def test_should_raise_error_if_transaction_param_empty_on_credit_request
@@ -91,6 +91,12 @@ class PayflowTest < Test::Unit::TestCase
91
91
  assert_equal 'PayPal', gateway.options[:partner]
92
92
  end
93
93
 
94
+ def test_partner_class_accessor_used_when_passed_in_partner_is_blank
95
+ assert_equal 'PayPal', PayflowGateway.partner
96
+ gateway = PayflowGateway.new(:login => 'test', :password => 'test', :partner => '')
97
+ assert_equal 'PayPal', gateway.options[:partner]
98
+ end
99
+
94
100
  def test_passed_in_partner_overrides_class_accessor
95
101
  assert_equal 'PayPal', PayflowGateway.partner
96
102
  gateway = PayflowGateway.new(:login => 'test', :password => 'test', :partner => 'PayPalUk')
@@ -98,14 +104,12 @@ class PayflowTest < Test::Unit::TestCase
98
104
  end
99
105
 
100
106
  def test_express_instance
101
- PayflowGateway.certification_id = '123456'
102
107
  gateway = PayflowGateway.new(
103
108
  :login => 'test',
104
109
  :password => 'password'
105
110
  )
106
111
  express = gateway.express
107
112
  assert_instance_of PayflowExpressGateway, express
108
- assert_equal '123456', express.options[:certification_id]
109
113
  assert_equal 'PayPal', express.options[:partner]
110
114
  assert_equal 'test', express.options[:login]
111
115
  assert_equal 'password', express.options[:password]