exact4r 0.9.3 → 1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. data/CHANGELOG +3 -0
  2. data/README +0 -11
  3. data/Rakefile +38 -6
  4. data/VERSION +1 -1
  5. data/lib/ews/transaction/request.rb +4 -0
  6. data/lib/ews/transaction/validator.rb +2 -0
  7. data/lib/ews/transporter.rb +4 -2
  8. data/test/credentials.rb +62 -0
  9. data/test/credentials.yml +53 -0
  10. data/test/exhaustive/batch_query_close_test.rb +193 -0
  11. data/test/exhaustive/forced_post_test.rb +3 -3
  12. data/test/exhaustive/online_debit_purchase_test.rb +9 -5
  13. data/test/exhaustive/online_debit_refund_test.rb +9 -5
  14. data/test/exhaustive/pre_auth_completion_test.rb +3 -3
  15. data/test/exhaustive/pre_auth_only_test.rb +9 -3
  16. data/test/exhaustive/pre_auth_test.rb +3 -3
  17. data/test/exhaustive/purchase_correction_test.rb +13 -7
  18. data/test/exhaustive/purchase_test.rb +3 -3
  19. data/test/exhaustive/recurring_seed_pre_auth_test.rb +3 -3
  20. data/test/exhaustive/recurring_seed_purchase_test.rb +3 -3
  21. data/test/exhaustive/refund_correction_test.rb +12 -6
  22. data/test/exhaustive/refund_test.rb +3 -3
  23. data/test/exhaustive/secure_storage_test.rb +3 -3
  24. data/test/exhaustive/tagged_online_debit_refund_test.rb +64 -37
  25. data/test/exhaustive/tagged_pre_auth_completion_test.rb +8 -8
  26. data/test/exhaustive/tagged_pre_auth_test.rb +8 -8
  27. data/test/exhaustive/tagged_purchase_test.rb +8 -8
  28. data/test/exhaustive/tagged_refund_test.rb +9 -9
  29. data/test/exhaustive/tagged_void_test.rb +24 -10
  30. data/test/exhaustive/transaction_details_test.rb +8 -6
  31. data/test/exhaustive/void_test.rb +9 -3
  32. data/test/general/avs_test.rb +7 -7
  33. data/test/general/request_test.rb +20 -37
  34. data/test/general/transporter_test.rb +6 -6
  35. data/test/general/validator_test.rb +2 -2
  36. data/test/test_helper.rb +8 -18
  37. metadata +5 -27
  38. data/doc/classes/EWS/Transaction/FakeResponse.html +0 -451
  39. data/doc/classes/EWS/Transaction/Request.html +0 -469
  40. data/doc/classes/EWS/Transaction/Response.html +0 -472
  41. data/doc/classes/EWS/Transaction/Validator.html +0 -182
  42. data/doc/classes/EWS/Transporter.html +0 -269
  43. data/doc/classes/REXML/Document.html +0 -176
  44. data/doc/classes/REXML/Entity.html +0 -150
  45. data/doc/classes/REXML.html +0 -112
  46. data/doc/created.rid +0 -1
  47. data/doc/files/CHANGELOG.html +0 -156
  48. data/doc/files/LICENCE.html +0 -109
  49. data/doc/files/README.html +0 -371
  50. data/doc/files/VERSION.html +0 -107
  51. data/doc/files/lib/ews/transaction/fake_response_rb.html +0 -101
  52. data/doc/files/lib/ews/transaction/mapping_rb.html +0 -108
  53. data/doc/files/lib/ews/transaction/request_rb.html +0 -108
  54. data/doc/files/lib/ews/transaction/response_rb.html +0 -101
  55. data/doc/files/lib/ews/transaction/validator_rb.html +0 -101
  56. data/doc/files/lib/ews/transporter_rb.html +0 -108
  57. data/doc/files/lib/exact4r_rb.html +0 -117
  58. data/doc/fr_class_index.html +0 -34
  59. data/doc/fr_file_index.html +0 -37
  60. data/doc/fr_method_index.html +0 -48
  61. data/doc/index.html +0 -24
  62. data/doc/rdoc-style.css +0 -208
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ == v1.0
2
+ Added support for Batch Query and Batch Close transactions.
3
+
1
4
  == v0.9.3
