cardconnect 1.0.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 +7 -0
- data/.gitignore +18 -0
- data/Gemfile +11 -0
- data/LICENSE.txt +22 -0
- data/README.md +154 -0
- data/Rakefile +178 -0
- data/cardconnect.gemspec +25 -0
- data/lib/cardconnect.rb +49 -0
- data/lib/cardconnect/configuration.rb +13 -0
- data/lib/cardconnect/connection.rb +35 -0
- data/lib/cardconnect/error.rb +3 -0
- data/lib/cardconnect/services/authorization/authorization.rb +17 -0
- data/lib/cardconnect/services/authorization/authorization_request.rb +51 -0
- data/lib/cardconnect/services/authorization/authorization_response.rb +41 -0
- data/lib/cardconnect/services/capture/capture.rb +17 -0
- data/lib/cardconnect/services/capture/capture_request.rb +50 -0
- data/lib/cardconnect/services/capture/capture_response.rb +24 -0
- data/lib/cardconnect/services/deposit/deposit.rb +17 -0
- data/lib/cardconnect/services/deposit/deposit_request.rb +64 -0
- data/lib/cardconnect/services/deposit/deposit_response.rb +40 -0
- data/lib/cardconnect/services/inquire/inquire.rb +17 -0
- data/lib/cardconnect/services/inquire/inquire_request.rb +44 -0
- data/lib/cardconnect/services/inquire/inquire_response.rb +31 -0
- data/lib/cardconnect/services/refund/refund.rb +16 -0
- data/lib/cardconnect/services/refund/refund_request.rb +50 -0
- data/lib/cardconnect/services/refund/refund_response.rb +40 -0
- data/lib/cardconnect/services/service_endpoint.rb +69 -0
- data/lib/cardconnect/services/settlement_status/settlement_status.rb +17 -0
- data/lib/cardconnect/services/settlement_status/settlement_status_request.rb +64 -0
- data/lib/cardconnect/services/settlement_status/settlement_status_response.rb +39 -0
- data/lib/cardconnect/services/void/void.rb +16 -0
- data/lib/cardconnect/services/void/void_request.rb +50 -0
- data/lib/cardconnect/services/void/void_response.rb +40 -0
- data/lib/cardconnect/utils.rb +22 -0
- data/lib/cardconnect/version.rb +3 -0
- data/test/api_request_stubs.rb +83 -0
- data/test/api_response_stubs.rb +120 -0
- data/test/cardconnect/configuration_test.rb +28 -0
- data/test/cardconnect/connection_test.rb +36 -0
- data/test/cardconnect/services/authorization/authorization_request_test.rb +141 -0
- data/test/cardconnect/services/authorization/authorization_response_test.rb +93 -0
- data/test/cardconnect/services/authorization/authorization_test.rb +59 -0
- data/test/cardconnect/services/capture/capture_request_test.rb +65 -0
- data/test/cardconnect/services/capture/capture_response_test.rb +39 -0
- data/test/cardconnect/services/capture/capture_test.rb +58 -0
- data/test/cardconnect/services/deposit/deposit_request_test.rb +65 -0
- data/test/cardconnect/services/deposit/deposit_response_test.rb +75 -0
- data/test/cardconnect/services/deposit/deposit_test.rb +55 -0
- data/test/cardconnect/services/inquire/inquire_request_test.rb +45 -0
- data/test/cardconnect/services/inquire/inquire_response_test.rb +59 -0
- data/test/cardconnect/services/inquire/inquire_test.rb +56 -0
- data/test/cardconnect/services/refund/refund_request_test.rb +49 -0
- data/test/cardconnect/services/refund/refund_response_test.rb +73 -0
- data/test/cardconnect/services/refund/refund_test.rb +57 -0
- data/test/cardconnect/services/settlement_status/settlement_status_request_test.rb +65 -0
- data/test/cardconnect/services/settlement_status/settlement_status_response_test.rb +47 -0
- data/test/cardconnect/services/settlement_status/settlement_status_test.rb +55 -0
- data/test/cardconnect/services/void/void_request_test.rb +49 -0
- data/test/cardconnect/services/void/void_response_test.rb +77 -0
- data/test/cardconnect/services/void/void_test.rb +57 -0
- data/test/cardconnect_test.rb +14 -0
- data/test/test_helper.rb +33 -0
- metadata +179 -0
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe CardConnect::Service::VoidRequest do
|
4
|
+
before do
|
5
|
+
@request = CardConnect::Service::VoidRequest.new(valid_void_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 retrieval reference number' do
|
18
|
+
@request.retref.must_equal "288013185633"
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should have amount' do
|
22
|
+
@request.amount.must_equal "101"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#valid?' do
|
27
|
+
it 'should not be valid if no attributes are passed in' do
|
28
|
+
CardConnect::Service::VoidRequest.new.valid?.must_equal false
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should be valid if valid attributes are passed in' do
|
32
|
+
CardConnect::Service::VoidRequest.new(valid_void_request).valid?.must_equal true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#errors' do
|
37
|
+
CardConnect::Service::VoidRequest::REQUIRED_FIELDS.each do |field|
|
38
|
+
it "should have an error message if #{field} is missing" do
|
39
|
+
CardConnect::Service::VoidRequest.new.errors.must_include "#{field.to_s.capitalize} is missing"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#payload' do
|
45
|
+
it 'should generate hash with all the right values' do
|
46
|
+
@request.payload.must_equal symbolize_keys(valid_void_request)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,77 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe CardConnect::Service::VoidResponse do
|
4
|
+
before do
|
5
|
+
@response = CardConnect::Service::VoidResponse.new(valid_void_response)
|
6
|
+
end
|
7
|
+
|
8
|
+
after do
|
9
|
+
@response = nil
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'FIELDS' do
|
13
|
+
it 'should have the merchant id' do
|
14
|
+
@response.merchid.must_equal "000000927996"
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should have the Amount' do
|
18
|
+
@response.amount.must_equal "1.01"
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should have the currency' do
|
22
|
+
@response.currency.must_equal "USD"
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'should have the Retrieval Reference Number' do
|
26
|
+
@response.retref.must_equal "288013185633"
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should have the authcode' do
|
30
|
+
@response.authcode.must_equal "REVERS"
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should have the Response Code' do
|
34
|
+
@response.respcode.must_equal "00"
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should have the Response Processor' do
|
38
|
+
@response.respproc.must_equal "FNOR"
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'should have the status' do
|
42
|
+
@response.respstat.must_equal "A"
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should have the Response text' do
|
46
|
+
@response.resptext.must_equal "Approval"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '#success?' do
|
51
|
+
it 'should be true when there are no errors' do
|
52
|
+
@response.success?.must_equal true
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should be false when there are errors' do
|
56
|
+
response = CardConnect::Service::VoidResponse.new(valid_void_response.merge!("respstat" => "C", "resptext" => "this is an error"))
|
57
|
+
response.success?.must_equal false
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe '#errors' do
|
62
|
+
it 'should be empty when there are no errors' do
|
63
|
+
@response.errors.must_be_empty
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should be an array of error messages when there are errors' do
|
67
|
+
response = CardConnect::Service::VoidResponse.new(valid_void_response.merge!("respstat" => "C", "resptext" => "this is an error"))
|
68
|
+
response.errors.must_equal ["this is an error"]
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe "#body" do
|
73
|
+
it 'should generate hash with all the right values' do
|
74
|
+
@response.body.must_equal symbolize_keys(valid_void_response)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe CardConnect::Service::Void do
|
4
|
+
before do
|
5
|
+
@connection = CardConnect::Connection.new.connection do |stubs|
|
6
|
+
stubs.put(@service.path) { [200, {}, valid_void_response] }
|
7
|
+
end
|
8
|
+
@service = CardConnect::Service::Void.new(@connection)
|
9
|
+
end
|
10
|
+
|
11
|
+
after do
|
12
|
+
@service = nil
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'must have the right path' do
|
16
|
+
@service.path.must_equal '/cardconnect/rest/void'
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '#build_request' do
|
20
|
+
before do
|
21
|
+
@valid_params = valid_void_request
|
22
|
+
end
|
23
|
+
|
24
|
+
after do
|
25
|
+
@valid_params = nil
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'uses the default merchant id if it is not passed in' do
|
29
|
+
@service.build_request(@valid_params.reject!{|k,v| k == 'merchid' })
|
30
|
+
@service.request.merchid.must_equal 'merchant123'
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'creates an Authorization request object with the right params' do
|
34
|
+
@service.build_request(@valid_params)
|
35
|
+
|
36
|
+
@service.request.must_be_kind_of CardConnect::Service::VoidRequest
|
37
|
+
|
38
|
+
@service.request.merchid.must_equal '000000927996'
|
39
|
+
@service.request.retref.must_equal '288013185633'
|
40
|
+
@service.request.amount.must_equal '101'
|
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_void_request)
|
52
|
+
@service.submit
|
53
|
+
@service.response.must_be_kind_of CardConnect::Service::VoidResponse
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
describe CardConnect do
|
4
|
+
it 'must respond to configure' do
|
5
|
+
CardConnect.must_respond_to :configure
|
6
|
+
end
|
7
|
+
|
8
|
+
describe 'configuration' do
|
9
|
+
it 'must return instance of Configuration' do
|
10
|
+
CardConnect.configuration.must_be_kind_of CardConnect::Configuration
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'cardconnect'
|
2
|
+
|
3
|
+
require 'minitest/autorun'
|
4
|
+
require 'minitest/pride'
|
5
|
+
|
6
|
+
require 'api_request_stubs'
|
7
|
+
require 'api_response_stubs'
|
8
|
+
|
9
|
+
include CardConnect::Utils
|
10
|
+
|
11
|
+
CardConnect.configure do |config|
|
12
|
+
config.merchant_id = "merchant123"
|
13
|
+
config.api_username = "test"
|
14
|
+
config.api_password = "testpass"
|
15
|
+
config.endpoint = "https://test.host"
|
16
|
+
end
|
17
|
+
|
18
|
+
# Stub out the Faraday connection for testing.
|
19
|
+
class CardConnect::Connection
|
20
|
+
def connection
|
21
|
+
@connection ||= Faraday.new(url: @config.endpoint, headers: @headers) do |faraday|
|
22
|
+
faraday.request :basic_auth, @config.api_username, @config.api_password
|
23
|
+
faraday.request :json
|
24
|
+
|
25
|
+
faraday.response :json, :content_type => /\bjson$/
|
26
|
+
faraday.response :raise_error
|
27
|
+
|
28
|
+
faraday.adapter :test do |stubs|
|
29
|
+
yield(stubs)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,179 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cardconnect
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tim McKenzie
|
8
|
+
- Prashant Mokkarala
|
9
|
+
- Jason Taylor
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2015-02-27 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: bundler
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - "~>"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - "~>"
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '1.0'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: faraday
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - "~>"
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 0.9.0
|
36
|
+
type: :runtime
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 0.9.0
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: faraday_middleware
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 0.9.1
|
50
|
+
type: :runtime
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - "~>"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 0.9.1
|
57
|
+
description: CardConnect API Ruby Wrapper
|
58
|
+
email:
|
59
|
+
- tim@mobilecause.com
|
60
|
+
- prashant@mobilecause.com
|
61
|
+
- j.m.taylor1@gmail.com
|
62
|
+
executables: []
|
63
|
+
extensions: []
|
64
|
+
extra_rdoc_files: []
|
65
|
+
files:
|
66
|
+
- ".gitignore"
|
67
|
+
- Gemfile
|
68
|
+
- LICENSE.txt
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- cardconnect.gemspec
|
72
|
+
- lib/cardconnect.rb
|
73
|
+
- lib/cardconnect/configuration.rb
|
74
|
+
- lib/cardconnect/connection.rb
|
75
|
+
- lib/cardconnect/error.rb
|
76
|
+
- lib/cardconnect/services/authorization/authorization.rb
|
77
|
+
- lib/cardconnect/services/authorization/authorization_request.rb
|
78
|
+
- lib/cardconnect/services/authorization/authorization_response.rb
|
79
|
+
- lib/cardconnect/services/capture/capture.rb
|
80
|
+
- lib/cardconnect/services/capture/capture_request.rb
|
81
|
+
- lib/cardconnect/services/capture/capture_response.rb
|
82
|
+
- lib/cardconnect/services/deposit/deposit.rb
|
83
|
+
- lib/cardconnect/services/deposit/deposit_request.rb
|
84
|
+
- lib/cardconnect/services/deposit/deposit_response.rb
|
85
|
+
- lib/cardconnect/services/inquire/inquire.rb
|
86
|
+
- lib/cardconnect/services/inquire/inquire_request.rb
|
87
|
+
- lib/cardconnect/services/inquire/inquire_response.rb
|
88
|
+
- lib/cardconnect/services/refund/refund.rb
|
89
|
+
- lib/cardconnect/services/refund/refund_request.rb
|
90
|
+
- lib/cardconnect/services/refund/refund_response.rb
|
91
|
+
- lib/cardconnect/services/service_endpoint.rb
|
92
|
+
- lib/cardconnect/services/settlement_status/settlement_status.rb
|
93
|
+
- lib/cardconnect/services/settlement_status/settlement_status_request.rb
|
94
|
+
- lib/cardconnect/services/settlement_status/settlement_status_response.rb
|
95
|
+
- lib/cardconnect/services/void/void.rb
|
96
|
+
- lib/cardconnect/services/void/void_request.rb
|
97
|
+
- lib/cardconnect/services/void/void_response.rb
|
98
|
+
- lib/cardconnect/utils.rb
|
99
|
+
- lib/cardconnect/version.rb
|
100
|
+
- test/api_request_stubs.rb
|
101
|
+
- test/api_response_stubs.rb
|
102
|
+
- test/cardconnect/configuration_test.rb
|
103
|
+
- test/cardconnect/connection_test.rb
|
104
|
+
- test/cardconnect/services/authorization/authorization_request_test.rb
|
105
|
+
- test/cardconnect/services/authorization/authorization_response_test.rb
|
106
|
+
- test/cardconnect/services/authorization/authorization_test.rb
|
107
|
+
- test/cardconnect/services/capture/capture_request_test.rb
|
108
|
+
- test/cardconnect/services/capture/capture_response_test.rb
|
109
|
+
- test/cardconnect/services/capture/capture_test.rb
|
110
|
+
- test/cardconnect/services/deposit/deposit_request_test.rb
|
111
|
+
- test/cardconnect/services/deposit/deposit_response_test.rb
|
112
|
+
- test/cardconnect/services/deposit/deposit_test.rb
|
113
|
+
- test/cardconnect/services/inquire/inquire_request_test.rb
|
114
|
+
- test/cardconnect/services/inquire/inquire_response_test.rb
|
115
|
+
- test/cardconnect/services/inquire/inquire_test.rb
|
116
|
+
- test/cardconnect/services/refund/refund_request_test.rb
|
117
|
+
- test/cardconnect/services/refund/refund_response_test.rb
|
118
|
+
- test/cardconnect/services/refund/refund_test.rb
|
119
|
+
- test/cardconnect/services/settlement_status/settlement_status_request_test.rb
|
120
|
+
- test/cardconnect/services/settlement_status/settlement_status_response_test.rb
|
121
|
+
- test/cardconnect/services/settlement_status/settlement_status_test.rb
|
122
|
+
- test/cardconnect/services/void/void_request_test.rb
|
123
|
+
- test/cardconnect/services/void/void_response_test.rb
|
124
|
+
- test/cardconnect/services/void/void_test.rb
|
125
|
+
- test/cardconnect_test.rb
|
126
|
+
- test/test_helper.rb
|
127
|
+
homepage: http://developer.cardconnect.com/
|
128
|
+
licenses:
|
129
|
+
- MIT
|
130
|
+
metadata: {}
|
131
|
+
post_install_message:
|
132
|
+
rdoc_options: []
|
133
|
+
require_paths:
|
134
|
+
- lib
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
requirements: []
|
146
|
+
rubyforge_project:
|
147
|
+
rubygems_version: 2.4.5
|
148
|
+
signing_key:
|
149
|
+
specification_version: 4
|
150
|
+
summary: CardConnect API Ruby Wrapper
|
151
|
+
test_files:
|
152
|
+
- test/api_request_stubs.rb
|
153
|
+
- test/api_response_stubs.rb
|
154
|
+
- test/cardconnect/configuration_test.rb
|
155
|
+
- test/cardconnect/connection_test.rb
|
156
|
+
- test/cardconnect/services/authorization/authorization_request_test.rb
|
157
|
+
- test/cardconnect/services/authorization/authorization_response_test.rb
|
158
|
+
- test/cardconnect/services/authorization/authorization_test.rb
|
159
|
+
- test/cardconnect/services/capture/capture_request_test.rb
|
160
|
+
- test/cardconnect/services/capture/capture_response_test.rb
|
161
|
+
- test/cardconnect/services/capture/capture_test.rb
|
162
|
+
- test/cardconnect/services/deposit/deposit_request_test.rb
|
163
|
+
- test/cardconnect/services/deposit/deposit_response_test.rb
|
164
|
+
- test/cardconnect/services/deposit/deposit_test.rb
|
165
|
+
- test/cardconnect/services/inquire/inquire_request_test.rb
|
166
|
+
- test/cardconnect/services/inquire/inquire_response_test.rb
|
167
|
+
- test/cardconnect/services/inquire/inquire_test.rb
|
168
|
+
- test/cardconnect/services/refund/refund_request_test.rb
|
169
|
+
- test/cardconnect/services/refund/refund_response_test.rb
|
170
|
+
- test/cardconnect/services/refund/refund_test.rb
|
171
|
+
- test/cardconnect/services/settlement_status/settlement_status_request_test.rb
|
172
|
+
- test/cardconnect/services/settlement_status/settlement_status_response_test.rb
|
173
|
+
- test/cardconnect/services/settlement_status/settlement_status_test.rb
|
174
|
+
- test/cardconnect/services/void/void_request_test.rb
|
175
|
+
- test/cardconnect/services/void/void_response_test.rb
|
176
|
+
- test/cardconnect/services/void/void_test.rb
|
177
|
+
- test/cardconnect_test.rb
|
178
|
+
- test/test_helper.rb
|
179
|
+
has_rdoc:
|