cardconnect 2.2.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ruby.yml +35 -0
  3. data/CHANGELOG.md +13 -0
  4. data/README.md +29 -5
  5. data/cardconnect.gemspec +1 -4
  6. data/lib/cardconnect/connection.rb +3 -3
  7. data/lib/cardconnect/services/authorization/authorization_response.rb +2 -6
  8. data/lib/cardconnect/services/bin/bin.rb +15 -0
  9. data/lib/cardconnect/services/bin/bin_request.rb +43 -0
  10. data/lib/cardconnect/services/bin/bin_response.rb +36 -0
  11. data/lib/cardconnect/services/capture/capture_request.rb +1 -5
  12. data/lib/cardconnect/services/capture/capture_response.rb +9 -11
  13. data/lib/cardconnect/services/inquire/inquire_response.rb +13 -14
  14. data/lib/cardconnect/services/profile/profile.rb +1 -1
  15. data/lib/cardconnect/services/profile/profile_delete_response.rb +1 -5
  16. data/lib/cardconnect/services/profile/profile_get_response.rb +6 -8
  17. data/lib/cardconnect/services/profile/profile_put_response.rb +1 -5
  18. data/lib/cardconnect/services/refund/refund_response.rb +1 -5
  19. data/lib/cardconnect/services/settlement_status/settlement_status_response.rb +1 -5
  20. data/lib/cardconnect/services/void/void_response.rb +1 -5
  21. data/lib/cardconnect/utils.rb +3 -6
  22. data/lib/cardconnect/version.rb +1 -1
  23. data/lib/cardconnect.rb +5 -1
  24. data/test/api_request_stubs.rb +7 -0
  25. data/test/api_response_stubs.rb +40 -6
  26. data/test/cardconnect/configuration_test.rb +5 -5
  27. data/test/cardconnect/connection_test.rb +6 -6
  28. data/test/cardconnect/services/authorization/authorization_request_test.rb +35 -35
  29. data/test/cardconnect/services/authorization/authorization_response_test.rb +19 -19
  30. data/test/cardconnect/services/authorization/authorization_test.rb +11 -11
  31. data/test/cardconnect/services/bin/bin_request_test.rb +45 -0
  32. data/test/cardconnect/services/bin/bin_response_test.rb +67 -0
  33. data/test/cardconnect/services/bin/bin_test.rb +56 -0
  34. data/test/cardconnect/services/capture/capture_request_test.rb +11 -11
  35. data/test/cardconnect/services/capture/capture_response_test.rb +6 -6
  36. data/test/cardconnect/services/capture/capture_test.rb +9 -9
  37. data/test/cardconnect/services/inquire/inquire_request_test.rb +6 -6
  38. data/test/cardconnect/services/inquire/inquire_response_test.rb +35 -11
  39. data/test/cardconnect/services/inquire/inquire_test.rb +9 -9
  40. data/test/cardconnect/services/profile/profile_delete_request_test.rb +7 -7
  41. data/test/cardconnect/services/profile/profile_delete_response_test.rb +11 -11
  42. data/test/cardconnect/services/profile/profile_get_request_test.rb +7 -7
  43. data/test/cardconnect/services/profile/profile_get_response_test.rb +34 -26
  44. data/test/cardconnect/services/profile/profile_put_request_test.rb +23 -23
  45. data/test/cardconnect/services/profile/profile_put_response_test.rb +28 -28
  46. data/test/cardconnect/services/profile/profile_test.rb +27 -27
  47. data/test/cardconnect/services/refund/refund_request_test.rb +7 -7
  48. data/test/cardconnect/services/refund/refund_response_test.rb +13 -13
  49. data/test/cardconnect/services/refund/refund_test.rb +9 -9
  50. data/test/cardconnect/services/settlement_status/settlement_status_request_test.rb +12 -12
  51. data/test/cardconnect/services/settlement_status/settlement_status_response_test.rb +8 -8
  52. data/test/cardconnect/services/settlement_status/settlement_status_test.rb +9 -9
  53. data/test/cardconnect/services/void/void_request_test.rb +7 -7
  54. data/test/cardconnect/services/void/void_response_test.rb +14 -14
  55. data/test/cardconnect/services/void/void_test.rb +9 -9
  56. data/test/cardconnect_test.rb +2 -2
  57. data/test/test_helper.rb +3 -1
  58. metadata +18 -38
  59. data/.travis.yml +0 -9