2
5
  Reinstated Tagged Void support.
3
6
 
data/README CHANGED
@@ -184,14 +184,3 @@ The following AVS responses are currently supported:
184
184
 
185
185
  response.cc_verification_str1.should == "N123BROWNSTREET4902101234"
186
186
  response.avs.should == N
187
-
188
- = Rake tasks
189
-
190
- test
191
- Run all tests (default)
192
-
193
- rdoc
194
- Generate rdoc html in doc/
195
-
196
- gem
197
- Build gem
data/Rakefile CHANGED
@@ -3,13 +3,45 @@ require 'rake/testtask'
3
3
  require "rubygems"
4
4
  require "rake/gempackagetask"
5
5
 
6
- task :default => :test
6
+ task :default => :'test:chase'
7
7
 
8
- desc 'Run all the tests'
9
- Rake::TestTask.new(:test) do |t|
10
- t.libs << 'lib'
11
- t.pattern = 'test/**/*_test.rb'
12
- t.verbose = true
8
+ namespace :test do
9
+
10
+ desc 'Run all tests against all processors. Use LOCATION to specify web service URL.'
11
+ task :all do
12
+ %w(chase tsys emergis moneris).each do |processor|
13
+ 3.times { puts }
14
+ puts "#-----------------------"
15
+ puts "# Testing: " + processor
16
+ puts "#-----------------------"
17
+
18
+ ENV['PROCESSOR'] = processor
19
+ begin
20
+ Rake::Task[:'test:processor'].execute
21
+ rescue
22
+ # don't care, just run it again. can examine output later
23
+ end
24
+ end
25
+ end
26
+
27
+ desc 'Run all tests against Chase processor and Production web service. Use LOCATION to specify web service URL.'
28
+ task :chase do
29
+ ENV['PROCESSOR'] = 'chase'
30
+ ENV['LOCATION'] = 'PROD'
31
+ begin
32
+ Rake::Task[:'test:processor'].execute
33
+ rescue
34
+ # don't care, just run it again. can examine output later
35
+ end
36
+ end
37
+
38
+ desc 'Run all the tests against a specific processor. Use LOCATION to specify web service URL.'
39
+ Rake::TestTask.new(:processor) do |t|
40
+ t.libs << 'lib'
41
+ t.pattern = 'test/**/*_test.rb'
42
+ t.verbose = true
43
+ end
44
+
13
45
  end
14
46
 
15
47
  desc "Build the RDoc"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.3
1
+ 1.0
@@ -43,6 +43,8 @@ module EWS # :nodoc:
43
43
  # :idebit_refund
44
44
  # :secure_storage
45
45
  # :secure_storage_eft
46
+ # :batch_query
47
+ # :batch_close
46
48
  # :transaction_details
47
49
  class Request
48
50
  include Validator
@@ -117,6 +119,8 @@ METHOD_EOS
117
119
  :idebit_refund => '54',
118
120
  :secure_storage => '60',
119
121
  :secure_storage_eft => '61',
122
+ :batch_query => '80',
123
+ :batch_close => '81',
120
124
  :transaction_details => 'CR'
121
125
  }.freeze unless defined?(@@transaction_codes)
122
126
 
@@ -40,6 +40,8 @@ module EWS # :nodoc:
40
40
 
41
41
  if self.transaction_type == "CR"
42
42
  append_error(:transaction_tag, "transaction_tag must be supplied") if self.transaction_tag.to_i < 1
43
+ elsif %w(80 81).include?(self.transaction_type)
44
+ # do nothing, no validation required
43
45
  elsif %w(50 54).include?(self.transaction_type)
44
46
  validate_for_pan
45
47
  elsif !self.transaction_tag.blank?
@@ -15,7 +15,7 @@ module EWS # :nodoc:
15
15
  # Once configured to connect to a particular service, it can be used repeatedly
16
16
  # to send as many transactions as required.
17
17
  class Transporter
18
-
18
+
19
19
  # Initialize a Transporter.
20
20
  #
