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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 0d6ec54a93e96b0853646453b4279a2f4940f944
4
- data.tar.gz: 4fdb897d65793526a08198bffd4f7b0e1533dbb6
2
+ SHA256:
3
+ metadata.gz: 392819d44d5b57e895e919ff4d8f09be8b2a03301100f944fd79b3b5cb321a52
4
+ data.tar.gz: 5d972cde73c7482d8de49279a68fc00429058244f1a6b960e823a130c1b437db
5
5
  SHA512:
6
- metadata.gz: 7c9363231dcd9e016e566bf9bee06c6d58f08c9bf17c8e5b873a5ccb6e5192b42859bfb5517b75c565b220ba7f62a5442251eaf317fb042d5ac9d343bb103d4c
7
- data.tar.gz: ecc1e1b60110560499449a41b3f615d1506ec0ce2bde957a719ac95cf7d7ebedd243eb3d9da2431e51c237399fea5c7eb2ad6febef6145f76bfd7c82555804c4
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
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## v2.4.0
4
+
5
+ * Upgrades `faraday` and `faraday_middleware` dependency versions to use ones that works with ruby 3.0.
6
+
7
+ ## v2.3.0
8
+
9
+ * Added the following fields to response objects (@shivashankar-ror):
10
+ - CaptureResponse: `:respproc, :resptext, :commcard, :respstat, :respcode, :batchid, :token`
11
+ - InquireResponse: `:capturedate, :batchid, :token, :authdate, :lastfour, :name, :currency, :settledate`
12
+ - ProfileGetResponse: `:gsacard, :auoptout`
13
+
14
+ * Added support for Bin Service (@shivashankar-ror)
15
+
3
16
  ## v2.2.0
4
17
 
5
18
  * 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
@@ -4,7 +4,6 @@ CardConnect API Ruby Client
4
4
 