@@ -11,25 +11,25 @@ describe CardConnect::Connection do
11
11
 
12
12
  describe '#connection' do
13
13
  it 'must have user agent in the headers' do
14
- @connection.headers['User-Agent'].must_equal "CardConnectRubyGem/#{CardConnect::VERSION}"
14
+ _(@connection.headers['User-Agent']).must_equal "CardConnectRubyGem/#{CardConnect::VERSION}"
15
15
  end
16
16
 
17
17
  it 'must have a URL that matches the configured endpoint' do
18
- @connection.url_prefix.host.must_equal URI.parse(CardConnect.configuration.endpoint).host
19
- @connection.url_prefix.scheme.must_equal 'https'
18
+ _(@connection.url_prefix.host).must_equal URI.parse(CardConnect.configuration.endpoint).host
19
+ _(@connection.url_prefix.scheme).must_equal 'https'
20
20
  end
21
21
 
22
22
  describe 'Faraday handlers' do
23
23
  it 'must have a handler for basic authentication first' do
24
- @connection.builder.handlers.first.must_be :===, Faraday::Request::BasicAuthentication
24
+ _(@connection.builder.handlers.first).must_be :===, Faraday::Request::Authorization
25
25
  end
26
26
 
27
27
  it 'must have a handler for encoding the request as json second' do
28
- @connection.builder.handlers[1].must_be :===, FaradayMiddleware::EncodeJson
28
+ _(@connection.builder.handlers[1]).must_be :===, Faraday::Request::Json
29
29
  end
30
30
 
31
31
  it 'must have a handler for parsing the json response third' do
32
- @connection.builder.handlers[2].must_be :===, FaradayMiddleware::ParseJson
32
+ _(@connection.builder.handlers[2]).must_be :===, Faraday::Response::Json
33
33
  end
34
34
 
35
35
  it 'has ssl verification on by default' do
@@ -11,133 +11,133 @@ describe CardConnect::Service::AuthorizationRequest do
11
11
 
12
12
  describe 'FIELDS' do
13
13
  it 'should have merchant id' do
14
- @request.merchid.must_equal '000000927996'
14
+ _(@request.merchid).must_equal '000000927996'
15
15
  end
16
16
 
17
17
  it 'should have account' do
18
- @request.account.must_equal '4111111111111111'
18
+ _(@request.account).must_equal '4111111111111111'
19
19
  end
20
20
 
21
21
  it 'should have expiry' do
22
- @request.expiry.must_equal '1212'
22
+ _(@request.expiry).must_equal '1212'
23
23
  end
24
24
 
25
25
  it 'should have amount' do
26
- @request.amount.must_equal '0'
26
+ _(@request.amount).must_equal '0'
27
27
  end
28
28
 
29
29
  it 'should have currency' do
30
- @request.currency.must_equal 'USD'
30
+ _(@request.currency).must_equal 'USD'
31
31
  end
32
32
 
33
33
  it 'should have account type' do
34
- @request.accttype.must_equal 'VISA'
34
+ _(@request.accttype).must_equal 'VISA'
35
35
  end
36
36
 
37
37
  it 'should have name' do
38
- @request.name.must_equal 'TOM JONES'
38
+ _(@request.name).must_equal 'TOM JONES'
39
39
  end
40
40
 
41
41
  it 'should have address' do
42
- @request.address.must_equal '123 MAIN STREET'
42
+ _(@request.address).must_equal '123 MAIN STREET'
43
43
  end
44
44
 
45
45
  it 'should have city' do
46
- @request.city.must_equal 'anytown'
46
+ _(@request.city).must_equal 'anytown'
47
47
  end
48
48
 
49
49
  it 'should have country' do
50
- @request.country.must_equal 'US'
50
+ _(@request.country).must_equal 'US'
51
51
  end
52
52
 
53
53
  it 'should have phone' do
54
- @request.phone.must_equal '3334445555'
54
+ _(@request.phone).must_equal '3334445555'
55
55
  end
56
56
 
57
57
  it 'should have postal' do
58
- @request.postal.must_equal '55555'
58
+ _(@request.postal).must_equal '55555'
59
59
  end
60
60
 
61
61
  it 'should have email' do
62
- @request.email.must_equal 'tom@jones.com'
62
+ _(@request.email).must_equal 'tom@jones.com'
63
63
  end
