cardconnect 1.1.1 → 2.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 +4 -4
- data/.travis.yml +1 -0
- data/README.md +18 -5
- data/Rakefile +34 -10
- data/lib/cardconnect.rb +7 -3
- data/lib/cardconnect/services/authorization/authorization_response.rb +1 -1
- data/lib/cardconnect/services/profile/profile.rb +25 -0
- data/lib/cardconnect/services/profile/profile_delete_request.rb +49 -0
- data/lib/cardconnect/services/profile/profile_delete_response.rb +39 -0
- data/lib/cardconnect/services/profile/profile_get_request.rb +49 -0
- data/lib/cardconnect/services/profile/profile_get_response.rb +40 -0
- data/lib/cardconnect/services/{deposit/deposit_request.rb → profile/profile_put_request.rb} +11 -21
- data/lib/cardconnect/services/profile/profile_put_response.rb +42 -0
- data/lib/cardconnect/services/service_endpoint.rb +7 -0
- data/lib/cardconnect/utils.rb +1 -0
- data/lib/cardconnect/version.rb +1 -1
- data/test/api_request_stubs.rb +32 -4
- data/test/api_response_stubs.rb +62 -30
- data/test/cardconnect/services/inquire/inquire_test.rb +1 -1
- data/test/cardconnect/services/profile/profile_delete_request_test.rb +50 -0
- data/test/cardconnect/services/profile/profile_delete_response_test.rb +67 -0
- data/test/cardconnect/services/profile/profile_get_request_test.rb +50 -0
- data/test/cardconnect/services/profile/profile_get_response_test.rb +127 -0
- data/test/cardconnect/services/profile/profile_put_request_test.rb +114 -0
- data/test/cardconnect/services/profile/profile_test.rb +168 -0
- metadata +22 -12
- data/lib/cardconnect/services/deposit/deposit.rb +0 -15
- data/lib/cardconnect/services/deposit/deposit_response.rb +0 -39
- data/test/cardconnect/services/deposit/deposit_request_test.rb +0 -65
- data/test/cardconnect/services/deposit/deposit_response_test.rb +0 -77
- data/test/cardconnect/services/deposit/deposit_test.rb +0 -55
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 613d7d7ba42912817e0e7e9e365a1b0d82b9dc74
|
4
|
+
data.tar.gz: fb5943d475fd8f9bbab4966681a6eef137b94a94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46c3f8b3366e57533bdc0daa2856f16fcfabc37674e1d5669e36e2ae2eb055dca126337272264ae3186b148e39e47bc22e0b8620f8d2d2bff56ba982dcdc8077
|
7
|
+
data.tar.gz: 5d321b4406a837bc9b0e6022608c7db3f883397d61ebba858b615b02604c2a7980495365d2683cd0bd2e5d709a0ec826bf801226992002c2860f893028121f78
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -111,14 +111,15 @@ service.build_request(params)
|
|
111
111
|
response = service.submit
|
112
112
|
```
|
113
113
|
|
114
|
-
###
|
114
|
+
### Profile Service
|
115
|
+
Thanks to [@AndreiBujenitsa](https://github.com/AndreiBujenitsa) for implementing Profile Service!
|
115
116
|
|
116
|
-
CardConnect documentation for this service can be found here:
|
117
|
+
CardConnect documentation for this service can be found here: https://developer.cardconnect.com/cardconnect-api/#profile-service
|
117
118
|
|
118
119
|
Example:
|
119
120
|
|
120
121
|
```ruby
|
121
|
-
service = CardConnect::Service::
|
122
|
+
service = CardConnect::Service::Profile.new
|
122
123
|
service.build_request(params)
|
123
124
|
response = service.submit
|
124
125
|
```
|
@@ -143,9 +144,21 @@ http://developer.cardconnect.com/cardconnect-api/#response-codes
|
|
143
144
|
|
144
145
|
* Funding Service needs to be implemented
|
145
146
|
|
146
|
-
####
|
147
|
+
#### Signature Capture Service
|
147
148
|
|
148
|
-
*
|
149
|
+
* Signature Capture Service needs to be implemented
|
150
|
+
|
151
|
+
#### Open Batch Service
|
152
|
+
|
153
|
+
* Open Batch Service needs to be implemented
|
154
|
+
|
155
|
+
#### Close Batch Service
|
156
|
+
|
157
|
+
* Close Batch Service needs to be implemented
|
158
|
+
|
159
|
+
#### Bin Service
|
160
|
+
|
161
|
+
* Bin Service needs to be implemented
|
149
162
|
|
150
163
|
## Contributing
|
151
164
|
|
data/Rakefile
CHANGED
@@ -183,24 +183,48 @@ namespace :cardconnect do
|
|
183
183
|
end
|
184
184
|
end
|
185
185
|
|
186
|
-
desc 'Simulate a
|
187
|
-
task :
|
188
|
-
# Date format is MMDD
|
186
|
+
desc 'Simulate a Profile request. Available rest methods: [put, get, delete]'
|
187
|
+
task :profile, [:rest_method, :profileid, :account_id, :merchant_id, :api_username, :api_password, :api_endpoint] do |_, args|
|
189
188
|
cardconnect_configure(args)
|
190
189
|
|
191
|
-
|
190
|
+
profile_params = {
|
192
191
|
'merchid' => CardConnect.configuration.merchant_id,
|
193
|
-
'
|
192
|
+
'profileid' => args[:profileid],
|
193
|
+
'acctid' => args[:account_id]
|
194
|
+
}
|
195
|
+
|
196
|
+
profile_put_params = {
|
197
|
+
"region" => "AK",
|
198
|
+
"phone" => "7778789999",
|
199
|
+
"accttype" => "VISA",
|
200
|
+
"postal" => "19090",
|
201
|
+
"ssnl4" => "3655",
|
202
|
+
"expiry" => "0214",
|
203
|
+
"city" => "ANYTOWN",
|
204
|
+
"country" => "US",
|
205
|
+
"address" => "123 MAIN STREET",
|
206
|
+
"merchid" => args[:merchant_id],
|
207
|
+
'profileid' => args[:profileid],
|
208
|
+
"name" => "TOM JONES",
|
209
|
+
"account" => "4444333322221111",
|
210
|
+
"license" => "123451254",
|
211
|
+
"defaultacct" => "N",
|
212
|
+
"profileupdate" => "Y"
|
194
213
|
}
|
195
214
|
|
196
|
-
|
197
|
-
|
215
|
+
profile = CardConnect::Service::Profile.new(args.rest_method)
|
216
|
+
|
217
|
+
if args.rest_method == 'put'
|
218
|
+
profile.build_request(profile_put_params)
|
219
|
+
else
|
220
|
+
profile.build_request(profile_params)
|
221
|
+
end
|
198
222
|
|
199
|
-
if
|
200
|
-
response =
|
223
|
+
if profile.request.valid?
|
224
|
+
response = profile.submit
|
201
225
|
puts response.body
|
202
226
|
else
|
203
|
-
puts
|
227
|
+
puts profile.request.errors
|
204
228
|
end
|
205
229
|
end
|
206
230
|
end
|
data/lib/cardconnect.rb
CHANGED
@@ -15,10 +15,14 @@ require 'cardconnect/services/inquire/inquire_request'
|
|
15
15
|
require 'cardconnect/services/inquire/inquire_response'
|
16
16
|
require 'cardconnect/services/refund/refund_request'
|
17
17
|
require 'cardconnect/services/refund/refund_response'
|
18
|
-
require 'cardconnect/services/deposit/deposit_request'
|
19
|
-
require 'cardconnect/services/deposit/deposit_response'
|
20
18
|
require 'cardconnect/services/void/void_request'
|
21
19
|
require 'cardconnect/services/void/void_response'
|
20
|
+
require 'cardconnect/services/profile/profile_put_request'
|
21
|
+
require 'cardconnect/services/profile/profile_put_response'
|
22
|
+
require 'cardconnect/services/profile/profile_get_request'
|
23
|
+
require 'cardconnect/services/profile/profile_get_response'
|
24
|
+
require 'cardconnect/services/profile/profile_delete_request'
|
25
|
+
require 'cardconnect/services/profile/profile_delete_response'
|
22
26
|
|
23
27
|
require 'cardconnect/services/service_endpoint'
|
24
28
|
require 'cardconnect/services/authorization/authorization'
|
@@ -26,8 +30,8 @@ require 'cardconnect/services/capture/capture'
|
|
26
30
|
require 'cardconnect/services/settlement_status/settlement_status'
|
27
31
|
require 'cardconnect/services/inquire/inquire'
|
28
32
|
require 'cardconnect/services/refund/refund'
|
29
|
-
require 'cardconnect/services/deposit/deposit'
|
30
33
|
require 'cardconnect/services/void/void'
|
34
|
+
require 'cardconnect/services/profile/profile'
|
31
35
|
|
32
36
|
module CardConnect
|
33
37
|
class << self
|
@@ -4,7 +4,7 @@ module CardConnect
|
|
4
4
|
include Utils
|
5
5
|
|
6
6
|
FIELDS = [:respstat, :retref, :account, :token, :amount, :merchid, :respcode,
|
7
|
-
:resptext, :respproc, :avsresp, :cvvresp, :authcode, :commcard, :profileid].freeze
|
7
|
+
:resptext, :respproc, :avsresp, :cvvresp, :authcode, :commcard, :profileid, :acctid].freeze
|
8
8
|
|
9
9
|
attr_accessor(*FIELDS)
|
10
10
|
attr_reader :errors
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module CardConnect
|
2
|
+
module Service
|
3
|
+
class Profile < ServiceEndpoint
|
4
|
+
# Initializes an Profile(create/update) Service
|
5
|
+
#
|
6
|
+
# @param connection [CardConnect::Connection]
|
7
|
+
# @return CardConnect::Service::Profile
|
8
|
+
def initialize(rest_method = nil, connection = CardConnect.connection)
|
9
|
+
super(connection)
|
10
|
+
@resource_name = '/profile'
|
11
|
+
@rest_method = rest_method
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def request_class
|
17
|
+
string_to_class("#{self.class}#{self.rest_method.capitalize}Request")
|
18
|
+
end
|
19
|
+
|
20
|
+
def response_class
|
21
|
+
string_to_class("#{self.class}#{self.rest_method.capitalize}Response")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module CardConnect
|
2
|
+
module Service
|
3
|
+
class ProfileDeleteRequest
|
4
|
+
include Utils
|
5
|
+
|
6
|
+
# Making acctid required here even though this conflicts with
|
7
|
+
# information in the CardConnect docs because I can't get a successful
|
8
|
+
# response from their API unless I pass an acctid. Please let me know
|
9
|
+
# if you know how to fix this.
|
10
|
+
REQUIRED_FIELDS = [:profileid, :acctid, :merchid]
|
11
|
+
|
12
|
+
OPTIONAL_FIELDS = []
|
13
|
+
|
14
|
+
FIELDS = REQUIRED_FIELDS + OPTIONAL_FIELDS
|
15
|
+
|
16
|
+
attr_accessor(*FIELDS)
|
17
|
+
attr_reader :errors
|
18
|
+
|
19
|
+
# Initializes a new ProfileDeleteRequest
|
20
|
+
#
|
21
|
+
# @param attrs [Hash]
|
22
|
+
# @return CardConnect::ProfileDeleteRequest
|
23
|
+
def initialize(attrs = {})
|
24
|
+
@errors = []
|
25
|
+
set_attributes(attrs, FIELDS)
|
26
|
+
validate_required_fields
|
27
|
+
end
|
28
|
+
|
29
|
+
# Indicates that the request is valid once it is built.
|
30
|
+
def valid?
|
31
|
+
errors.empty?
|
32
|
+
end
|
33
|
+
|
34
|
+
# Builds the request payload
|
35
|
+
def payload
|
36
|
+
"/#{profileid}/#{acctid}/#{merchid}"
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def validate_required_fields
|
42
|
+
REQUIRED_FIELDS.each do |field|
|
43
|
+
value = send(field)
|
44
|
+
value.nil? || value.empty? ? errors.push("#{field.capitalize} is missing") : next
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module CardConnect
|
2
|
+
module Service
|
3
|
+
class ProfileDeleteResponse
|
4
|
+
include Utils
|
5
|
+
|
6
|
+
FIELDS = [:resptext, :respcode, :respproc, :respstat, :profileid, :acctid]
|
7
|
+
|
8
|
+
attr_accessor(*FIELDS)
|
9
|
+
attr_reader :errors
|
10
|
+
|
11
|
+
STATUS_APPROVED = 'A'
|
12
|
+
STATUS_NOT_FOUND = 'C'
|
13
|
+
|
14
|
+
def initialize(response)
|
15
|
+
set_attributes(response, FIELDS)
|
16
|
+
@errors = []
|
17
|
+
process_errors
|
18
|
+
end
|
19
|
+
|
20
|
+
def success?
|
21
|
+
errors.empty?
|
22
|
+
end
|
23
|
+
|
24
|
+
def body
|
25
|
+
body = {}
|
26
|
+
FIELDS.each do |attr|
|
27
|
+
body.merge!({attr => send(attr)})
|
28
|
+
end
|
29
|
+
body
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def process_errors
|
35
|
+
@errors << resptext if STATUS_NOT_FOUND == respstat
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module CardConnect
|
2
|
+
module Service
|
3
|
+
class ProfileGetRequest
|
4
|
+
include Utils
|
5
|
+
|
6
|
+
# Making acctid required here even though this conflicts with
|
7
|
+
# information in the CardConnect docs because I can't get a successful
|
8
|
+
# response from their API unless I pass an acctid. Please let me know
|
9
|
+
# if you know how to fix this.
|
10
|
+
REQUIRED_FIELDS = [:profileid, :acctid, :merchid]
|
11
|
+
|
12
|
+
OPTIONAL_FIELDS = []
|
13
|
+
|
14
|
+
FIELDS = REQUIRED_FIELDS + OPTIONAL_FIELDS
|
15
|
+
|
16
|
+
attr_accessor(*FIELDS)
|
17
|
+
attr_reader :errors
|
18
|
+
|
19
|
+
# Initializes a new ProfileGetRequest
|
20
|
+
#
|
21
|
+
# @param attrs [Hash]
|
22
|
+
# @return CardConnect::ProfileGetRequest
|
23
|
+
def initialize(attrs = {})
|
24
|
+
@errors = []
|
25
|
+
set_attributes(attrs, FIELDS)
|
26
|
+
validate_required_fields
|
27
|
+
end
|
28
|
+
|
29
|
+
# Indicates that the request is valid once it is built.
|
30
|
+
def valid?
|
31
|
+
errors.empty?
|
32
|
+
end
|
33
|
+
|
34
|
+
# Builds the request payload
|
35
|
+
def payload
|
36
|
+
"/#{profileid}/#{acctid}/#{merchid}"
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def validate_required_fields
|
42
|
+
REQUIRED_FIELDS.each do |field|
|
43
|
+
value = send(field)
|
44
|
+
value.nil? || value.empty? ? errors.push("#{field.capitalize} is missing") : next
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module CardConnect
|
2
|
+
module Service
|
3
|
+
class ProfileGetResponse
|
4
|
+
include Utils
|
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]
|
8
|
+
|
9
|
+
attr_accessor(*FIELDS)
|
10
|
+
attr_reader :errors
|
11
|
+
|
12
|
+
STATUS_APPROVED = 'A'
|
13
|
+
STATUS_NOT_FOUND = 'C'
|
14
|
+
|
15
|
+
def initialize(response)
|
16
|
+
set_attributes(response, FIELDS)
|
17
|
+
@errors = []
|
18
|
+
process_errors
|
19
|
+
end
|
20
|
+
|
21
|
+
def success?
|
22
|
+
errors.empty?
|
23
|
+
end
|
24
|
+
|
25
|
+
def body
|
26
|
+
body = {}
|
27
|
+
FIELDS.each do |attr|
|
28
|
+
body.merge!({attr => send(attr)})
|
29
|
+
end
|
30
|
+
body
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def process_errors
|
36
|
+
@errors << resptext if STATUS_NOT_FOUND == respstat
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -1,21 +1,23 @@
|
|
1
|
-
require 'date'
|
2
|
-
|
3
1
|
module CardConnect
|
4
2
|
module Service
|
5
|
-
class
|
3
|
+
class ProfilePutRequest
|
6
4
|
include Utils
|
7
5
|
|
8
|
-
REQUIRED_FIELDS = [:merchid, :
|
6
|
+
REQUIRED_FIELDS = [:merchid, :account]
|
7
|
+
|
8
|
+
OPTIONAL_FIELDS = [:profile, :defaultacct, :profileupdate, :accttype, :profileid,
|
9
|
+
:bankaba, :expiry, :name, :address, :city, :region, :country,
|
10
|
+
:phone, :postal, :ssnl4, :email, :license]
|
9
11
|
|
10
|
-
FIELDS = REQUIRED_FIELDS
|
12
|
+
FIELDS = REQUIRED_FIELDS + OPTIONAL_FIELDS
|
11
13
|
|
12
14
|
attr_accessor(*FIELDS)
|
13
15
|
attr_reader :errors
|
14
16
|
|
15
|
-
# Initializes a new
|
17
|
+
# Initializes a new Profile Request
|
16
18
|
#
|
17
19
|
# @param attrs [Hash]
|
18
|
-
# @return CardConnect::
|
20
|
+
# @return CardConnect::ProfileRequest
|
19
21
|
def initialize(attrs = {})
|
20
22
|
@errors = []
|
21
23
|
set_attributes(attrs, FIELDS)
|
@@ -29,9 +31,9 @@ module CardConnect
|
|
29
31
|
|
30
32
|
# Builds the request payload
|
31
33
|
def payload
|
32
|
-
payload =
|
34
|
+
payload = {}
|
33
35
|
FIELDS.each do |field|
|
34
|
-
payload
|
36
|
+
payload.merge!({field => send(field)})
|
35
37
|
end
|
36
38
|
payload
|
37
39
|
end
|
@@ -39,23 +41,11 @@ module CardConnect
|
|
39
41
|
private
|
40
42
|
|
41
43
|
def validate_required_fields
|
42
|
-
validate_presence_of_required_fields
|
43
|
-
validate_date_format unless date.nil? || date.empty?
|
44
|
-
end
|
45
|
-
|
46
|
-
def validate_presence_of_required_fields
|
47
44
|
REQUIRED_FIELDS.each do |field|
|
48
45
|
value = send(field)
|
49
46
|
value.nil? || value.empty? ? errors.push("#{field.capitalize} is missing") : next
|
50
47
|
end
|
51
48
|
end
|
52
|
-
|
53
|
-
def validate_date_format
|
54
|
-
raise if date.length != 4
|
55
|
-
Date.parse(date, '%m%d')
|
56
|
-
rescue
|
57
|
-
errors.push('Date format is invalid. Please use MMDD format')
|
58
|
-
end
|
59
49
|
end
|
60
50
|
end
|
61
51
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module CardConnect
|
2
|
+
module Service
|
3
|
+
class ProfilePutResponse
|
4
|
+
include Utils
|
5
|
+
|
6
|
+
FIELDS = [:profileid, :acctid, :respstat, :account, :respcode, :resptext, :respproc, :accttype,
|
7
|
+
:expiry, :name, :address, :city, :region, :country, :phone, :postal, :ssnl4, :email,
|
8
|
+
:defaultacct, :license, :gsacard, :auoptout]
|
9
|
+
|
10
|
+
attr_accessor(*FIELDS)
|
11
|
+
attr_reader :errors
|
12
|
+
|
13
|
+
STATUS_APPROVED = 'A'
|
14
|
+
STATUS_RETRY = 'B'
|
15
|
+
STATUS_DECLINED = 'C'
|
16
|
+
|
17
|
+
def initialize(response)
|
18
|
+
set_attributes(response, FIELDS)
|
19
|
+
@errors = []
|
20
|
+
process_errors
|
21
|
+
end
|
22
|
+
|
23
|
+
def success?
|
24
|
+
errors.empty?
|
25
|
+
end
|
26
|
+
|
27
|
+
def body
|
28
|
+
body = {}
|
29
|
+
FIELDS.each do |attr|
|
30
|
+
body.merge!({attr => send(attr)})
|
31
|
+
end
|
32
|
+
body
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def process_errors
|
38
|
+
@errors << resptext if [STATUS_RETRY, STATUS_DECLINED].include?(respstat)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|