cardconnect 2.2.0 → 2.3.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 +5 -5
- data/.travis.yml +3 -2
- data/CHANGELOG.md +9 -0
- data/README.md +12 -4
- data/lib/cardconnect.rb +5 -1
- data/lib/cardconnect/services/authorization/authorization_response.rb +1 -5
- 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/test/api_request_stubs.rb +7 -0
- data/test/api_response_stubs.rb +38 -6
- 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/inquire/inquire_response_test.rb +26 -2
- data/test/cardconnect/services/profile/profile_get_response_test.rb +8 -0
- data/test/test_helper.rb +2 -0
- metadata +12 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 1319ba15f85f510f12fc111ca22d27ac342d91688e0728c11a21b946af2e1f02
|
4
|
+
data.tar.gz: a39c7ab4f3b114407a8c5172ade8dd7d27fecca2e40457a2e029e5c592b0775a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d32dca6f0801050dec6a2645e4104f57347e1d4e26ec84f32410aadf3e07de9a92081c574a2023360972da3d69c6ec0c44f9e7ca3924e5564eab6870c57ad98d
|
7
|
+
data.tar.gz: 87948c7f5600544bff1801804bb5989e0a8d7e0bcb3bfa0f2120dd0f1a36eef03f8f0037e5418de32d3809b999e0d2f513738940ebcad856dc0d4d252b801047
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## v2.3.0
|
4
|
+
|
5
|
+
* Added the following fields to response objects (@shivashankar-ror):
|
6
|
+
- CaptureResponse: `:respproc, :resptext, :commcard, :respstat, :respcode, :batchid, :token`
|
7
|
+
- InquireResponse: `:capturedate, :batchid, :token, :authdate, :lastfour, :name, :currency, :settledate`
|
8
|
+
- ProfileGetResponse: `:gsacard, :auoptout`
|
9
|
+
|
10
|
+
* Added support for Bin Service (@shivashankar-ror)
|
11
|
+
|
3
12
|
## v2.2.0
|
4
13
|
|
5
14
|
* Add `token` field to Profile Service for create/update responses since this field can potentially be included in the response if a token hadn't already been created for that particular profile. (@mauriciozaffari)
|
data/README.md
CHANGED
@@ -133,6 +133,18 @@ service.build_request(params)
|
|
133
133
|
response = service.submit
|
134
134
|
```
|
135
135
|
|
136
|
+
### Bin Service
|
137
|
+
|
138
|
+
CardConnect documentation for this service can be found here: https://developer.cardconnect.com/cardconnect-api#bin-service
|
139
|
+
|
140
|
+
Example:
|
141
|
+
|
142
|
+
```ruby
|
143
|
+
service = CardConnect::Service::Bin.new
|
144
|
+
service.build_request(params)
|
145
|
+
response = service.submit
|
146
|
+
```
|
147
|
+
|
136
148
|
### Response Codes
|
137
149
|
|
138
150
|
http://developer.cardconnect.com/cardconnect-api/#response-codes
|
@@ -165,10 +177,6 @@ http://developer.cardconnect.com/cardconnect-api/#response-codes
|
|
165
177
|
|
166
178
|
* Close Batch Service needs to be implemented
|
167
179
|
|
168
|
-
#### Bin Service
|
169
|
-
|
170
|
-
* Bin Service needs to be implemented
|
171
|
-
|
172
180
|
## Contributing
|
173
181
|
|
174
182
|
1. Fork it ( https://github.com/mobilecause/cardconnect/fork )
|
data/lib/cardconnect.rb
CHANGED
@@ -23,6 +23,8 @@ require 'cardconnect/services/profile/profile_get_request'
|
|
23
23
|
require 'cardconnect/services/profile/profile_get_response'
|
24
24
|
require 'cardconnect/services/profile/profile_delete_request'
|
25
25
|
require 'cardconnect/services/profile/profile_delete_response'
|
26
|
+
require 'cardconnect/services/bin/bin_request'
|
27
|
+
require 'cardconnect/services/bin/bin_response'
|
26
28
|
|
27
29
|
require 'cardconnect/services/service_endpoint'
|
28
30
|
require 'cardconnect/services/authorization/authorization'
|
@@ -32,6 +34,8 @@ require 'cardconnect/services/inquire/inquire'
|
|
32
34
|
require 'cardconnect/services/refund/refund'
|
33
35
|
require 'cardconnect/services/void/void'
|
34
36
|
require 'cardconnect/services/profile/profile'
|
37
|
+
require 'cardconnect/services/bin/bin'
|
38
|
+
|
35
39
|
|
36
40
|
module CardConnect
|
37
41
|
class << self
|
@@ -47,4 +51,4 @@ module CardConnect
|
|
47
51
|
@connection ||= Connection.new.connection
|
48
52
|
end
|
49
53
|
end
|
50
|
-
end
|
54
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module CardConnect
|
2
|
+
module Service
|
3
|
+
class Bin < ServiceEndpoint
|
4
|
+
# Initializes a Bin Service
|
5
|
+
#
|
6
|
+
# @param connection [CardConnect::Connection]
|
7
|
+
# @return CardConnect::Service::Bin
|
8
|
+
def initialize(connection = CardConnect.connection)
|
9
|
+
super(connection)
|
10
|
+
@resource_name = '/bin'
|
11
|
+
@rest_method = 'get'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module CardConnect
|
2
|
+
module Service
|
3
|
+
class BinRequest
|
4
|
+
include Utils
|
5
|
+
|
6
|
+
REQUIRED_FIELDS = [:token, :merchid].freeze
|
7
|
+
|
8
|
+
FIELDS = REQUIRED_FIELDS
|
9
|
+
|
10
|
+
attr_accessor(*FIELDS)
|
11
|
+
attr_reader :errors
|
12
|
+
|
13
|
+
# Initializes a new BinGetRequest
|
14
|
+
#
|
15
|
+
# @param attrs [Hash]
|
16
|
+
# @return CardConnect::BinGetRequest
|
17
|
+
def initialize(attrs = {})
|
18
|
+
@errors = []
|
19
|
+
set_attributes(attrs, FIELDS)
|
20
|
+
validate_required_fields
|
21
|
+
end
|
22
|
+
|
23
|
+
# Indicates that the request is valid once it is built.
|
24
|
+
def valid?
|
25
|
+
errors.empty?
|
26
|
+
end
|
27
|
+
|
28
|
+
# Builds the request payload
|
29
|
+
def payload
|
30
|
+
"/#{merchid}/#{token}"
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def validate_required_fields
|
36
|
+
REQUIRED_FIELDS.each do |field|
|
37
|
+
value = send(field)
|
38
|
+
value.nil? || value.empty? ? errors.push("#{field.capitalize} is missing") : next
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module CardConnect
|
2
|
+
module Service
|
3
|
+
class BinResponse
|
4
|
+
include Utils
|
5
|
+
|
6
|
+
FIELDS = [
|
7
|
+
:country, :cardusestring, :gsa, :product,
|
8
|
+
:corporate, :fsa, :subtype, :purchase, :prepaid, :binlo,
|
9
|
+
:issuer, :binhi
|
10
|
+
].freeze
|
11
|
+
|
12
|
+
# Error messages
|
13
|
+
BIN_INFO_NOT_FOUND = 'No bin information found'
|
14
|
+
TOKEN_NOT_FOUND = 'Token not found'
|
15
|
+
BIN_NOT_ENABLED = 'Bin feature not enabled for merchant'
|
16
|
+
|
17
|
+
attr_accessor(*FIELDS)
|
18
|
+
attr_reader :errors
|
19
|
+
|
20
|
+
def initialize(response)
|
21
|
+
|
22
|
+
set_attributes(response, FIELDS)
|
23
|
+
# raise [response, self].inspect
|
24
|
+
@errors = []
|
25
|
+
end
|
26
|
+
|
27
|
+
def success?
|
28
|
+
@errors.empty?
|
29
|
+
end
|
30
|
+
|
31
|
+
def body
|
32
|
+
FIELDS.collect{|attr| {attr => send(attr)} }.reduce({}, :merge)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -29,11 +29,7 @@ module CardConnect
|
|
29
29
|
|
30
30
|
# Builds the request payload
|
31
31
|
def payload
|
32
|
-
|
33
|
-
FIELDS.each do |field|
|
34
|
-
payload.merge!(field => send(field))
|
35
|
-
end
|
36
|
-
payload
|
32
|
+
FIELDS.collect{|field| {field => send(field)} }.reduce({}, :merge)
|
37
33
|
end
|
38
34
|
|
39
35
|
private
|
@@ -3,15 +3,17 @@ module CardConnect
|
|
3
3
|
class CaptureResponse
|
4
4
|
include Utils
|
5
5
|
|
6
|
-
FIELDS = [:merchid, :account, :amount, :retref, :setlstat
|
6
|
+
FIELDS = [:merchid, :account, :amount, :retref, :setlstat, :respproc,
|
7
|
+
:resptext, :commcard, :respstat, :respcode,
|
8
|
+
:batchid, :token].freeze
|
7
9
|
|
8
10
|
# Settlement Statuses
|
9
11
|
TXN_NOT_FOUND = 'Txn not found' # The Retref was not found
|
10
|
-
AUTHORIZED
|
11
|
-
QUEUED
|
12
|
-
ZERO_AMOUNT
|
13
|
-
ACCEPTED
|
14
|
-
REJECTED
|
12
|
+
AUTHORIZED = 'Authorized' # Auth only, not captured
|
13
|
+
QUEUED = 'Queued for Capture' # Queued for the Processor
|
14
|
+
ZERO_AMOUNT = 'Zero Amount' # Capture (and Auth) were Voided
|
15
|
+
ACCEPTED = 'Accepted' # Accepted by the Processor
|
16
|
+
REJECTED = 'Rejected' # Rejected by the Processor
|
15
17
|
|
16
18
|
attr_accessor(*FIELDS)
|
17
19
|
|
@@ -20,11 +22,7 @@ module CardConnect
|
|
20
22
|
end
|
21
23
|
|
22
24
|
def body
|
23
|
-
|
24
|
-
FIELDS.each do |attr|
|
25
|
-
body.merge!(attr => send(attr))
|
26
|
-
end
|
27
|
-
body
|
25
|
+
FIELDS.collect{|attr| {attr => send(attr)} }.reduce({}, :merge)
|
28
26
|
end
|
29
27
|
end
|
30
28
|
end
|
@@ -3,17 +3,20 @@ module CardConnect
|
|
3
3
|
class InquireResponse
|
4
4
|
include Utils
|
5
5
|
|
6
|
-
FIELDS = [
|
7
|
-
|
8
|
-
|
6
|
+
FIELDS = [
|
7
|
+
:merchid, :account, :amount, :currency, :retref, :respcode,
|
8
|
+
:respproc, :respstat, :resptext, :setlstat, :capturedate, :batchid,
|
9
|
+
:token, :authdate, :lastfour, :name, :settledate
|
10
|
+
].freeze
|
11
|
+
|
9
12
|
# Settlement Status
|
10
|
-
AUTHORIZED
|
11
|
-
QUEUED
|
12
|
-
ACCEPTED
|
13
|
-
REJECTED
|
13
|
+
AUTHORIZED = 'Authorized' # Txn has not been Captured
|
14
|
+
QUEUED = 'Queued for Capture' # Txn is in flight to Clearing House
|
15
|
+
ACCEPTED = 'Accepted' # Txn was accepted for Settlement
|
16
|
+
REJECTED = 'Rejected' # Txn was not accepted
|
14
17
|
ZERO_AMOUNT = 'Zero Amount' # Txn was $0
|
15
|
-
VOIDED
|
16
|
-
DECLINED
|
18
|
+
VOIDED = 'Voided' # Txn has been voided
|
19
|
+
DECLINED = 'Declined' # Txn had an error
|
17
20
|
|
18
21
|
attr_accessor(*FIELDS)
|
19
22
|
attr_reader :errors
|
@@ -28,11 +31,7 @@ module CardConnect
|
|
28
31
|
end
|
29
32
|
|
30
33
|
def body
|
31
|
-
|
32
|
-
FIELDS.each do |attr|
|
33
|
-
body.merge!(attr => send(attr))
|
34
|
-
end
|
35
|
-
body
|
34
|
+
FIELDS.collect{|attr| {attr => send(attr)} }.reduce({}, :merge)
|
36
35
|
end
|
37
36
|
end
|
38
37
|
end
|
@@ -5,7 +5,7 @@ module CardConnect
|
|
5
5
|
#
|
6
6
|
# @param connection [CardConnect::Connection]
|
7
7
|
# @return CardConnect::Service::Profile
|
8
|
-
def initialize(rest_method
|
8
|
+
def initialize(rest_method, connection = CardConnect.connection)
|
9
9
|
super(connection)
|
10
10
|
@resource_name = '/profile'
|
11
11
|
@rest_method = rest_method
|
@@ -3,13 +3,15 @@ module CardConnect
|
|
3
3
|
class ProfileGetResponse
|
4
4
|
include Utils
|
5
5
|
|
6
|
-
FIELDS = [:profileid, :acctid, :respstat, :account,
|
7
|
-
|
6
|
+
FIELDS = [:gsacard, :profileid, :acctid, :respstat, :account,
|
7
|
+
:respcode, :resptext, :respproc, :accttype, :expiry,
|
8
|
+
:name, :address, :city, :region, :country, :phone, :postal,
|
9
|
+
:ssnl4, :email, :defaultacct, :license, :token, :auoptout]
|
8
10
|
|
9
11
|
attr_accessor(*FIELDS)
|
10
12
|
attr_reader :errors
|
11
13
|
|
12
|
-
STATUS_APPROVED
|
14
|
+
STATUS_APPROVED = 'A'
|
13
15
|
STATUS_NOT_FOUND = 'C'
|
14
16
|
|
15
17
|
def initialize(response)
|
@@ -23,11 +25,7 @@ module CardConnect
|
|
23
25
|
end
|
24
26
|
|
25
27
|
def body
|
26
|
-
|
27
|
-
FIELDS.each do |attr|
|
28
|
-
body.merge!({attr => send(attr)})
|
29
|
-
end
|
30
|
-
body
|
28
|
+
FIELDS.collect{|attr| {attr => send(attr)} }.reduce({}, :merge)
|
31
29
|
end
|
32
30
|
|
33
31
|
private
|
data/lib/cardconnect/utils.rb
CHANGED
@@ -4,18 +4,15 @@ module CardConnect
|
|
4
4
|
return if attributes.empty?
|
5
5
|
attributes = attributes[0] if attributes.is_a? Array
|
6
6
|
attributes = symbolize_keys(attributes)
|
7
|
+
|
7
8
|
fields.each do |attr|
|
8
|
-
next
|
9
|
+
next if attributes[attr].nil?
|
9
10
|
send("#{attr}=", attributes[attr])
|
10
11
|
end
|
11
12
|
end
|
12
13
|
|
13
14
|
def symbolize_keys(hash)
|
14
|
-
|
15
|
-
hash.each do |k, v|
|
16
|
-
symbolized_hash[k.to_sym] = v
|
17
|
-
end
|
18
|
-
symbolized_hash
|
15
|
+
hash.collect{|key, value| {key.to_sym => value} }.reduce({}, :merge)
|
19
16
|
end
|
20
17
|
end
|
21
18
|
end
|
data/lib/cardconnect/version.rb
CHANGED
data/test/api_request_stubs.rb
CHANGED
data/test/api_response_stubs.rb
CHANGED
@@ -24,22 +24,35 @@ def valid_capture_response
|
|
24
24
|
'setlstat' => 'Pending',
|
25
25
|
'retref' => '288002073633',
|
26
26
|
'merchid' => '000000927996',
|
27
|
-
'account' => '41XXXXXXXXXX4113'
|
27
|
+
'account' => '41XXXXXXXXXX4113',
|
28
|
+
'respproc' => 'FNOR',
|
29
|
+
'resptext' => 'Approval',
|
30
|
+
'respstat' => 'A',
|
31
|
+
'respcode' => '00',
|
32
|
+
'batchid' => '1900941569',
|
33
|
+
'token' => '9418594164541111',
|
34
|
+
'commcard' => ' C '
|
28
35
|
}
|
29
36
|
end
|
30
|
-
|
31
37
|
def valid_inquire_response # rubocop:disable Metrics/MethodLength
|
32
38
|
{
|
33
39
|
'amount' => '596.00',
|
34
40
|
'resptext' => 'Approval',
|
35
|
-
'setlstat' => '
|
41
|
+
'setlstat' => 'Accepted',
|
36
42
|
'respcode' => '00',
|
37
43
|
'retref' => '288015190411',
|
38
44
|
'merchid' => '000000927996',
|
39
|
-
'account' => '
|
45
|
+
'account' => '9418594164541111',
|
40
46
|
'respproc' => 'FNOR',
|
41
47
|
'respstat' => 'A',
|
42
|
-
'currency' => 'USD'
|
48
|
+
'currency' => 'USD',
|
49
|
+
'token' => '9418594164541111',
|
50
|
+
'authdate' => '20180410',
|
51
|
+
'lastfour' => '1111',
|
52
|
+
'name' => 'TOM JONES',
|
53
|
+
'capturedate' => '20180326065748',
|
54
|
+
'batchid' => '1900941569',
|
55
|
+
'settledate' => '20180327143721'
|
43
56
|
}
|
44
57
|
end
|
45
58
|
|
@@ -108,7 +121,9 @@ def valid_profile_get_response #rubocop:disable Metrics/MethodLength
|
|
108
121
|
"city" => "ANYTOWN",
|
109
122
|
"expiry" => "0214",
|
110
123
|
"profileid" => "12345678901234567890",
|
111
|
-
"acctid" => "1"
|
124
|
+
"acctid" => "1",
|
125
|
+
"gsacard" => "N",
|
126
|
+
"auoptout" => "N"
|
112
127
|
}
|
113
128
|
end
|
114
129
|
|
@@ -150,3 +165,20 @@ def valid_profile_put_response #rubocop:disable Metrics/MethodLength
|
|
150
165
|
"gsacard" => "N"
|
151
166
|
}
|
152
167
|
end
|
168
|
+
|
169
|
+
def valid_bin_response
|
170
|
+
{
|
171
|
+
"country" => "USA",
|
172
|
+
"product" => "V",
|
173
|
+
"cardusestring" => "True credit",
|
174
|
+
"gsa" => false,
|
175
|
+
"corporate" => true,
|
176
|
+
"fsa" => false,
|
177
|
+
"subtype" => "Visa Corporate T&E",
|
178
|
+
"purchase" => false,
|
179
|
+
"prepaid" => false,
|
180
|
+
"binlo" => "478823XXX",
|
181
|
+
"issuer" => "JPMorgan Chase Bank N.A. - Commercial",
|
182
|
+
"binhi" => "478825XXX"
|
183
|
+
}
|
184
|
+
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
|
+
proc { @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
|
@@ -14,8 +14,12 @@ describe CardConnect::Service::InquireResponse do
|
|
14
14
|
@response.merchid.must_equal '000000927996'
|
15
15
|
end
|
16
16
|
|
17
|
+
it 'should have name' do
|
18
|
+
@response.name.must_equal 'TOM JONES'
|
19
|
+
end
|
20
|
+
|
17
21
|
it 'should have account' do
|
18
|
-
@response.account.must_equal '
|
22
|
+
@response.account.must_equal '9418594164541111'
|
19
23
|
end
|
20
24
|
|
21
25
|
it 'should have amount' do
|
@@ -47,7 +51,27 @@ describe CardConnect::Service::InquireResponse do
|
|
47
51
|
end
|
48
52
|
|
49
53
|
it 'should have settlement status' do
|
50
|
-
@response.setlstat.must_equal '
|
54
|
+
@response.setlstat.must_equal 'Accepted'
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should have token' do
|
58
|
+
@response.token.must_equal '9418594164541111'
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should have authdate' do
|
62
|
+
@response.authdate.must_equal '20180410'
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should have captureddate' do
|
66
|
+
@response.capturedate.must_equal '20180326065748'
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should have lastfour value' do
|
70
|
+
@response.lastfour.must_equal '1111'
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should have settledate' do
|
74
|
+
@response.settledate.must_equal '20180327143721'
|
51
75
|
end
|
52
76
|
end
|
53
77
|
|
@@ -93,6 +93,14 @@ describe CardConnect::Service::ProfileGetResponse do
|
|
93
93
|
it 'should have token' do
|
94
94
|
@response.token.must_equal '9440670166031111'
|
95
95
|
end
|
96
|
+
|
97
|
+
it 'should have gsacard' do
|
98
|
+
@response.gsacard.must_equal 'N'
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'should have auoptout' do
|
102
|
+
@response.auoptout.must_equal 'N'
|
103
|
+
end
|
96
104
|
end
|
97
105
|
|
98
106
|
describe '#success?' do
|
data/test/test_helper.rb
CHANGED
@@ -18,6 +18,8 @@ end
|
|
18
18
|
# Stub out the Faraday connection for testing.
|
19
19
|
module CardConnect
|
20
20
|
class Connection
|
21
|
+
undef :connection if method_defined? :connection
|
22
|
+
|
21
23
|
def connection
|
22
24
|
@connection ||= Faraday.new(faraday_options) do |faraday|
|
23
25
|
faraday.request :basic_auth, @config.api_username, @config.api_password
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cardconnect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim McKenzie
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-
|
13
|
+
date: 2018-04-24 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -80,6 +80,9 @@ files:
|
|
80
80
|
- lib/cardconnect/services/authorization/authorization.rb
|
81
81
|
- lib/cardconnect/services/authorization/authorization_request.rb
|
82
82
|
- lib/cardconnect/services/authorization/authorization_response.rb
|
83
|
+
- lib/cardconnect/services/bin/bin.rb
|
84
|
+
- lib/cardconnect/services/bin/bin_request.rb
|
85
|
+
- lib/cardconnect/services/bin/bin_response.rb
|
83
86
|
- lib/cardconnect/services/capture/capture.rb
|
84
87
|
- lib/cardconnect/services/capture/capture_request.rb
|
85
88
|
- lib/cardconnect/services/capture/capture_response.rb
|
@@ -112,6 +115,9 @@ files:
|
|
112
115
|
- test/cardconnect/services/authorization/authorization_request_test.rb
|
113
116
|
- test/cardconnect/services/authorization/authorization_response_test.rb
|
114
117
|
- test/cardconnect/services/authorization/authorization_test.rb
|
118
|
+
- test/cardconnect/services/bin/bin_request_test.rb
|
119
|
+
- test/cardconnect/services/bin/bin_response_test.rb
|
120
|
+
- test/cardconnect/services/bin/bin_test.rb
|
115
121
|
- test/cardconnect/services/capture/capture_request_test.rb
|
116
122
|
- test/cardconnect/services/capture/capture_response_test.rb
|
117
123
|
- test/cardconnect/services/capture/capture_test.rb
|
@@ -156,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
162
|
version: '0'
|
157
163
|
requirements: []
|
158
164
|
rubyforge_project:
|
159
|
-
rubygems_version: 2.
|
165
|
+
rubygems_version: 2.7.3
|
160
166
|
signing_key:
|
161
167
|
specification_version: 4
|
162
168
|
summary: CardConnect API Ruby Client
|
@@ -168,6 +174,9 @@ test_files:
|
|
168
174
|
- test/cardconnect/services/authorization/authorization_request_test.rb
|
169
175
|
- test/cardconnect/services/authorization/authorization_response_test.rb
|
170
176
|
- test/cardconnect/services/authorization/authorization_test.rb
|
177
|
+
- test/cardconnect/services/bin/bin_request_test.rb
|
178
|
+
- test/cardconnect/services/bin/bin_response_test.rb
|
179
|
+
- test/cardconnect/services/bin/bin_test.rb
|
171
180
|
- test/cardconnect/services/capture/capture_request_test.rb
|
172
181
|
- test/cardconnect/services/capture/capture_response_test.rb
|
173
182
|
- test/cardconnect/services/capture/capture_test.rb
|