64
64
 
65
65
  it 'should have ecomind' do
66
- @request.ecomind.must_equal 'E'
66
+ _(@request.ecomind).must_equal 'E'
67
67
  end
68
68
 
69
69
  it 'should have cvv2' do
70
- @request.cvv2.must_equal '123'
70
+ _(@request.cvv2).must_equal '123'
71
71
  end
72
72
 
73
73
  it 'should have order id' do
74
- @request.orderid.must_equal 'AB-11-9876'
74
+ _(@request.orderid).must_equal 'AB-11-9876'
75
75
  end
76
76
 
77
77
  it 'should have track' do
78
- @request.track.must_equal 'Y'
78
+ _(@request.track).must_equal 'Y'
79
79
  end
80
80
 
81
81
  it 'should have bankaba' do
82
- @request.bankaba.must_equal '1010101'
82
+ _(@request.bankaba).must_equal '1010101'
83
83
  end
84
84
 
85
85
  it 'should have tokenize' do
86
- @request.tokenize.must_equal 'Y'
86
+ _(@request.tokenize).must_equal 'Y'
87
87
  end
88
88
 
89
89
  it 'should have termid' do
90
- @request.termid.must_equal '12345'
90
+ _(@request.termid).must_equal '12345'
91
91
  end
92
92
 
93
93
  it 'should have capture' do
94
- @request.capture.must_equal 'Y'
94
+ _(@request.capture).must_equal 'Y'
95
95
  end
96
96
 
97
97
  it 'should have ssnl4 field' do
98
- @request.ssnl4.must_equal '1234'
98
+ _(@request.ssnl4).must_equal '1234'
99
99
  end
100
100
 
101
101
  it 'should have license field' do
102
- @request.license.must_equal 'CO:1231231234'
102
+ _(@request.license).must_equal 'CO:1231231234'
103
103
  end
104
104
 
105
105
  it 'should have profile field' do
106
- @request.profile.must_equal 'Y'
106
+ _(@request.profile).must_equal 'Y'
107
107
  end
108
108
 
109
109
  it 'should have ponumber field' do
110
- @request.ponumber.must_equal '1234'
110
+ _(@request.ponumber).must_equal '1234'
111
111
  end
112
112
 
113
113
  it 'should have authcode field' do
114
- @request.authcode.must_equal '123456'
114
+ _(@request.authcode).must_equal '123456'
115
115
  end
116
116
 
117
117
  it 'should have invoiceid field' do
118
- @request.invoiceid.must_equal '000000000001'
118
+ _(@request.invoiceid).must_equal '000000000001'
119
119
  end
120
120
 
121
121
  it 'should have taxamnt field' do
122
- @request.taxamnt.must_equal '0'
122
+ _(@request.taxamnt).must_equal '0'
123
123
  end
124
124
 
125
125
  describe 'userfields' do
126
126
  it 'should be an array of name-value pairs' do
127
- @request.userfields.must_be_kind_of Array
128
- @request.userfields.first.must_be_kind_of Hash
129
- @request.userfields.first['name0'].must_equal 'value0'
127
+ _(@request.userfields).must_be_kind_of Array
128
+ _(@request.userfields.first).must_be_kind_of Hash
129
+ _(@request.userfields.first['name0']).must_equal 'value0'
130
130
  end
131
131
  end
132
132
  end
133
133
 
134
134
  describe '#valid?' do
135
135
  it 'should not be valid if no attributes are passed in' do
136
- CardConnect::Service::AuthorizationRequest.new.valid?.must_equal false
136
+ _(CardConnect::Service::AuthorizationRequest.new.valid?).must_equal false
137
137
  end
138
138
 
139
139
  it 'should be valid if valid attributes are passed in' do
140
- CardConnect::Service::AuthorizationRequest.new(valid_auth_request).valid?.must_equal true
140
+ _(CardConnect::Service::AuthorizationRequest.new(valid_auth_request).valid?).must_equal true
141
141
  end
142
142
  end
143
143
 
@@ -145,14 +145,14 @@ describe CardConnect::Service::AuthorizationRequest do
145
145
  CardConnect::Service::AuthorizationRequest::REQUIRED_FIELDS.each do |field|
146
146
  field_name = field.to_s.capitalize
147
147
  it "should have an error message if #{field_name} is missing" do