5
5
  [![Gem Version](https://badge.fury.io/rb/cardconnect.svg)](http://badge.fury.io/rb/cardconnect)
6
6
  [![Code Climate](https://codeclimate.com/github/mobilecause/cardconnect/badges/gpa.svg)](https://codeclimate.com/github/mobilecause/cardconnect)
7
- [![Build Status](https://travis-ci.org/mobilecause/cardconnect.svg?branch=master)](https://travis-ci.org/mobilecause/cardconnect)
8
7
 
9
8
  ## Installation
10
9
 
@@ -133,10 +132,39 @@ service.build_request(params)
133
132
  response = service.submit
134
133
  ```
135
134
 
135
+ ### Bin Service
136
+
137
+ CardConnect documentation for this service can be found here: https://developer.cardconnect.com/cardconnect-api#bin-service
138
+
139
+ Example:
140
+
141
+ ```ruby
142
+ service = CardConnect::Service::Bin.new
143
+ service.build_request(params)
144
+ response = service.submit
145
+ ```
146
+
136
147
  ### Response Codes
137
148
 
138
149
  http://developer.cardconnect.com/cardconnect-api/#response-codes
139
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
+
140
168
  ## To Do:
141
169
 
142
170
  #### Authorization Service
@@ -165,10 +193,6 @@ http://developer.cardconnect.com/cardconnect-api/#response-codes
165
193
 
166
194
  * Close Batch Service needs to be implemented
167
195
 
168
- #### Bin Service
169
-
170
- * Bin Service needs to be implemented
171
-
172
196
  ## Contributing
173
197
 
174
198
  1. Fork it ( https://github.com/mobilecause/cardconnect/fork )
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.add_development_dependency 'bundler', '~> 1.0'
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 :basic_auth, @config.api_username, @config.api_password
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)
@@ -24,11 +24,7 @@ module CardConnect
24
24
  end
25
25
 
26
26
  def body
27
- body = {}
28
- FIELDS.each do |attr|
29
- body.merge!(attr => send(attr))
30
- end
31
- body
27
+ FIELDS.collect{|attr| {attr => send(attr)} }.reduce({}, :merge)
32
28
  end
33
29
 
34
30
  private
@@ -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
- payload = {}
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].freeze
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 = 'Authorized' # Auth only, not captured
11
- QUEUED = 'Queued for Capture' # Queued for the Processor
12
- ZERO_AMOUNT = 'Zero Amount' # Capture (and Auth) were Voided
13
- ACCEPTED = 'Accepted' # Accepted by the Processor
14
- REJECTED = 'Rejected' # Rejected by the Processor
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
- body = {}
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 = [:merchid, :account, :amount, :currency, :retref, :respcode,
7
- :respproc, :respstat, :resptext, :setlstat].freeze
8
-
6
+ FIELDS = [
7
+ :merchid, :account, :amount, :currency, :retref, :respcode,
8
+ :respproc, :respstat, :resptext, :setlstat, :capturedate, :batchid,
9
+ :token, :authdate, :lastfour, :name, :settledate, :expiry
10
+ ].freeze
11
+
9
12
  # Settlement Status
10
- AUTHORIZED = 'Authorized' # Txn has not been Captured
11
- QUEUED = 'Queued for Capture' # Txn is in flight to Clearing House
12
- ACCEPTED = 'Accepted' # Txn was accepted for Settlement
13
- REJECTED = 'Rejected' # Txn was not accepted
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 = 'Voided' # Txn has been voided
16
- DECLINED = 'Declined' # Txn had an error
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
- body = {}
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 = nil, connection = CardConnect.connection)
8
+ def initialize(rest_method, connection = CardConnect.connection)
9
9
  super(connection)
10
10
  @resource_name = '/profile'
11
11
  @rest_method = rest_method
@@ -22,11 +22,7 @@ module CardConnect
22
22
  end
23
23
 
24
24
  def body
25
- body = {}
26
- FIELDS.each do |attr|
27
- body.merge!({attr => send(attr)})
28
- end
29
- body
25
+ FIELDS.collect{|attr| {attr => send(attr)} }.reduce({}, :merge)
30
26
  end
31
27
 
32
28
  private
@@ -3,13 +3,15 @@ module CardConnect
3
3
  class ProfileGetResponse
4
4
  include Utils
5
5
 
6
- FIELDS = [:profileid, :acctid, :respstat, :account, :respcode, :resptext, :respproc, :accttype, :expiry,
7
- :name, :address, :city, :region, :country, :phone, :postal, :ssnl4, :email, :defaultacct, :license, :token]
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 = 'A'
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
- body = {}
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
@@ -25,11 +25,7 @@ module CardConnect
25
25
  end
26
26
 
27
27
  def body
28
- body = {}
29
- FIELDS.each do |attr|
30
- body.merge!({attr => send(attr)})
31
- end
32
- body
28
+ FIELDS.collect{|attr| {attr => send(attr)} }.reduce({}, :merge)
33
29
  end
34
30
 
35
31
  private
@@ -23,11 +23,7 @@ module CardConnect
23
23
  end
24
24
 
25
25
  def body
26
- body = {}
27
- FIELDS.each do |attr|
28
- body.merge!(attr => send(attr))
29
- end
30
- body
26
+ FIELDS.collect{|attr| {attr => send(attr)} }.reduce({}, :merge)
31
27
  end
32
28
 
33
29
  private
@@ -20,11 +20,7 @@ module CardConnect
20
20
  end
21
21
 
22
22
  def body
23
- body = {}
24
- FIELDS.each do |attr|
25
- body.merge!(attr => send(attr))
26
- end
27
- body
23
+ FIELDS.collect{|attr| {attr => send(attr)} }.reduce({}, :merge)
28
24
  end
29
25
 
30
26
  private
@@ -24,11 +24,7 @@ module CardConnect
24
24
  end
25
25
 
26
26
  def body
27
- body = {}
28
- FIELDS.each do |attr|
29
- body.merge!(attr => send(attr))
30
- end
31
- body
27
+ FIELDS.collect{|attr| {attr => send(attr)} }.reduce({}, :merge)
32
28
  end
33
29
 
34
30
  private
@@ -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 unless attributes[attr]
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
- symbolized_hash = {}
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
@@ -1,3 +1,3 @@
1
1
  module CardConnect
2
- VERSION = '2.2.0'.freeze
2
+ VERSION = '2.4.0'.freeze
3
3
  end
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
@@ -113,3 +113,10 @@ def valid_profile_put_request
113
113
  "profileupdate" => "Y"
114
114
  }
115
115
  end
116
+
117
+ def valid_bin_request
118
+ {
119
+ 'token' => '9477709629051443',
120
+ 'merchid' => '000000927996'
121
+ }
122
+ end
@@ -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
  }
@@ -24,22 +25,36 @@ def valid_capture_response
24
25
  'setlstat' => 'Pending',
25
26
  'retref' => '288002073633',
26
27
  'merchid' => '000000927996',
27
- 'account' => '41XXXXXXXXXX4113'
28
+ 'account' => '41XXXXXXXXXX4113',
29
+ 'respproc' => 'FNOR',
30
+ 'resptext' => 'Approval',
31
+ 'respstat' => 'A',
32
+ 'respcode' => '00',
33
+ 'batchid' => '1900941569',
34
+ 'token' => '9418594164541111',
35
+ 'commcard' => ' C '
28
36
  }
29
37
  end
30
-
31
38
  def valid_inquire_response # rubocop:disable Metrics/MethodLength
32
39
  {
33
40
  'amount' => '596.00',
34
41
  'resptext' => 'Approval',
35
- 'setlstat' => 'NOTCAPTURED',
42
+ 'setlstat' => 'Accepted',
36
43
  'respcode' => '00',
37
44
  'retref' => '288015190411',
38
45
  'merchid' => '000000927996',
39
- 'account' => '41XXXXXXXXXX4113',
46
+ 'account' => '9418594164541111',
40
47
  'respproc' => 'FNOR',
41
48
  'respstat' => 'A',
42
- 'currency' => 'USD'
49
+ 'currency' => 'USD',
50
+ 'token' => '9418594164541111',
51
+ 'expiry' => '04/32',
52
+ 'authdate' => '20180410',
53
+ 'lastfour' => '1111',
54
+ 'name' => 'TOM JONES',
55
+ 'capturedate' => '20180326065748',
56
+ 'batchid' => '1900941569',
57
+ 'settledate' => '20180327143721'
43
58
  }
44
59
  end
45
60
 
@@ -108,7 +123,9 @@ def valid_profile_get_response #rubocop:disable Metrics/MethodLength
108
123
  "city" => "ANYTOWN",
109
124
  "expiry" => "0214",
110
125
  "profileid" => "12345678901234567890",
111
- "acctid" => "1"
126
+ "acctid" => "1",
127
+ "gsacard" => "N",
128
+ "auoptout" => "N"
112
129
  }
113
130
  end
114
131
 
@@ -150,3 +167,20 @@ def valid_profile_put_response #rubocop:disable Metrics/MethodLength
150
167
  "gsacard" => "N"
151
168
  }
152
169
  end
170
+
171
+ def valid_bin_response
172
+ {
173
+ "country" => "USA",
174
+ "product" => "V",
175
+ "cardusestring" => "True credit",
176
+ "gsa" => false,
177
+ "corporate" => true,
178
+ "fsa" => false,
179
+ "subtype" => "Visa Corporate T&E",
180
+ "purchase" => false,
181
+ "prepaid" => false,
182
+ "binlo" => "478823XXX",
183
+ "issuer" => "JPMorgan Chase Bank N.A. - Commercial",
184
+ "binhi" => "478825XXX"
185
+ }
186
+ end
@@ -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