cardconnect 2.2.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/ruby.yml +35 -0
- data/CHANGELOG.md +13 -0
- data/README.md +29 -5
- data/cardconnect.gemspec +1 -4
- data/lib/cardconnect/connection.rb +3 -3
- data/lib/cardconnect/services/authorization/authorization_response.rb +2 -6
- data/lib/cardconnect/services/bin/bin.rb +15 -0
- data/lib/cardconnect/services/bin/bin_request.rb +43 -0
- data/lib/cardconnect/services/bin/bin_response.rb +36 -0
- data/lib/cardconnect/services/capture/capture_request.rb +1 -5
- data/lib/cardconnect/services/capture/capture_response.rb +9 -11
- data/lib/cardconnect/services/inquire/inquire_response.rb +13 -14
- data/lib/cardconnect/services/profile/profile.rb +1 -1
- data/lib/cardconnect/services/profile/profile_delete_response.rb +1 -5
- data/lib/cardconnect/services/profile/profile_get_response.rb +6 -8
- data/lib/cardconnect/services/profile/profile_put_response.rb +1 -5
- data/lib/cardconnect/services/refund/refund_response.rb +1 -5
- data/lib/cardconnect/services/settlement_status/settlement_status_response.rb +1 -5
- data/lib/cardconnect/services/void/void_response.rb +1 -5
- data/lib/cardconnect/utils.rb +3 -6
- data/lib/cardconnect/version.rb +1 -1
- data/lib/cardconnect.rb +5 -1
- data/test/api_request_stubs.rb +7 -0
- data/test/api_response_stubs.rb +40 -6
- data/test/cardconnect/configuration_test.rb +5 -5
- data/test/cardconnect/connection_test.rb +6 -6
- data/test/cardconnect/services/authorization/authorization_request_test.rb +35 -35
- data/test/cardconnect/services/authorization/authorization_response_test.rb +19 -19
- data/test/cardconnect/services/authorization/authorization_test.rb +11 -11
- data/test/cardconnect/services/bin/bin_request_test.rb +45 -0
- data/test/cardconnect/services/bin/bin_response_test.rb +67 -0
- data/test/cardconnect/services/bin/bin_test.rb +56 -0
- data/test/cardconnect/services/capture/capture_request_test.rb +11 -11
- data/test/cardconnect/services/capture/capture_response_test.rb +6 -6
- data/test/cardconnect/services/capture/capture_test.rb +9 -9
- data/test/cardconnect/services/inquire/inquire_request_test.rb +6 -6
- data/test/cardconnect/services/inquire/inquire_response_test.rb +35 -11
- data/test/cardconnect/services/inquire/inquire_test.rb +9 -9
- data/test/cardconnect/services/profile/profile_delete_request_test.rb +7 -7
- data/test/cardconnect/services/profile/profile_delete_response_test.rb +11 -11
- data/test/cardconnect/services/profile/profile_get_request_test.rb +7 -7
- data/test/cardconnect/services/profile/profile_get_response_test.rb +34 -26
- data/test/cardconnect/services/profile/profile_put_request_test.rb +23 -23
- data/test/cardconnect/services/profile/profile_put_response_test.rb +28 -28
- data/test/cardconnect/services/profile/profile_test.rb +27 -27
- data/test/cardconnect/services/refund/refund_request_test.rb +7 -7
- data/test/cardconnect/services/refund/refund_response_test.rb +13 -13
- data/test/cardconnect/services/refund/refund_test.rb +9 -9
- data/test/cardconnect/services/settlement_status/settlement_status_request_test.rb +12 -12
- data/test/cardconnect/services/settlement_status/settlement_status_response_test.rb +8 -8
- data/test/cardconnect/services/settlement_status/settlement_status_test.rb +9 -9
- data/test/cardconnect/services/void/void_request_test.rb +7 -7
- data/test/cardconnect/services/void/void_response_test.rb +14 -14
- data/test/cardconnect/services/void/void_test.rb +9 -9
- data/test/cardconnect_test.rb +2 -2
- data/test/test_helper.rb +3 -1
- metadata +18 -38
- data/.travis.yml +0 -9
@@ -11,125 +11,125 @@ describe CardConnect::Service::ProfilePutResponse do
|
|
11
11
|
|
12
12
|
describe 'FIELDS' do
|
13
13
|
it 'should have profile id' do
|
14
|
-
@response.profileid.must_equal '12305454023615201322'
|
14
|
+
_(@response.profileid).must_equal '12305454023615201322'
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'should have account id' do
|
18
|
-
@response.acctid.must_equal '1'
|
18
|
+
_(@response.acctid).must_equal '1'
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'should have response status' do
|
22
|
-
@response.respstat.must_equal 'A'
|
22
|
+
_(@response.respstat).must_equal 'A'
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'should have account' do
|
26
|
-
@response.account.must_equal '41XXXXXXXXXX1111'
|
26
|
+
_(@response.account).must_equal '41XXXXXXXXXX1111'
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'should have response code' do
|
30
|
-
@response.respcode.must_equal '09'
|
30
|
+
_(@response.respcode).must_equal '09'
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'should have response text' do
|
34
|
-
@response.resptext.must_equal 'Profile Saved'
|
34
|
+
_(@response.resptext).must_equal 'Profile Saved'
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'should have respproc' do
|
38
|
-
@response.respproc.must_equal 'PPS'
|
38
|
+
_(@response.respproc).must_equal 'PPS'
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'should have accttype' do
|
42
|
-
@response.accttype.must_equal 'VISA'
|
42
|
+
_(@response.accttype).must_equal 'VISA'
|
43
43
|
end
|
44
44
|
|
45
45
|
it 'should have expiry' do
|
46
|
-
@response.expiry.must_equal '0214'
|
46
|
+
_(@response.expiry).must_equal '0214'
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'should have name' do
|
50
|
-
@response.name.must_equal 'TOM JONES'
|
50
|
+
_(@response.name).must_equal 'TOM JONES'
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'should have address' do
|
54
|
-
@response.address.must_equal '123 MAIN STREET'
|
54
|
+
_(@response.address).must_equal '123 MAIN STREET'
|
55
55
|
end
|
56
56
|
|
57
57
|
it 'should have city' do
|
58
|
-
@response.city.must_equal 'ANYTOWN'
|
58
|
+
_(@response.city).must_equal 'ANYTOWN'
|
59
59
|
end
|
60
60
|
|
61
61
|
it 'should have region' do
|
62
|
-
@response.region.must_equal 'AK'
|
62
|
+
_(@response.region).must_equal 'AK'
|
63
63
|
end
|
64
64
|
|
65
65
|
it 'should have country' do
|
66
|
-
@response.country.must_equal 'US'
|
66
|
+
_(@response.country).must_equal 'US'
|
67
67
|
end
|
68
68
|
|
69
69
|
it 'should have phone' do
|
70
|
-
@response.phone.must_equal '7778789999'
|
70
|
+
_(@response.phone).must_equal '7778789999'
|
71
71
|
end
|
72
72
|
|
73
73
|
it 'should have postal' do
|
74
|
-
@response.postal.must_equal '19090'
|
74
|
+
_(@response.postal).must_equal '19090'
|
75
75
|
end
|
76
76
|
|
77
77
|
it 'should have ssnl4' do
|
78
|
-
@response.ssnl4.must_equal '3655'
|
78
|
+
_(@response.ssnl4).must_equal '3655'
|
79
79
|
end
|
80
80
|
|
81
81
|
it 'should have email' do
|
82
|
-
@response.email.must_equal 'test@test.com'
|
82
|
+
_(@response.email).must_equal 'test@test.com'
|
83
83
|
end
|
84
84
|
|
85
85
|
it 'should have defaultacct' do
|
86
|
-
@response.defaultacct.must_equal 'Y'
|
86
|
+
_(@response.defaultacct).must_equal 'Y'
|
87
87
|
end
|
88
88
|
|
89
89
|
it 'should have license' do
|
90
|
-
@response.license.must_equal '123451254'
|
90
|
+
_(@response.license).must_equal '123451254'
|
91
91
|
end
|
92
92
|
|
93
93
|
it 'should have token' do
|
94
|
-
@response.token.must_equal '9441149619831111'
|
94
|
+
_(@response.token).must_equal '9441149619831111'
|
95
95
|
end
|
96
96
|
|
97
97
|
it 'should have gsacard' do
|
98
|
-
@response.gsacard.must_equal 'N'
|
98
|
+
_(@response.gsacard).must_equal 'N'
|
99
99
|
end
|
100
100
|
|
101
101
|
it 'should have auoptout' do
|
102
|
-
@response.auoptout.must_equal 'N'
|
102
|
+
_(@response.auoptout).must_equal 'N'
|
103
103
|
end
|
104
104
|
end
|
105
105
|
|
106
106
|
describe '#success?' do
|
107
107
|
it 'should be true when there are no errors' do
|
108
|
-
@response.success
|
108
|
+
_(@response.success?).must_equal true
|
109
109
|
end
|
110
110
|
|
111
111
|
it 'should be false when there are errors' do
|
112
112
|
prof_response = valid_profile_put_response.merge!('respstat' => 'C', 'resptext' => 'this is an error')
|
113
113
|
response = CardConnect::Service::ProfilePutResponse.new(prof_response)
|
114
|
-
response.success
|
114
|
+
_(response.success?).must_equal false
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
118
118
|
describe '#errors' do
|
119
119
|
it 'should be empty when there are no errors' do
|
120
|
-
@response.errors.must_be_empty
|
120
|
+
_(@response.errors).must_be_empty
|
121
121
|
end
|
122
122
|
|
123
123
|
it 'should be an array of error messages when there are errors' do
|
124
124
|
prof_response = valid_profile_put_response.merge!('respstat' => 'C', 'resptext' => 'this is an error')
|
125
125
|
response = CardConnect::Service::ProfilePutResponse.new(prof_response)
|
126
|
-
response.errors.must_equal ['this is an error']
|
126
|
+
_(response.errors).must_equal ['this is an error']
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
130
130
|
describe '#body' do
|
131
131
|
it 'should generate hash with all the right values' do
|
132
|
-
@response.body.must_equal symbolize_keys(valid_profile_put_response)
|
132
|
+
_(@response.body).must_equal symbolize_keys(valid_profile_put_response)
|
133
133
|
end
|
134
134
|
end
|
135
135
|
end
|
@@ -16,7 +16,7 @@ describe CardConnect::Service::Profile do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'must have the right path' do
|
19
|
-
@service.path.must_equal '/cardconnect/rest/profile'
|
19
|
+
_(@service.path).must_equal '/cardconnect/rest/profile'
|
20
20
|
end
|
21
21
|
|
22
22
|
describe '#build_request' do
|
@@ -31,28 +31,28 @@ describe CardConnect::Service::Profile do
|
|
31
31
|
it 'creates a profile request object with the passed in params' do
|
32
32
|
@service.build_request(@valid_params)
|
33
33
|
|
34
|
-
@service.request.must_be_kind_of CardConnect::Service::ProfileGetRequest
|
35
|
-
@service.request.acctid.must_equal '1'
|
36
|
-
@service.request.merchid.must_equal '000000927996'
|
34
|
+
_(@service.request).must_be_kind_of CardConnect::Service::ProfileGetRequest
|
35
|
+
_(@service.request.acctid).must_equal '1'
|
36
|
+
_(@service.request.merchid).must_equal '000000927996'
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'uses default merchant ID if merchid is not passed in' do
|
40
40
|
@service.build_request(@valid_params.reject! { |k, _| k == 'merchid' })
|
41
|
-
@service.request.must_be_kind_of CardConnect::Service::ProfileGetRequest
|
42
|
-
@service.request.merchid.must_equal 'merchant123'
|
41
|
+
_(@service.request).must_be_kind_of CardConnect::Service::ProfileGetRequest
|
42
|
+
_(@service.request.merchid).must_equal 'merchant123'
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
describe '#submit' do
|
47
47
|
it 'raises an error when there is no request' do
|
48
|
-
@service.request.nil
|
49
|
-
proc { @service.submit }.must_raise CardConnect::Error
|
48
|
+
_(@service.request.nil?).must_equal true
|
49
|
+
_(proc { @service.submit }).must_raise CardConnect::Error
|
50
50
|
end
|
51
51
|
|
52
52
|
it 'creates a response when a valid request is processed' do
|
53
53
|
@service.build_request(valid_profile_request)
|
54
54
|
@service.submit
|
55
|
-
@service.response.must_be_kind_of CardConnect::Service::ProfileGetResponse
|
55
|
+
_(@service.response).must_be_kind_of CardConnect::Service::ProfileGetResponse
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
@@ -71,7 +71,7 @@ describe CardConnect::Service::Profile do
|
|
71
71
|
end
|
72
72
|
|
73
73
|
it 'must have the right path' do
|
74
|
-
@service.path.must_equal '/cardconnect/rest/profile'
|
74
|
+
_(@service.path).must_equal '/cardconnect/rest/profile'
|
75
75
|
end
|
76
76
|
|
77
77
|
describe '#build_request' do
|
@@ -86,28 +86,28 @@ describe CardConnect::Service::Profile do
|
|
86
86
|
it 'creates a profile request object with the passed in params' do
|
87
87
|
@service.build_request(@valid_params)
|
88
88
|
|
89
|
-
@service.request.must_be_kind_of CardConnect::Service::ProfileDeleteRequest
|
90
|
-
@service.request.acctid.must_equal '1'
|
91
|
-
@service.request.merchid.must_equal '000000927996'
|
89
|
+
_(@service.request).must_be_kind_of CardConnect::Service::ProfileDeleteRequest
|
90
|
+
_(@service.request.acctid).must_equal '1'
|
91
|
+
_(@service.request.merchid).must_equal '000000927996'
|
92
92
|
end
|
93
93
|
|
94
94
|
it 'uses default merchant ID if merchid is not passed in' do
|
95
95
|
@service.build_request(@valid_params.reject! { |k, _| k == 'merchid' })
|
96
|
-
@service.request.must_be_kind_of CardConnect::Service::ProfileDeleteRequest
|
97
|
-
@service.request.merchid.must_equal 'merchant123'
|
96
|
+
_(@service.request).must_be_kind_of CardConnect::Service::ProfileDeleteRequest
|
97
|
+
_(@service.request.merchid).must_equal 'merchant123'
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
101
|
describe '#submit' do
|
102
102
|
it 'raises an error when there is no request' do
|
103
|
-
@service.request.nil
|
104
|
-
proc { @service.submit }.must_raise CardConnect::Error
|
103
|
+
_(@service.request.nil?).must_equal true
|
104
|
+
_(proc { @service.submit }).must_raise CardConnect::Error
|
105
105
|
end
|
106
106
|
|
107
107
|
it 'creates a response when a valid request is processed' do
|
108
108
|
@service.build_request(valid_profile_request)
|
109
109
|
@service.submit
|
110
|
-
@service.response.must_be_kind_of CardConnect::Service::ProfileDeleteResponse
|
110
|
+
_(@service.response).must_be_kind_of CardConnect::Service::ProfileDeleteResponse
|
111
111
|
end
|
112
112
|
end
|
113
113
|
end
|
@@ -125,7 +125,7 @@ describe CardConnect::Service::Profile do
|
|
125
125
|
end
|
126
126
|
|
127
127
|
it 'must have the right path' do
|
128
|
-
@service.path.must_equal '/cardconnect/rest/profile'
|
128
|
+
_(@service.path).must_equal '/cardconnect/rest/profile'
|
129
129
|
end
|
130
130
|
|
131
131
|
describe '#build_request' do
|
@@ -140,28 +140,28 @@ describe CardConnect::Service::Profile do
|
|
140
140
|
it 'creates a profile request object with the passed in params' do
|
141
141
|
@service.build_request(@valid_params)
|
142
142
|
|
143
|
-
@service.request.must_be_kind_of CardConnect::Service::ProfilePutRequest
|
144
|
-
@service.request.merchid.must_equal '000000927996'
|
145
|
-
@service.request.profileid.must_equal '12345678901234567890'
|
143
|
+
_(@service.request).must_be_kind_of CardConnect::Service::ProfilePutRequest
|
144
|
+
_(@service.request.merchid).must_equal '000000927996'
|
145
|
+
_(@service.request.profileid).must_equal '12345678901234567890'
|
146
146
|
end
|
147
147
|
|
148
148
|
it 'uses default merchant ID if merchid is not passed in' do
|
149
149
|
@service.build_request(@valid_params.reject! { |k, _| k == 'merchid' })
|
150
|
-
@service.request.must_be_kind_of CardConnect::Service::ProfilePutRequest
|
151
|
-
@service.request.merchid.must_equal 'merchant123'
|
150
|
+
_(@service.request).must_be_kind_of CardConnect::Service::ProfilePutRequest
|
151
|
+
_(@service.request.merchid).must_equal 'merchant123'
|
152
152
|
end
|
153
153
|
end
|
154
154
|
|
155
155
|
describe '#submit' do
|
156
156
|
it 'raises an error when there is no request' do
|
157
|
-
@service.request.nil
|
158
|
-
proc { @service.submit }.must_raise CardConnect::Error
|
157
|
+
_(@service.request.nil?).must_equal true
|
158
|
+
_(proc { @service.submit }).must_raise CardConnect::Error
|
159
159
|
end
|
160
160
|
|
161
161
|
it 'creates a response when a valid request is processed' do
|
162
162
|
@service.build_request(valid_profile_request)
|
163
163
|
@service.submit
|
164
|
-
@service.response.must_be_kind_of CardConnect::Service::ProfilePutResponse
|
164
|
+
_(@service.response).must_be_kind_of CardConnect::Service::ProfilePutResponse
|
165
165
|
end
|
166
166
|
end
|
167
167
|
end
|
@@ -11,39 +11,39 @@ describe CardConnect::Service::RefundRequest 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 '288009185241'
|
18
|
+
_(@request.retref).must_equal '288009185241'
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'should have amount' do
|
22
|
-
@request.amount.must_equal '59.60'
|
22
|
+
_(@request.amount).must_equal '59.60'
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
describe '#valid?' do
|
27
27
|
it 'should not be valid if no attributes are passed in' do
|
28
|
-
CardConnect::Service::RefundRequest.new.valid
|
28
|
+
_(CardConnect::Service::RefundRequest.new.valid?).must_equal false
|
29
29
|
end
|
30
30
|
|
31
31
|
it 'should be valid if valid attributes are passed in' do
|
32
|
-
CardConnect::Service::RefundRequest.new(valid_refund_request).valid
|
32
|
+
_(CardConnect::Service::RefundRequest.new(valid_refund_request).valid?).must_equal true
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
describe '#errors' do
|
37
37
|
CardConnect::Service::RefundRequest::REQUIRED_FIELDS.each do |field|
|
38
38
|
it "should have an error message if #{field} is missing" do
|
39
|
-
CardConnect::Service::RefundRequest.new.errors.must_include "#{field.to_s.capitalize} is missing"
|
39
|
+
_(CardConnect::Service::RefundRequest.new.errors).must_include "#{field.to_s.capitalize} is missing"
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
describe '#payload' do
|
45
45
|
it 'should generate hash with all the right values' do
|
46
|
-
@request.payload.must_equal symbolize_keys(valid_refund_request)
|
46
|
+
_(@request.payload).must_equal symbolize_keys(valid_refund_request)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
@@ -11,65 +11,65 @@ describe CardConnect::Service::RefundResponse do
|
|
11
11
|
|
12
12
|
describe 'FIELDS' do
|
13
13
|
it 'should have the 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 the Amount' do
|
18
|
-
@response.amount.must_equal '59.60'
|
18
|
+
_(@response.amount).must_equal '59.60'
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'should have the Retrieval Reference Number' do
|
22
|
-
@response.retref.must_equal '288010185242'
|
22
|
+
_(@response.retref).must_equal '288010185242'
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'should have the Response Code' do
|
26
|
-
@response.respcode.must_equal '00'
|
26
|
+
_(@response.respcode).must_equal '00'
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'should have the Response Processor' do
|
30
|
-
@response.respproc.must_equal 'PPS'
|
30
|
+
_(@response.respproc).must_equal 'PPS'
|
31
31
|
end
|
32
32
|
|
33
33
|
it 'should have the status' do
|
34
|
-
@response.respstat.must_equal 'A'
|
34
|
+
_(@response.respstat).must_equal 'A'
|
35
35
|
end
|
36
36
|
|
37
37
|
it 'should have the Response text' do
|
38
|
-
@response.resptext.must_equal 'Approval'
|
38
|
+
_(@response.resptext).must_equal 'Approval'
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'should have authcode' do
|
42
|
-
@response.authcode.must_equal 'REFUND'
|
42
|
+
_(@response.authcode).must_equal 'REFUND'
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
46
|
describe '#success?' do
|
47
47
|
it 'should be true when there are no errors' do
|
48
|
-
@response.success
|
48
|
+
_(@response.success?).must_equal true
|
49
49
|
end
|
50
50
|
|
51
51
|
it 'should be false when there are errors' do
|
52
52
|
refund_response = valid_refund_response.merge!('respstat' => 'C', 'resptext' => 'this is an error')
|
53
53
|
response = CardConnect::Service::RefundResponse.new(refund_response)
|
54
|
-
response.success
|
54
|
+
_(response.success?).must_equal false
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
58
58
|
describe '#errors' do
|
59
59
|
it 'should be empty when there are no errors' do
|
60
|
-
@response.errors.must_be_empty
|
60
|
+
_(@response.errors).must_be_empty
|
61
61
|
end
|
62
62
|
|
63
63
|
it 'should be an array of error messages when there are errors' do
|
64
64
|
refund_response = valid_refund_response.merge!('respstat' => 'C', 'resptext' => 'this is an error')
|
65
65
|
response = CardConnect::Service::RefundResponse.new(refund_response)
|
66
|
-
response.errors.must_equal ['this is an error']
|
66
|
+
_(response.errors).must_equal ['this is an error']
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
70
|
describe '#body' do
|
71
71
|
it 'should generate hash with all the right values' do
|
72
|
-
@response.body.must_equal symbolize_keys(valid_refund_response)
|
72
|
+
_(@response.body).must_equal symbolize_keys(valid_refund_response)
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
@@ -13,7 +13,7 @@ describe CardConnect::Service::Refund do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'must have the right path' do
|
16
|
-
@service.path.must_equal '/cardconnect/rest/refund'
|
16
|
+
_(@service.path).must_equal '/cardconnect/rest/refund'
|
17
17
|
end
|
18
18
|
|
19
19
|
describe '#build_request' do
|
@@ -27,30 +27,30 @@ describe CardConnect::Service::Refund 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
35
|
|
36
|
-
@service.request.must_be_kind_of CardConnect::Service::RefundRequest
|
36
|
+
_(@service.request).must_be_kind_of CardConnect::Service::RefundRequest
|
37
37
|
|
38
|
-
@service.request.merchid.must_equal '000000927996'
|
39
|
-
@service.request.retref.must_equal '288009185241'
|
40
|
-
@service.request.amount.must_equal '59.60'
|
38
|
+
_(@service.request.merchid).must_equal '000000927996'
|
39
|
+
_(@service.request.retref).must_equal '288009185241'
|
40
|
+
_(@service.request.amount).must_equal '59.60'
|
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
|
47
|
-
proc { @service.submit }.must_raise CardConnect::Error
|
46
|
+
_(@service.request.nil?).must_equal true
|
47
|
+
_(proc { @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_refund_request)
|
52
52
|
@service.submit
|
53
|
-
@service.response.must_be_kind_of CardConnect::Service::RefundResponse
|
53
|
+
_(@service.response).must_be_kind_of CardConnect::Service::RefundResponse
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
@@ -11,21 +11,21 @@ describe CardConnect::Service::SettlementStatusRequest 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.date.must_equal '0110'
|
18
|
+
_(@request.date).must_equal '0110'
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
describe '#valid?' do
|
23
23
|
it 'should not be valid if no attributes are passed in' do
|
24
|
-
CardConnect::Service::SettlementStatusRequest.new.valid
|
24
|
+
_(CardConnect::Service::SettlementStatusRequest.new.valid?).must_equal false
|
25
25
|
end
|
26
26
|
|
27
27
|
it 'should be valid if valid attributes are passed in' do
|
28
|
-
CardConnect::Service::SettlementStatusRequest.new(valid_settlestat_request).valid
|
28
|
+
_(CardConnect::Service::SettlementStatusRequest.new(valid_settlestat_request).valid?).must_equal true
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
@@ -33,34 +33,34 @@ describe CardConnect::Service::SettlementStatusRequest do
|
|
33
33
|
CardConnect::Service::SettlementStatusRequest::REQUIRED_FIELDS.each do |field|
|
34
34
|
field_name = field.to_s.capitalize
|
35
35
|
it "should have an error message if #{field_name} is missing" do
|
36
|
-
CardConnect::Service::SettlementStatusRequest.new.errors.must_include "#{field_name} is missing"
|
36
|
+
_(CardConnect::Service::SettlementStatusRequest.new.errors).must_include "#{field_name} is missing"
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
describe '#validate_date_format' do
|
41
41
|
it 'should have an error when date is less than 4 characters long' do
|
42
42
|
request = CardConnect::Service::SettlementStatusRequest.new(date: '123')
|
43
|
-
request.valid
|
44
|
-
request.errors.must_include 'Date format is invalid. Please use MMDD format'
|
43
|
+
_(request.valid?).must_equal false
|
44
|
+
_(request.errors).must_include 'Date format is invalid. Please use MMDD format'
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'should have an error when date is more than 4 characters long' do
|
48
48
|
request = CardConnect::Service::SettlementStatusRequest.new(date: '12345')
|
49
|
-
request.valid
|
50
|
-
request.errors.must_include 'Date format is invalid. Please use MMDD format'
|
49
|
+
_(request.valid?).must_equal false
|
50
|
+
_(request.errors).must_include 'Date format is invalid. Please use MMDD format'
|
51
51
|
end
|
52
52
|
|
53
53
|
it 'should have an error when date is not parseable in MMDD format' do
|
54
54
|
request = CardConnect::Service::SettlementStatusRequest.new(date: '0000')
|
55
|
-
request.valid
|
56
|
-
request.errors.must_include 'Date format is invalid. Please use MMDD format'
|
55
|
+
_(request.valid?).must_equal false
|
56
|
+
_(request.errors).must_include 'Date format is invalid. Please use MMDD format'
|
57
57
|
end
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
61
|
describe '#payload' do
|
62
62
|
it 'should generate the correct path params' do
|
63
|
-
@request.payload.must_equal "?merchid=#{@request.merchid}&date=#{@request.date}&"
|
63
|
+
_(@request.payload).must_equal "?merchid=#{@request.merchid}&date=#{@request.date}&"
|
64
64
|
end
|
65
65
|
end
|
66
66
|
end
|
@@ -10,39 +10,39 @@ describe CardConnect::Service::SettlementStatusResponse do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'should have the merchant id' do
|
13
|
-
@response.merchid.must_equal '000000927996'
|
13
|
+
_(@response.merchid).must_equal '000000927996'
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'should have the batch id' do
|
17
|
-
@response.batchid.must_equal '71742042'
|
17
|
+
_(@response.batchid).must_equal '71742042'
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'should have the settlement status' do
|
21
|
-
@response.hoststat.must_equal 'GB'
|
21
|
+
_(@response.hoststat).must_equal 'GB'
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'should have the host batch id' do
|
25
|
-
@response.hostbatch.must_equal '71742041'
|
25
|
+
_(@response.hostbatch).must_equal '71742041'
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'should have the clearing house' do
|
29
|
-
@response.respproc.must_equal 'FNOR'
|
29
|
+
_(@response.respproc).must_equal 'FNOR'
|
30
30
|
end
|
31
31
|
|
32
32
|
it 'should have the transactions' do
|
33
|
-
@response.txns.must_equal [{ setlstat: 'N', retref: '179001161341' },
|
33
|
+
_(@response.txns).must_equal [{ setlstat: 'N', retref: '179001161341' },
|
34
34
|
{ setlstat: 'Y', retref: '179002161341' }]
|
35
35
|
end
|
36
36
|
|
37
37
|
describe '#body' do
|
38
38
|
it 'should have all the right fields in the body' do
|
39
|
-
@response.body.keys.must_equal [:merchid, :batchid, :hoststat, :hostbatch, :respproc, :txns]
|
39
|
+
_(@response.body.keys).must_equal [:merchid, :batchid, :hoststat, :hostbatch, :respproc, :txns]
|
40
40
|
end
|
41
41
|
|
42
42
|
it 'should generate hash with all the right values' do
|
43
43
|
valid_payload = symbolize_keys(valid_settlestat_response.first)
|
44
44
|
valid_payload[:txns] = valid_payload[:txns].map { |txn| symbolize_keys(txn) }
|
45
|
-
@response.body.must_equal valid_payload
|
45
|
+
_(@response.body).must_equal valid_payload
|
46
46
|
end
|
47
47
|
end
|
48
48
|
end
|
@@ -13,7 +13,7 @@ describe CardConnect::Service::SettlementStatus do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it 'must have the right path' do
|
16
|
-
@service.path.must_equal '/cardconnect/rest/settlestat'
|
16
|
+
_(@service.path).must_equal '/cardconnect/rest/settlestat'
|
17
17
|
end
|
18
18
|
|
19
19
|
describe '#build_request' do
|
@@ -28,28 +28,28 @@ describe CardConnect::Service::SettlementStatus do
|
|
28
28
|
it 'creates a Capture request object with the passed in params' do
|
29
29
|
@service.build_request(@valid_params)
|
30
30
|
|
31
|
-
@service.request.must_be_kind_of CardConnect::Service::SettlementStatusRequest
|
32
|
-
@service.request.merchid.must_equal '000000927996'
|
33
|
-
@service.request.date.must_equal '0110'
|
31
|
+
_(@service.request).must_be_kind_of CardConnect::Service::SettlementStatusRequest
|
32
|
+
_(@service.request.merchid).must_equal '000000927996'
|
33
|
+
_(@service.request.date).must_equal '0110'
|
34
34
|
end
|
35
35
|
|
36
36
|
it 'uses default merchant ID if merchid is not passed in' do
|
37
37
|
@service.build_request(@valid_params.reject! { |k, _| k == 'merchid' })
|
38
|
-
@service.request.must_be_kind_of CardConnect::Service::SettlementStatusRequest
|
39
|
-
@service.request.merchid.must_equal 'merchant123'
|
38
|
+
_(@service.request).must_be_kind_of CardConnect::Service::SettlementStatusRequest
|
39
|
+
_(@service.request.merchid).must_equal 'merchant123'
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
43
|
describe '#submit' do
|
44
44
|
it 'raises an error when there is no request' do
|
45
|
-
@service.request.nil
|
46
|
-
proc { @service.submit }.must_raise CardConnect::Error
|
45
|
+
_(@service.request.nil?).must_equal true
|
46
|
+
_(proc { @service.submit }).must_raise CardConnect::Error
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'creates a response when a valid request is processed' do
|
50
50
|
@service.build_request(valid_settlestat_request)
|
51
51
|
@service.submit
|
52
|
-
@service.response.must_be_kind_of CardConnect::Service::SettlementStatusResponse
|
52
|
+
_(@service.response).must_be_kind_of CardConnect::Service::SettlementStatusResponse
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|