148
- CardConnect::Service::AuthorizationRequest.new.errors.must_include "#{field_name} is missing"
148
+ _(CardConnect::Service::AuthorizationRequest.new.errors).must_include "#{field_name} is missing"
149
149
  end
150
150
  end
151
151
  end
152
152
 
153
153
  describe '#payload' do
154
154
  it 'should generate hash with all the right values' do
155
- @request.payload.must_equal symbolize_keys(valid_auth_request)
155
+ _(@request.payload).must_equal symbolize_keys(valid_auth_request)
156
156
  end
157
157
  end
158
158
  end
@@ -11,89 +11,89 @@ describe CardConnect::Service::AuthorizationResponse do
11
11
 
12
12
  describe 'FIELDS' do
13
13
  it 'should have the merchant id' do
14
- @response.merchid.must_equal '020594000000'
14
+ _(@response.merchid).must_equal '020594000000'
15
15
  end
16
16
 
17
17
  it 'should have the status' do
18
- @response.respstat.must_equal 'A'
18
+ _(@response.respstat).must_equal 'A'
19
19
  end
20
20
 
21
21
  it 'should have the Retrieval Reference Number' do
22
- @response.retref.must_equal '343005123105'
22
+ _(@response.retref).must_equal '343005123105'
23
23
  end
24
24
 
25
25
  it 'should have the Account Number' do
26
- @response.account.must_equal '41XXXXXXXXXX1111'
26
+ _(@response.account).must_equal '41XXXXXXXXXX1111'
27
27
  end
28
28
 
29
29
  it 'should have the Token' do
30
- @response.token.must_equal '9419786452781111'
30
+ _(@response.token).must_equal '9419786452781111'
31
31
  end
32
32
 
33
33
  it 'should have the Amount' do
34
- @response.amount.must_equal '111'
34
+ _(@response.amount).must_equal '111'
35
35
  end
36
36
 
37
37
  it 'should have the Response Code' do
38
- @response.respcode.must_equal '00'
38
+ _(@response.respcode).must_equal '00'
39
39
  end
40
40
 
41
41
  it 'should have the Response text' do
42
- @response.resptext.must_equal 'Approved'
42
+ _(@response.resptext).must_equal 'Approved'
43
43
  end
44
44
 
45
45
  it 'should have the Response Processor' do
46
- @response.respproc.must_equal 'FNOR'
46
+ _(@response.respproc).must_equal 'FNOR'
47
47
  end
48
48
 
49
49
  it 'should have the AVS response code' do
50
- @response.avsresp.must_equal '9'
50
+ _(@response.avsresp).must_equal '9'
51
51
  end
52
52
 
53
53
  it 'should have the CVV response code' do
54
- @response.cvvresp.must_equal 'M'
54
+ _(@response.cvvresp).must_equal 'M'
55
55
  end
56
56
 
57
57
  it 'should have the Authorization code' do
58
- @response.authcode.must_equal '046221'
58
+ _(@response.authcode).must_equal '046221'
59
59
  end
60
60
 
61
61
  it 'should have the Commercial Card Flag' do
62
- @response.commcard.must_equal 'N'
62
+ _(@response.commcard).must_equal 'N'
63
63
  end
64
64
 
65
65
  it 'should have the profile id' do
66
- @response.profileid.must_equal '12345678'
66
+ _(@response.profileid).must_equal '12345678'
67
67
  end
68
68
  end
69
69
 
70
70
  describe '#success?' do
71
71
  it 'should be true when there are no errors' do
72
- @response.success?.must_equal true
72
+ _(@response.success?).must_equal true
73
73
  end
74
74
 
75
75
  it 'should be false when there are errors' do
76
76
  auth_response = valid_auth_response.merge!('respstat' => 'B', 'resptext' => 'this is an error')
77
77
  response = CardConnect::Service::AuthorizationResponse.new(auth_response)
78
- response.success?.must_equal false
78
+ _(response.success?).must_equal false
79
79
  end
80
80
  end
81
81
 
82
82
  describe '#errors' do
83
83
  it 'should be empty when there are no errors' do
84
- @response.errors.must_be_empty
84
+ _(@response.errors).must_be_empty
85
85
  end
86
86
 
87
87
  it 'should be an array of error messages when there are errors' do
88
88
  auth_response = valid_auth_response.merge!('respstat' => 'B', 'resptext' => 'this is an error')