21
21
  # You can specify the URL you would like the Transporter to connect to, although it defaults
@@ -30,6 +30,8 @@ module EWS # :nodoc:
30
30
  def initialize(url = "https://api.e-xact.com", options = {})
31
31
  @url = URI.parse(url.gsub(/\/$/,''))
32
32
  @transport_type = options[:transport_type] || :rest
33
+
34
+ debugger
33
35
 
34
36
  @@issuer_cert ||= File.dirname(__FILE__)+"/../../certs/equifax_ca.cer"
35
37
  @@server_cert ||= File.new(File.dirname(__FILE__)+"/../../certs/exact.cer").read
@@ -52,7 +54,7 @@ module EWS # :nodoc:
52
54
  request = build_http_request(transaction, transport_type, transport_details[:suffix])
53
55
  request.basic_auth(transaction.gateway_id, transaction.password)
54
56
  request.add_field "Accept", transport_details[:content_type]
55
- request.add_field "User-Agent", "exact4r v0.9.1"
57
+ request.add_field "User-Agent", "exact4r v1.0"
56
58
  request.add_field "Content-type", "#{transport_details[:content_type]}; charset=UTF-8"
57
59
 
58
60
  response = get_connection.request(request)
@@ -0,0 +1,62 @@
1
+ module Exact
2
+ class Credentials
3
+
4
+ attr_accessor :config
5
+
6
+ def initialize
7
+ load_configuration(ENV['LOCATION'])
8
+ end
9
+
10
+ # obtain the credentials for the processor specified by
11
+ # ENV['PROCESSOR'], defaulting to 'emergis'
12
+ def current_gateway
13
+ processor = ENV['PROCESSOR'] || 'emergis'
14
+ self.config[processor]
15
+ end
16
+
17
+ def chase
18
+ self.config['chase']
19
+ end
20
+ def chase_batch
21
+ self.config['chase_batch']
22
+ end
23
+ def chase?
24
+ [self.chase[:gateway_id], self.chase_batch[:gateway_id]].include?(current_gateway[:gateway_id])
25
+ end
26
+
27
+ def tsys
28
+ self.config['tsys']
29
+ end
30
+ def tsys?
31
+ current_gateway[:gateway_id] == self.tsys[:gateway_id]
32
+ end
33
+
34
+ def emergis
35
+ self.config['emergis']
36
+ end
37
+ def emergis?
38
+ current_gateway[:gateway_id] == self.emergis[:gateway_id]
39
+ end
40
+
41
+ def moneris
42
+ self.config['moneris']
43
+ end
44
+ def moneris?
45
+ current_gateway[:gateway_id] == self.moneris[:gateway_id]
46
+ end
47
+
48
+ def load_configuration(environment)
49
+ config_file = File.dirname(__FILE__) + '/credentials.yml'
50
+ yaml = YAML::load(IO.read(config_file))
51
+ environment ||= 'DEV'
52
+
53
+ self.config = yaml[environment]
54
+
55
+ if self.config.nil?
56
+ abort "No credentials configured. Please create a properly-formatted credentials.yml file in #{File.dirname(__FILE__)}."
57
+ end
58
+ end
59
+ private :load_configuration
60
+
61
+ end
62
+ end
@@ -0,0 +1,53 @@
1
+ DEV:
2
+ location: http://ws.local/
3
+ tsys:
4
+ :gateway_id: AD0007-01
5
+ :password: 3uLi726f
6
+ emergis:
7
+ :gateway_id: AD0009-01
8
+ :password: 8L588rmd
9
+ moneris:
10
+ :gateway_id: AD0154-01
11
+ :password: 77hgy56y
12
+ chase:
13
+ :gateway_id: AD0008-01
14
+ :password: 7nfcpc7n
15
+ chase_batch:
16
+ :gateway_id: AD0021-02
17
+ :password: 22ra7k69
18
+
19
+ QA:
20
+ location: http://api.qa.e-xact.com/
21
+ tsys:
22
+ :gateway_id: A04766-01
23
+ :password: 4apitest
24
+ emergis:
25
+ :gateway_id: A04763-01
26
+ :password: 4apitest
27
+ moneris:
28
+ :gateway_id: A04760-01
29
+ :password: 4apitest
30
+ chase:
31
+ :gateway_id: A04757-02
32
+ :password: 4apitest
33
+ chase_batch:
34
+ :gateway_id: A04757-01
35
+ :password: 4apitest
36
+
37
+ PROD:
38
+ location: https://api.e-xact.com/
39
+ tsys:
40
+ :gateway_id: A08741-01
41
+ :password: 4apitest
42
+ emergis:
43
+ :gateway_id: A08738-01
44
+ :password: 4apitest
45
+ moneris:
46
+ :gateway_id: A08735-01
47
+ :password: 4apitest
48
+ chase:
49
+ :gateway_id: A08732-02
50
+ :password: 4apitest
51
+ chase_batch:
52
+ :gateway_id: A08732-01
53
+ :password: 4apitest
@@ -0,0 +1,193 @@
1
+ require File.dirname(__FILE__) + "/../test_helper"
2
+
3
+ class BatchQueryCloseTest < Test::Unit::TestCase
4
+
5
+ # NOTE: DO NOT submit an amount with a cents value of LESS THAN 25 to this host as it will
6
+ # reply with a bank_resp_code == 200 + cents
7
+
8
+ def setup
9
+ @transporter = EWS::Transporter.new(@@credentials.config['location'])
10
+ end
11
+
12
+ def test_mandatory
13
+ request = EWS::Transaction::Request.new(:transaction_type => :batch_query)
14
+ assert !request.valid?
15
+ assert_equal "gateway_id must be supplied", request.errors[:gateway_id]
16
+
17
+ request.gateway_id = @@credentials.chase_batch[:gateway_id]
18
+ assert !request.valid?
19
+ assert_equal "password must be supplied", request.errors[:password]
20
+
21
+ request.password = @@credentials.chase_batch[:password]
22
+ assert request.valid?
23
+
24
+ # yep, that's it. only gateway_id and password are required
25
+
26
+ request = EWS::Transaction::Request.new(:transaction_type => :batch_close)
27
+ assert !request.valid?
28
+ assert_equal "gateway_id must be supplied", request.errors[:gateway_id]
29
+
30
+ request.gateway_id = @@credentials.chase_batch[:gateway_id]
31
+ assert !request.valid?
32
+ assert_equal "password must be supplied", request.errors[:password]
33
+
34
+ request.password = @@credentials.chase_batch[:password]
35
+ assert request.valid?
36
+ end
37
+
38
+ def test_query
39
+ return unless @@credentials.chase?
40
+
41
+ # send a transaction to ensure there is a batch in progress
42
+ submit_purchase
43
+
44
+ request = EWS::Transaction::Request.new(@@credentials.chase_batch.merge(:transaction_type => :batch_query))
45
+
46
+ response = @transporter.submit(request, :json)
47
+ assert_response_approved response
48
+ assert_equal "BATINQ", response.authorization_num
49
+
50
+ response = @transporter.submit(request, :rest)
51
+ assert_response_approved response
52
+ assert_equal "BATINQ", response.authorization_num
53
+
54
+ response = @transporter.submit(request, :soap)
55
+ assert_response_approved response
56
+ assert_equal "BATINQ", response.authorization_num
57
+ end
58
+
59
+ def test_close_json
60
+ return unless @@credentials.chase?
61
+
62
+ # send a transaction to ensure there is a batch in progress
63
+ submit_purchase
64
+
65
+ request = EWS::Transaction::Request.new(@@credentials.chase_batch.merge(:transaction_type => :batch_close))
66
+
67
+ response = @transporter.submit(request, :json)
68
+ assert_response_approved response
69
+ assert_equal "BATCLS", response.authorization_num
70
+ end
71
+
72
+ def test_close_rest
73
+ return unless @@credentials.chase?
74
+
75
+ # send a transaction to ensure there is a batch in progress
76
+ submit_purchase
77
+
78
+ request = EWS::Transaction::Request.new(@@credentials.chase_batch.merge(:transaction_type => :batch_close))
79
+
80
+ response = @transporter.submit(request, :rest)
81
+ assert_response_approved response
82
+ assert_equal "BATCLS", response.authorization_num
83
+ end
84
+
85
+ def test_close_soap
86
+ return unless @@credentials.chase?
87
+
88
+ # send a transaction to ensure there is a batch in progress
89
+ submit_purchase
90
+
91
+ request = EWS::Transaction::Request.new(@@credentials.chase_batch.merge(:transaction_type => :batch_close))
92
+
93
+ response = @transporter.submit(request, :soap)
94
+ assert_response_approved response
95
+ assert_equal "BATCLS", response.authorization_num
96
+ end
97
+
98
+ def test_cant_close_already_closed_batch
99
+ return unless @@credentials.chase?
100
+
101
+ # ensure any existing batch is closed
102
+ submit_batch_close
103
+
104
+ response = submit_batch_close
105
+ assert !response.approved?
106
+ assert_nil response.bank_resp_code
107
+ assert_equal "BAT ALREADY RELS", response.bank_message
108
+ end
109
+
110
+ # test cards
111
+ # Visa: 4111111111111111
112
+ # MasterCard: 5500000000000004
113
+ # American Express: 340000000000009
114
+ def test_summation
115
+ return unless @@credentials.chase?
116
+
117
+ submit_batch_close # ensure we're starting a new batch
118
+
119
+ submit_purchase(:amount => 10.00)
120
+ submit_purchase(:amount => 15.29)
121
+ submit_purchase(:amount => 122.75)
122
+ # 3 transactions, total of 148.04 on VISA
123
+
124
+ submit_purchase({:cc_number => "5500000000000004", :amount => 1754.60})
125
+ submit_purchase({:cc_number => "5500000000000004", :amount => 1544.87})
126
+ # 2 transactions, total of 3299.47 on Mastercard
127
+
128
+ submit_purchase({:cc_number => "340000000000009", :amount => 43.26})
129
+ submit_purchase({:cc_number => "340000000000009", :amount => 185.75})
130
+ submit_purchase({:cc_number => "340000000000009", :amount => 877.53})
131
+ submit_purchase({:cc_number => "340000000000009", :amount => 7.45})
132
+ # 4 transactions, total of 1113.99 on Amex
133
+
134
+ response = submit_batch_query
135
+ assert_response_approved response
136
+ assert_equal "BATINQ", response.authorization_num
137
+ assert_equal "<CR|5|344751><AE|4|111399>", response.bank_message
138
+
139
+ # now close the batch
140
+ response = submit_batch_close
141
+ assert_response_approved response
142
+ assert_equal "BATCLS", response.authorization_num
143
+ assert_equal "<CR|5|344751><AE|4|111399>", response.bank_message
144
+ end
145
+
146
+ def test_large_summation
147
+ return unless @@credentials.chase?
148
+
149
+ submit_batch_close # ensure we're starting a new batch
150
+
151
+ 10.times { submit_purchase(:amount => 99999.0) }
152
+
153
+ response = submit_batch_query
154
+ assert_response_approved response
155
+ assert_equal "BATINQ", response.authorization_num
156
+ assert_equal "<CR|10|99999000>", response.bank_message
157
+
158
+ # now close the batch
159
+ response = submit_batch_close
160
+ assert_response_approved response
161
+ assert_equal "BATCLS", response.authorization_num
162
+ assert_equal "<CR|10|99999000>", response.bank_message
163
+ end
164
+
165
+ private
166
+ def submit_batch_query
167
+ request = EWS::Transaction::Request.new(@@credentials.chase_batch.merge(:transaction_type => :batch_query))
168
+ @transporter.submit(request, :rest)
169
+ end
170
+
171
+ def submit_batch_close
172
+ request = EWS::Transaction::Request.new(@@credentials.chase_batch.merge(:transaction_type => :batch_close))
173
+ @transporter.submit(request, :json)
174
+ end
175
+
176
+ def submit_purchase(options = {:amount => 10.0})
177
+ params = cc_number_params.
178
+ merge(@@credentials.chase_batch).
179
+ merge(:transaction_type => :purchase).
180
+ merge(options)
181
+ request = EWS::Transaction::Request.new(params)
182
+ assert request.valid?, request.errors.inspect
183
+
184
+ # if this is failing, see note at top of page first!
185
+ assert @transporter.submit(request, :json).approved?
186
+ end
187
+
188
+ def assert_response_approved(response)
189
+ assert_not_nil response, "response should not be nil"
190
+ assert response.approved?, "#{response.error_number} / #{response.error_description} / #{response.exact_message} / #{response.bank_message}"
191
+ assert_equal "000", response.bank_resp_code
192
+ end
193
+ end
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + "/../test_helper"
3
3
  class ForcedPostTest < Test::Unit::TestCase
