cardconnect 2.3.0 → 2.4.0
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.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +35 -0
- data/CHANGELOG.md +4 -0
- data/README.md +17 -1
- data/cardconnect.gemspec +1 -4
- data/lib/cardconnect/connection.rb +3 -3
- data/lib/cardconnect/services/authorization/authorization_response.rb +1 -1
- data/lib/cardconnect/services/inquire/inquire_response.rb +1 -1
- data/lib/cardconnect/version.rb +1 -1
- data/test/api_response_stubs.rb +2 -0
- 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 +6 -6
- data/test/cardconnect/services/bin/bin_response_test.rb +13 -13
- data/test/cardconnect/services/bin/bin_test.rb +9 -9
- 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 +17 -17
- 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 +28 -28
- 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 +1 -1
- metadata +9 -38
- data/.travis.yml +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 392819d44d5b57e895e919ff4d8f09be8b2a03301100f944fd79b3b5cb321a52
|
4
|
+
data.tar.gz: 5d972cde73c7482d8de49279a68fc00429058244f1a6b960e823a130c1b437db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48c09c70ca14beffd6bc7e4d8b6999b4ad9b20bc4b04c9137908c514af52950f717e9cd02021187bd79831594a449b01ea734db7b2f37e67e124e4f9a76eb6b7
|
7
|
+
data.tar.gz: 0c5ce20dccadabad622ade2c9b46911672187b0734292e9470fffd4ae427138bc4561521d9bfb41656581307164c6b34057b6232a77dc62ac0299841d3b8fd0d
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# This workflow uses actions that are not certified by GitHub.
|
2
|
+
# They are provided by a third-party and are governed by
|
3
|
+
# separate terms of service, privacy policy, and support
|
4
|
+
# documentation.
|
5
|
+
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
+
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
+
|
8
|
+
name: Ruby
|
9
|
+
|
10
|
+
on:
|
11
|
+
push:
|
12
|
+
branches: [ "master" ]
|
13
|
+
pull_request:
|
14
|
+
branches: [ "master" ]
|
15
|
+
|
16
|
+
permissions:
|
17
|
+
contents: read
|
18
|
+
|
19
|
+
jobs:
|
20
|
+
test:
|
21
|
+
|
22
|
+
runs-on: ubuntu-latest
|
23
|
+
strategy:
|
24
|
+
matrix:
|
25
|
+
ruby-version: ['3.0', '3.1', '3.2']
|
26
|
+
|
27
|
+
steps:
|
28
|
+
- uses: actions/checkout@v3
|
29
|
+
- name: Set up Ruby
|
30
|
+
uses: ruby/setup-ruby@v1
|
31
|
+
with:
|
32
|
+
ruby-version: ${{ matrix.ruby-version }}
|
33
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
34
|
+
- name: Run tests
|
35
|
+
run: bundle exec rake
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,6 @@ CardConnect API Ruby Client
|
|
4
4
|
|
5
5
|
[](http://badge.fury.io/rb/cardconnect)
|
6
6
|
[](https://codeclimate.com/github/mobilecause/cardconnect)
|
7
|
-
[](https://travis-ci.org/mobilecause/cardconnect)
|
8
7
|
|
9
8
|
## Installation
|
10
9
|
|
@@ -149,6 +148,23 @@ response = service.submit
|
|
149
148
|
|
150
149
|
http://developer.cardconnect.com/cardconnect-api/#response-codes
|
151
150
|
|
151
|
+
## Run-time logins
|
152
|
+
Typically, you want to use `config/initializers/cardconnect.rb` to set your API username and password details in a secure way, as detailed above. If you need to connect to multiple CardConnect accounts, you can specify the username/password immediately before processing a transaction.
|
153
|
+
|
154
|
+
Example:
|
155
|
+
```
|
156
|
+
config = CardConnect::Configuration.new
|
157
|
+
config.api_username = "username"
|
158
|
+
config.api_password = "password123"
|
159
|
+
config.endpoint = "https://url.com"
|
160
|
+
|
161
|
+
connection = CardConnect::Connection.new(config).connection
|
162
|
+
service = CardConnect::Service::Authorize.new(connection)
|
163
|
+
service.build_request(params)
|
164
|
+
response = service.submit
|
165
|
+
```
|
166
|
+
Username, password, and/or endpoint can be defined either in the CardConnect initializer or overridden at runtime.
|
167
|
+
|
152
168
|
## To Do:
|
153
169
|
|
154
170
|
#### Authorization Service
|
data/cardconnect.gemspec
CHANGED
@@ -18,8 +18,5 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.
|
22
|
-
|
23
|
-
spec.add_dependency 'faraday', '~> 0.12.1'
|
24
|
-
spec.add_dependency 'faraday_middleware', '~> 0.11.0.1'
|
21
|
+
spec.add_dependency 'faraday', '~> 2.7.4'
|
25
22
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'faraday'
|
2
|
-
require 'faraday_middleware'
|
3
2
|
|
4
3
|
module CardConnect
|
5
4
|
class Connection
|
@@ -7,9 +6,10 @@ module CardConnect
|
|
7
6
|
@config = config
|
8
7
|
end
|
9
8
|
|
10
|
-
def connection
|
9
|
+
def connection(config = nil)
|
10
|
+
config ||= @config
|
11
11
|
@connection ||= Faraday.new(faraday_options) do |f|
|
12
|
-
f.request :
|
12
|
+
f.request :authorization, :basic, config.api_username, config.api_password
|
13
13
|
f.request :json
|
14
14
|
|
15
15
|
f.response :json, content_type: /\bjson$/
|
@@ -3,7 +3,7 @@ module CardConnect
|
|
3
3
|
class AuthorizationResponse
|
4
4
|
include Utils
|
5
5
|
|
6
|
-
FIELDS = [:respstat, :retref, :account, :token, :amount, :merchid, :respcode,
|
6
|
+
FIELDS = [:respstat, :retref, :account, :expiry, :token, :amount, :merchid, :respcode,
|
7
7
|
:resptext, :respproc, :avsresp, :cvvresp, :authcode, :commcard, :profileid, :acctid].freeze
|
8
8
|
|
9
9
|
attr_accessor(*FIELDS)
|
@@ -6,7 +6,7 @@ module CardConnect
|
|
6
6
|
FIELDS = [
|
7
7
|
:merchid, :account, :amount, :currency, :retref, :respcode,
|
8
8
|
:respproc, :respstat, :resptext, :setlstat, :capturedate, :batchid,
|
9
|
-
:token, :authdate, :lastfour, :name, :settledate
|
9
|
+
:token, :authdate, :lastfour, :name, :settledate, :expiry
|
10
10
|
].freeze
|
11
11
|
|
12
12
|
# Settlement Status
|
data/lib/cardconnect/version.rb
CHANGED
data/test/api_response_stubs.rb
CHANGED
@@ -13,6 +13,7 @@ def valid_auth_response # rubocop:disable Metrics/MethodLength
|
|
13
13
|
'authcode' => '046221',
|
14
14
|
'respproc' => 'FNOR',
|
15
15
|
'commcard' => 'N',
|
16
|
+
'expiry' => '04/32',
|
16
17
|
'profileid' => '12345678',
|
17
18
|
'acctid' => nil
|
18
19
|
}
|
@@ -47,6 +48,7 @@ def valid_inquire_response # rubocop:disable Metrics/MethodLength
|
|
47
48
|
'respstat' => 'A',
|
48
49
|
'currency' => 'USD',
|
49
50
|
'token' => '9418594164541111',
|
51
|
+
'expiry' => '04/32',
|
50
52
|
'authdate' => '20180410',
|
51
53
|
'lastfour' => '1111',
|
52
54
|
'name' => 'TOM JONES',
|
@@ -10,22 +10,22 @@ describe CardConnect::Configuration do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'must respond to merchant id' do
|
13
|
-
@config.must_respond_to :merchant_id
|
13
|
+
_(@config).must_respond_to :merchant_id
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'must respond to api username' do
|
17
|
-
@config.must_respond_to :api_username
|
17
|
+
_(@config).must_respond_to :api_username
|
18
18
|
end
|
19
19
|
|
20
20
|
it 'must respond to api password' do
|
21
|
-
@config.must_respond_to :api_password
|
21
|
+
_(@config).must_respond_to :api_password
|
22
22
|
end
|
23
23
|
|
24
24
|
it 'must respond to endpoint' do
|
25
|
-
@config.must_respond_to :endpoint
|
25
|
+
_(@config).must_respond_to :endpoint
|
26
26
|
end
|
27
27
|
|
28
28
|
it 'must respond to connection_options' do
|
29
|
-
@config.must_respond_to :connection_options
|
29
|
+
_(@config).must_respond_to :connection_options
|
30
30
|
end
|
31
31
|
end
|
@@ -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
|
-
|
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::
|
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 :===,
|
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 :===,
|
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
|
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
|
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
|
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
|
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
|
47
|
-
|
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
|
@@ -11,35 +11,35 @@ describe CardConnect::Service::BinRequest 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 token' do
|
18
|
-
@request.token.must_equal '9477709629051443'
|
18
|
+
_(@request.token).must_equal '9477709629051443'
|
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::BinRequest.new.valid
|
24
|
+
_(CardConnect::Service::BinRequest.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::BinRequest.new(valid_bin_request).valid
|
28
|
+
_(CardConnect::Service::BinRequest.new(valid_bin_request).valid?).must_equal true
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
32
|
describe '#errors' do
|
33
33
|
CardConnect::Service::BinRequest::REQUIRED_FIELDS.each do |field|
|
34
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"
|
35
|
+
_(CardConnect::Service::BinRequest.new.errors).must_include "#{field.to_s.capitalize} is missing"
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
40
|
describe '#payload' do
|
41
41
|
it 'should generate the correct path params' do
|
42
|
-
@request.payload.must_equal '/000000927996/9477709629051443'
|
42
|
+
_(@request.payload).must_equal '/000000927996/9477709629051443'
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|