89
89
  response = CardConnect::Service::AuthorizationResponse.new(auth_response)
90
- response.errors.must_equal ['this is an error']
90
+ _(response.errors).must_equal ['this is an error']
91
91
  end
92
92
  end
93
93
 
94
94
  describe '#body' do
95
95
  it 'should generate hash with all the right values' do
96
- @response.body.must_equal symbolize_keys(valid_auth_response)
96
+ _(@response.body).must_equal symbolize_keys(valid_auth_response)
97
97
  end
98
98
  end
99
99
  end
@@ -13,7 +13,7 @@ describe CardConnect::Service::Authorization do
13
13
  end
14
14
 
15
15
  it 'must have the right path' do
16
- @service.path.must_equal '/cardconnect/rest/auth'
16
+ _(@service.path).must_equal '/cardconnect/rest/auth'
17
17
  end
18
18
 
19
19
  describe '#build_request' do
@@ -27,30 +27,30 @@ describe CardConnect::Service::Authorization do
27
27
 
28
28
  it 'uses the default merchant id if it is not passed in' do
29
29
  @service.build_request(@valid_params.reject! { |k, _| k == 'merchid' })
30
- @service.request.merchid.must_equal 'merchant123'
30
+ _(@service.request.merchid).must_equal 'merchant123'
31
31
  end
32
32
 
33
33
  it 'creates an Authorization request object with the right params' do
34
34
  @service.build_request(@valid_params)
35
- @service.request.must_be_kind_of CardConnect::Service::AuthorizationRequest
36
- @service.request.merchid.must_equal '000000927996'
37
- @service.request.account.must_equal '4111111111111111'
38
- @service.request.expiry.must_equal '1212'
39
- @service.request.amount.must_equal '0'
40
- @service.request.currency.must_equal 'USD'
35
+ _(@service.request).must_be_kind_of CardConnect::Service::AuthorizationRequest
36
+ _(@service.request.merchid).must_equal '000000927996'
37
+ _(@service.request.account).must_equal '4111111111111111'
38
+ _(@service.request.expiry).must_equal '1212'
39
+ _(@service.request.amount).must_equal '0'
40
+ _(@service.request.currency).must_equal 'USD'
41
41
  end
42
42
  end
43
43
 
44
44
  describe '#submit' do
45
45
  it 'raises an error when there is no request' do
46
- @service.request.nil?.must_equal true
47
- proc { @service.submit }.must_raise CardConnect::Error
46
+ _(@service.request.nil?).must_equal true
47
+ _(-> { @service.submit }).must_raise CardConnect::Error
48
48
  end
49
49
 
50
50
  it 'creates a response when a valid request is processed' do
51
51
  @service.build_request(valid_auth_request)
52
52
  @service.submit
53
- @service.response.must_be_kind_of CardConnect::Service::AuthorizationResponse
53
+ _(@service.response).must_be_kind_of CardConnect::Service::AuthorizationResponse
54
54
  end
55
55
  end
56
56
  end