4
4
 
5
5
  def setup
6
- @transporter = EWS::Transporter.new(LOCATION)
6
+ @transporter = EWS::Transporter.new(@@credentials.config['location'])
7
7
  end
8
8
 
9
9
  def test_mandatory
@@ -11,11 +11,11 @@ class ForcedPostTest < Test::Unit::TestCase
11
11
  assert !request.valid?
12
12
  assert_equal "gateway_id must be supplied", request.errors[:gateway_id]
13
13
 
14
- request.gateway_id = EMERGIS_BASIC_AUTH[:gateway_id]
14
+ request.gateway_id = @@credentials.current_gateway[:gateway_id]
15
15
  assert !request.valid?
16
16
  assert_equal "password must be supplied", request.errors[:password]
17
17
 
18
- request.password = EMERGIS_BASIC_AUTH[:password]
18
+ request.password = @@credentials.current_gateway[:password]
19
19
  assert !request.valid?
20
20
  assert_equal "One of the following must be supplied: cc_number, track1, track2 or transaction_tag.", request.errors[:base]
21
21
 
@@ -5,7 +5,7 @@ class OnlineDebitPurchaseTest < Test::Unit::TestCase
5
5
  # NOTE: INTERAC Online Debit transactions are ONLY supported by Chase merchants