@@ -0,0 +1,45 @@
1
+ require 'test_helper'
2
+
3
+ describe CardConnect::Service::BinRequest do
4
+ before do
5
+ @request = CardConnect::Service::BinRequest.new(valid_bin_request)
6
+ end
7
+
8
+ after do
9
+ @request = nil
10
+ end
11
+
12
+ describe 'FIELDS' do
13
+ it 'should have merchant id' do
14
+ _(@request.merchid).must_equal '000000927996'
15
+ end
16
+
17
+ it 'should have token' do
18
+ _(@request.token).must_equal '9477709629051443'
19
+ end
20
+ end
21
+
22
+ describe '#valid?' do
23
+ it 'should not be valid if no attributes are passed in' do
24
+ _(CardConnect::Service::BinRequest.new.valid?).must_equal false
25
+ end
26
+
27
+ it 'should be valid if valid attributes are passed in' do
28
+ _(CardConnect::Service::BinRequest.new(valid_bin_request).valid?).must_equal true
29
+ end
30
+ end
31
+
32
+ describe '#errors' do
33
+ CardConnect::Service::BinRequest::REQUIRED_FIELDS.each do |field|
34
+ it "should have an error message if #{field} is missing" do
35
+ _(CardConnect::Service::BinRequest.new.errors).must_include "#{field.to_s.capitalize} is missing"
36
+ end
37
+ end
38
+ end
39
+
40
+ describe '#payload' do
41
+ it 'should generate the correct path params' do
42
+ _(@request.payload).must_equal '/000000927996/9477709629051443'
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,67 @@
1
+ require 'test_helper'
2
+
3
+ describe CardConnect::Service::BinResponse do
4
+ before do
5
+ @response = CardConnect::Service::BinResponse.new(valid_bin_response)
6
+ end
7
+
8
+ after do
9
+ @response = nil
10
+ end
11
+
12
+ describe 'FIELDS' do
13
+ it 'should have country' do
14
+ _(@response.country).must_equal 'USA'
15
+ end
16
+
17
+ it 'should have product' do
18
+ _(@response.product).must_equal 'V'
19
+ end
20
+
21
+ it 'should have cardusestring' do
22
+ _(@response.cardusestring).must_equal 'True credit'
23
+ end
24
+
25
+ it 'should have gsa' do
26
+ _(@response.gsa).must_equal false
27
+ end
28
+
29
+ it 'should have corporate' do
30
+ _(@response.corporate).must_equal true
31
+ end
32
+
33
+ it 'should have fsa' do
34
+ _(@response.fsa).must_equal false
35
+ end
36
+
37
+ it 'should have subtype' do
38
+ _(@response.subtype).must_equal 'Visa Corporate T&E'
39
+ end
40
+
41
+ it 'should have purchase' do
42
+ _(@response.purchase).must_equal false
43
+ end
44
+
45
+ it 'should have prepaid' do
46
+ _(@response.prepaid).must_equal false
47
+ end
48
+
49
+ it 'should have binlo' do
50
+ _(@response.binlo).must_equal '478823XXX'
51
+ end
52
+
53
+ it 'should have issuer' do
54
+ _(@response.issuer).must_equal "JPMorgan Chase Bank N.A. - Commercial"
55
+ end
56
+
57
+ it 'should have binhi' do
58
+ _(@response.binhi).must_equal "478825XXX"
59
+ end
60
+ end
61
+
62
+ describe '#body' do
63
+ it 'should generate hash with all the right values' do
64
+ _(@response.body).must_equal symbolize_keys(valid_bin_response)
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,56 @@
1
+ require 'test_helper'
2
+
3
+ describe CardConnect::Service::Bin do
4
+ before do
5
+ @connection = CardConnect::Connection.new.connection do |stubs|
6
+ path = "#{@service.path}/#{valid_bin_request['merchid']}/#{valid_bin_request['token']}"
7
+ stubs.get(path) { [200, {}, valid_bin_response] }
8
+ end
9
+ @service = CardConnect::Service::Bin.new(@connection)
10
+ end
11
+
12
+ after do
13
+ @service = nil
14
+ end
15
+
16
+ it 'must have the right path' do
17
+ _(@service.path).must_equal '/cardconnect/rest/bin'
18
+ end
19
+
20
+ describe '#build_request' do
21
+ before do
22
+ @valid_params = valid_bin_request
23
+ end
24
+
25
+ after do
26
+ @valid_params = nil
27
+ end
28
+
29
+ it 'creates a bin request object with the passed in params' do
30
+ @service.build_request(@valid_params)
31
+
32
+ _(@service.request).must_be_kind_of CardConnect::Service::BinRequest
33
+ _(@service.request.token).must_equal '9477709629051443'
34
+ _(@service.request.merchid).must_equal '000000927996'
35
+ end
36
+
37
+ it 'uses default merchant ID if merchid is not passed in' do
38
+ @service.build_request(@valid_params.reject! { |k, _| k == 'merchid' })
39
+ _(@service.request).must_be_kind_of CardConnect::Service::BinRequest
40
+ _(@service.request.merchid).must_equal 'merchant123'
41
+ end
42
+ end
43
+
44
+ describe '#submit' do
45
+ it 'raises an error when there is no request' do
46
+ _(@service.request.nil?).must_equal true
47
+ _(-> { @service.submit }).must_raise CardConnect::Error
48
+ end
49
+
50
+ it 'creates a response when a valid request is processed' do
51
+ @service.build_request(valid_bin_request)
52
+ @service.submit
53
+ _(@service.response).must_be_kind_of CardConnect::Service::BinResponse
54
+ end
55
+ end
56
+ end
@@ -11,55 +11,55 @@ describe CardConnect::Service::CaptureRequest do
11
11
 