6
6
 
7
7
  def setup
8
- @transporter = EWS::Transporter.new(LOCATION)
8
+ @transporter = EWS::Transporter.new(@@credentials.config['location'])
9
9
  end
10
10
 
11
11
  def test_mandatory
@@ -13,11 +13,11 @@ class OnlineDebitPurchaseTest < Test::Unit::TestCase
13
13
  assert !request.valid?
14
14
  assert_equal "gateway_id must be supplied", request.errors[:gateway_id]
15
15
 
16
- request.gateway_id = CHASE_BASIC_AUTH[:gateway_id]
16
+ request.gateway_id = @@credentials.current_gateway[:gateway_id]
17
17
  assert !request.valid?
18
18
  assert_equal "password must be supplied", request.errors[:password]
19
19
 
20
- request.password = CHASE_BASIC_AUTH[:password]
20
+ request.password = @@credentials.current_gateway[:password]
21
21
  assert !request.valid?
22
22
  assert_equal "pan must be supplied", request.errors[:pan]
23
23
 
@@ -35,12 +35,14 @@ class OnlineDebitPurchaseTest < Test::Unit::TestCase
35
35
 
36
36
  # PAN may be specificed as a simple account number...
37
37
  def test_by_pan_as_cc_number
38
+ return unless @@credentials.chase?
39
+
38
40
  request = EWS::Transaction::Request.new({
39
41
  :transaction_type => :idebit_purchase,
40
42
  :amount => 11.25,
41
43
  :pan => TEST_CARD_NUMBER,
42
44
  :cardholder_name => TEST_CARD_HOLDER
43
- }.merge(CHASE_BASIC_AUTH))
45
+ }.merge(@@credentials.current_gateway))
44
46
  assert request.valid?, request.errors.inspect
45
47
 
46
48
  assert_details_correct request, @transporter.submit(request, :json)
@@ -50,12 +52,14 @@ class OnlineDebitPurchaseTest < Test::Unit::TestCase
50
52
 
51
53
  # ...or in track2 format
52
54
  def test_by_pan_as_cc_number
55
+ return unless @@credentials.chase?
56
+
53
57
  request = EWS::Transaction::Request.new({
54
58
  :transaction_type => :idebit_purchase,
55
59
  :amount => 11.25,
56
60
  :pan => TEST_TRACK2,
57
61
  :cardholder_name => TEST_CARD_HOLDER
58
- }.merge(CHASE_BASIC_AUTH))
62
+ }.merge(@@credentials.current_gateway))
59
63
  assert request.valid?, request.errors.inspect
60
64
 
61
65
  assert_details_correct request, @transporter.submit(request, :json)
@@ -5,7 +5,7 @@ class OnlineDebitRefundTest < Test::Unit::TestCase
5
5
  # NOTE: INTERAC Online Debit transactions are ONLY supported by Chase merchants
6
6
 
7
7
  def setup
8
- @transporter = EWS::Transporter.new(LOCATION)
8
+ @transporter = EWS::Transporter.new(@@credentials.config['location'])
9
9
  end
10
10
 