12
12
  describe 'FIELDS' do
13
13
  it 'should have merchant id' do
14
- @request.merchid.must_equal '000000927996'
14
+ _(@request.merchid).must_equal '000000927996'
15
15
  end
16
16
 
17
17
  it 'should have retrieval reference number' do
18
- @request.retref.must_equal '288002073633'
18
+ _(@request.retref).must_equal '288002073633'
19
19
  end
20
20
 
21
21
  it 'should have authorization code' do
22
- @request.authcode.must_equal '046221'
22
+ _(@request.authcode).must_equal '046221'
23
23
  end
24
24
 
25
25
  it 'should have amount' do
26
- @request.amount.must_equal '596.00'
26
+ _(@request.amount).must_equal '596.00'
27
27
  end
28
28
 
29
29
  it 'should have invoice id' do
30
- @request.invoiceid.must_equal '7890'
30
+ _(@request.invoiceid).must_equal '7890'
31
31
  end
32
32
 
33
33
  it 'should have PO number' do
34
- @request.ponumber.must_equal 'PO-0736332'
34
+ _(@request.ponumber).must_equal 'PO-0736332'
35
35
  end
36
36
 
37
37
  it 'should have tax amount' do
38
- @request.taxamnt.must_equal '40.00'
38
+ _(@request.taxamnt).must_equal '40.00'
39
39
  end
40
40
  end
41
41
 
42
42
  describe '#valid?' do
43
43
  it 'should not be valid if no attributes are passed in' do
44
- CardConnect::Service::CaptureRequest.new.valid?.must_equal false
44
+ _(CardConnect::Service::CaptureRequest.new.valid?).must_equal false
45
45
  end
46
46
 
47
47
  it 'should be valid if valid attributes are passed in' do
48
- CardConnect::Service::CaptureRequest.new(valid_capture_request).valid?.must_equal true
48
+ _(CardConnect::Service::CaptureRequest.new(valid_capture_request).valid?).must_equal true
49
49
  end
50
50
  end
51
51
 
52
52
  describe '#errors' do
53
53
  CardConnect::Service::CaptureRequest::REQUIRED_FIELDS.each do |field|
54
54
  it "should have an error message if #{field} is missing" do
55
- CardConnect::Service::CaptureRequest.new.errors.must_include "#{field.to_s.capitalize} is missing"
55
+ _(CardConnect::Service::CaptureRequest.new.errors).must_include "#{field.to_s.capitalize} is missing"
56
56
  end
57
57
  end
58
58
  end
59
59
 
60
60
  describe '#payload' do
61
61
  it 'should generate hash with all the right values' do
62
- @request.payload.must_equal symbolize_keys(valid_capture_request)
62
+ _(@request.payload).must_equal symbolize_keys(valid_capture_request)
63
63
  end
64
64
  end
65
65
  end
@@ -11,29 +11,29 @@ describe CardConnect::Service::CaptureResponse do
11
11
 
12
12
  describe 'FIELDS' do
13
13
  it 'should have merchant id' do
14
- @response.merchid.must_equal '000000927996'
14
+ _(@response.merchid).must_equal '000000927996'
15
15
  end
16
16
 
17
17
  it 'should have account' do
18
- @response.account.must_equal '41XXXXXXXXXX4113'
18
+ _(@response.account).must_equal '41XXXXXXXXXX4113'
19
19
  end
20
20
 
21
21
  it 'should have amount' do
22
- @response.amount.must_equal '596.00'
22
+ _(@response.amount).must_equal '596.00'
23
23
  end
24
24
 
25
25
  it 'should have retrieval reference number' do
26
- @response.retref.must_equal '288002073633'
26
+ _(@response.retref).must_equal '288002073633'
27
27
  end
28
28
 
29
29
  it 'should have settlement status' do
30
- @response.setlstat.must_equal 'Pending'
30
+ _(@response.setlstat).must_equal 'Pending'
31
31
  end
32
32
  end
33
33
 
34
34
  describe '#body' do
35
35
  it 'should generate hash with all the right values' do
36
- @response.body.must_equal symbolize_keys(valid_capture_response)
36
+ _(@response.body).must_equal symbolize_keys(valid_capture_response)
37
37
  end
38
38
  end
39
39
  end