11
11
  def test_mandatory
@@ -13,11 +13,11 @@ class OnlineDebitRefundTest < Test::Unit::TestCase
13
13
  assert !request.valid?
14
14
  assert_equal "gateway_id must be supplied", request.errors[:gateway_id]
15
15
 
16
- request.gateway_id = CHASE_BASIC_AUTH[:gateway_id]
16
+ request.gateway_id = @@credentials.current_gateway[:gateway_id]
17
17
  assert !request.valid?
18
18
  assert_equal "password must be supplied", request.errors[:password]
19
19
 
20
- request.password = CHASE_BASIC_AUTH[:password]
20
+ request.password = @@credentials.current_gateway[:password]
21
21
  assert !request.valid?
22
22
  assert_equal "pan must be supplied", request.errors[:pan]
23
23
 
@@ -35,12 +35,14 @@ class OnlineDebitRefundTest < Test::Unit::TestCase
35
35
 
36
36
  # PAN may be specificed as a simple account number...
37
37
  def test_by_pan_as_cc_number
38
+ return unless @@credentials.chase?
39
+
38
40
  request = EWS::Transaction::Request.new({
39
41
  :transaction_type => :idebit_refund,
40
42
  :amount => 11.25,
41
43
  :pan => TEST_CARD_NUMBER,
42
44
  :cardholder_name => TEST_CARD_HOLDER
43
- }.merge(CHASE_BASIC_AUTH))
45
+ }.merge(@@credentials.current_gateway))
44
46
  assert request.valid?, request.errors.inspect
45
47
 
46
48
  assert_details_correct request, @transporter.submit(request, :json)
@@ -50,12 +52,14 @@ class OnlineDebitRefundTest < Test::Unit::TestCase
50
52
 
51
53
  # ...or in track2 format
52
54
  def test_by_pan_as_cc_number
55
+ return unless @@credentials.chase?
56
+
53
57
  request = EWS::Transaction::Request.new({
54
58
  :transaction_type => :idebit_refund,
55
59
  :amount => 11.25,
56
60
  :pan => TEST_TRACK2,
57
61
  :cardholder_name => TEST_CARD_HOLDER
58
- }.merge(CHASE_BASIC_AUTH))
62
+ }.merge(@@credentials.current_gateway))
59
63
  assert request.valid?, request.errors.inspect
60
64
 
61
65
  assert_details_correct request, @transporter.submit(request, :json)
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + "/../test_helper"
3
3
  class PreAuthCompletionTest < Test::Unit::TestCase
4
4
 
5
5
  def setup
6
- @transporter = EWS::Transporter.new(LOCATION)
6
+ @transporter = EWS::Transporter.new(@@credentials.config['location'])
7
7
  end
8
8
 
9
9
  def test_mandatory
@@ -11,11 +11,11 @@ class PreAuthCompletionTest < Test::Unit::TestCase
11
11
  assert !request.valid?
12
12
  assert_equal "gateway_id must be supplied", request.errors[:gateway_id]
13
13
 
14
- request.gateway_id = EMERGIS_BASIC_AUTH[:gateway_id]
14
+ request.gateway_id = @@credentials.current_gateway[:gateway_id]
15
15
  assert !request.valid?
16
16
  assert_equal "password must be supplied", request.errors[:password]
17
17
 
18
- request.password = EMERGIS_BASIC_AUTH[:password]
18
+ request.password = @@credentials.current_gateway[:password]
19
19
  assert !request.valid?
20
20
  assert_equal "One of the following must be supplied: cc_number, track1, track2 or transaction_tag.", request.errors[:base]
21
21
 
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + "/../test_helper"
3
3
  class PreAuthOnlyTest < Test::Unit::TestCase
4
4
 
5
5
  def setup
6
- @transporter = EWS::Transporter.new(LOCATION)
6
+ @transporter = EWS::Transporter.new(@@credentials.config['location'])
7
7
  end
8
8
 
9
9
  def test_mandatory
@@ -11,11 +11,11 @@ class PreAuthOnlyTest < Test::Unit::TestCase
11
11
  assert !request.valid?
12
12
  assert_equal "gateway_id must be supplied", request.errors[:gateway_id]
13
13
 
14
- request.gateway_id = EMERGIS_BASIC_AUTH[:gateway_id]
14
+ request.gateway_id = @@credentials.current_gateway[:gateway_id]
15
15
  assert !request.valid?
16
16
  assert_equal "password must be supplied", request.errors[:password]
17
17
 
18
- request.password = EMERGIS_BASIC_AUTH[:password]
18
+ request.password = @@credentials.current_gateway[:password]
19
19
  assert !request.valid?
20
20
  assert_equal "One of the following must be supplied: cc_number, track1, track2 or transaction_tag.", request.errors[:base]
21
21
 
@@ -36,6 +36,8 @@ class PreAuthOnlyTest < Test::Unit::TestCase
36
36
  end
37
37
 
38
38
  def test_by_credit_card
39
+ return unless @@credentials.chase? || @@credentials.emergis?
40
+
39
41
  request = EWS::Transaction::Request.new(cc_number_params.merge(:transaction_type => :pre_auth_only))
40
42
  request.amount = 11.25
41
43
  assert request.valid?, request.errors.inspect
@@ -46,6 +48,8 @@ class PreAuthOnlyTest < Test::Unit::TestCase
46
48
  end
47
49
 
48
50
  def test_by_track1
51
+ return unless @@credentials.chase? || @@credentials.emergis?
52
+
49
53
  request = EWS::Transaction::Request.new(track1_params.merge(:transaction_type => :pre_auth_only))
50
54
  request.amount = 11.25
51
55
  assert request.valid?, request.errors.inspect
@@ -56,6 +60,8 @@ class PreAuthOnlyTest < Test::Unit::TestCase
56
60
  end
57
61
 
58
62
  def test_by_track2
63
+ return unless @@credentials.chase? || @@credentials.emergis?
64
+
59
65
  request = EWS::Transaction::Request.new(track2_params.merge(:transaction_type => :pre_auth_only))
60
66
  request.amount = 11.25
61
67
  assert request.valid?, request.errors.inspect
@@ -3,7 +3,7 @@ require File.dirname(__FILE__) + "/../test_helper"
3
3
  class PreAuthTest < Test::Unit::TestCase
4
4
 
5
5
  def setup
6
- @transporter = EWS::Transporter.new(LOCATION)
6
+ @transporter = EWS::Transporter.new(@@credentials.config['location'])
7
7
  end
8
8
 
9
9
  def test_mandatory
@@ -11,11 +11,11 @@ class PreAuthTest < Test::Unit::TestCase
11
11
  assert !request.valid?
12
12
  assert_equal "gateway_id must be supplied", request.errors[:gateway_id]
13
13
 
14
- request.gateway_id = EMERGIS_BASIC_AUTH[:gateway_id]
14
+ request.gateway_id = @@credentials.current_gateway[:gateway_id]
15
15
  assert !request.valid?
16
16
  assert_equal "password must be supplied", request.errors[:password]
17
17
 
18
- request.password = EMERGIS_BASIC_AUTH[:password]
18
+ request.password = @@credentials.current_gateway[:password]
19
19
  assert !request.valid?
20
20
  assert_equal "One of the following must be supplied: cc_number, track1, track2 or transaction_tag.", request.errors[:base]
21
21