hps 1.0.2 → 2.1.2

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.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -8
  3. data/LICENSE.txt +32 -32
  4. data/PRIVACY.txt +65 -65
  5. data/README.md +214 -41
  6. data/Rakefile +15 -15
  7. data/hps.gemspec +28 -26
  8. data/lib/hps.rb +48 -45
  9. data/lib/hps/configuration.rb +16 -16
  10. data/lib/hps/entities/hps_account_verify.rb +8 -8
  11. data/lib/hps/entities/hps_address.rb +6 -6
  12. data/lib/hps/entities/hps_authorization.rb +12 -12
  13. data/lib/hps/entities/hps_batch.rb +6 -6
  14. data/lib/hps/entities/hps_cardholder.rb +6 -10
  15. data/lib/hps/entities/hps_charge.rb +8 -8
  16. data/lib/hps/entities/hps_charge_exceptions.rb +6 -6
  17. data/lib/hps/entities/hps_credit_card.rb +34 -33
  18. data/lib/hps/entities/hps_direct_market_data.rb +5 -0
  19. data/lib/hps/entities/hps_encryption_data.rb +6 -0
  20. data/lib/hps/entities/hps_refund.rb +8 -8
  21. data/lib/hps/entities/hps_report_transaction_details.rb +10 -10
  22. data/lib/hps/entities/hps_report_transaction_summary.rb +6 -6
  23. data/lib/hps/entities/hps_reversal.rb +10 -10
  24. data/lib/hps/entities/hps_token_data.rb +10 -10
  25. data/lib/hps/entities/hps_track_data.rb +5 -0
  26. data/lib/hps/entities/hps_transaction.rb +161 -161
  27. data/lib/hps/entities/hps_transaction_details.rb +6 -6
  28. data/lib/hps/entities/hps_transaction_header.rb +8 -8
  29. data/lib/hps/entities/hps_transaction_type.rb +16 -16
  30. data/lib/hps/entities/hps_void.rb +8 -8
  31. data/lib/hps/infrastructure/api_connection_exception.rb +11 -11
  32. data/lib/hps/infrastructure/authentication_exception.rb +11 -11
  33. data/lib/hps/infrastructure/card_exception.rb +15 -15
  34. data/lib/hps/infrastructure/exceptions.json +468 -468
  35. data/lib/hps/infrastructure/hps_exception.rb +25 -25
  36. data/lib/hps/infrastructure/hps_exception_mapper.rb +134 -134
  37. data/lib/hps/infrastructure/hps_sdk_codes.rb +48 -48
  38. data/lib/hps/infrastructure/hps_track_data_method.rb +6 -0
  39. data/lib/hps/infrastructure/invalid_request_exception.rb +15 -15
  40. data/lib/hps/services/hps_batch_service.rb +29 -29
  41. data/lib/hps/services/hps_charge_service.rb +735 -635
  42. data/lib/hps/services/hps_service.rb +127 -128
  43. data/lib/hps/version.rb +3 -3
  44. data/tests/amex_tests.rb +292 -231
  45. data/tests/cert_tests.rb +80 -80
  46. data/tests/certification/card_present_spec.rb +320 -0
  47. data/tests/discover_tests.rb +386 -325
  48. data/tests/exception_mapper_tests.rb +244 -244
  49. data/tests/general_tests.rb +65 -57
  50. data/tests/hps_token_service.rb +56 -56
  51. data/tests/mastercard_tests.rb +387 -326
  52. data/tests/secret_key.rb +11 -11
  53. data/tests/test_data.rb +128 -128
  54. data/tests/test_helper.rb +115 -108
  55. data/tests/token_tests.rb +512 -512
  56. data/tests/visa_tests.rb +445 -378
  57. metadata +36 -3
@@ -1,25 +1,25 @@
1
- module Hps
2
- class HpsException < StandardError
3
-
4
- attr_accessor :code, :inner_exception, :response_code, :response_text
5
-
6
-
7
- def initialize(message, code, inner_exception = nil)
8
-
9
- @code=code
10
- @inner_exception = inner_exception
11
- super(message)
12
-
13
- end
14
-
15
- def code
16
- if @code.nil?
17
- "unknown"
18
- else
19
- @code
20
- end
21
- end
22
-
23
-
24
- end
25
- end
1
+ module Hps
2
+ class HpsException < StandardError
3
+
4
+ attr_accessor :code, :inner_exception, :response_code, :response_text
5
+
6
+
7
+ def initialize(message, code, inner_exception = nil)
8
+
9
+ @code=code
10
+ @inner_exception = inner_exception
11
+ super(message)
12
+
13
+ end
14
+
15
+ def code
16
+ if @code.nil?
17
+ "unknown"
18
+ else
19
+ @code
20
+ end
21
+ end
22
+
23
+
24
+ end
25
+ end
@@ -1,135 +1,135 @@
1
- require 'json'
2
-
3
- module Hps
4
- class ExceptionMapper
5
-
6
- attr_reader :exceptions
7
-
8
- def initialize
9
- path = File.join( File.dirname(__FILE__), "exceptions.json")
10
-
11
- File.open(path, "r") do |f|
12
- @exceptions = JSON.load(f)
13
- end
14
- end
15
-
16
- def version_number
17
- @exceptions["version"]
18
- end
19
-
20
- def map_issuer_exception(transaction_id, response_code, response_text)
21
-
22
- mapping = exception_for_category_and_code("issuer", response_code)
23
-
24
- unless mapping.nil?
25
- message = message_for_mapping(mapping, response_text)
26
- code = mapping["mapping_code"]
27
- return CardException.new(transaction_id, code, message)
28
- else
29
- return CardException.new(transaction_id, "unknown_card_exception", response_text)
30
- end
31
-
32
- end
33
-
34
- def map_gateway_exception(transaction_id, response_code, response_text)
35
-
36
- mapping = exception_for_category_and_code("gateway", response_code)
37
- message = message_for_mapping(mapping, response_text)
38
-
39
- unless mapping.nil?
40
-
41
- code = mapping["mapping_code"]
42
- exception_type = mapping["mapping_type"]
43
-
44
- if exception_type == "AuthenticationException"
45
-
46
- return AuthenticationException.new(message)
47
-
48
- elsif exception_type == "CardException"
49
-
50
- return CardException.new(transaction_id, code, message)
51
-
52
- elsif exception_type == "InvalidRequestException"
53
-
54
- return InvalidRequestException.new(message, mapping["param"], code)
55
-
56
- elsif !code.nil?
57
-
58
- return HpsException.new(response_text, code)
59
-
60
- end
61
-
62
- end
63
-
64
- HpsException.new(message, "unknown")
65
- end
66
-
67
- def map_sdk_exception(error_code, inner_exception = nil)
68
-
69
- mapping = exception_for_category_and_code("sdk", error_code)
70
- sdk_code_name = SdkCodes.instance_methods.detect { |m| SdkCodes.send(m) == error_code }
71
-
72
- if sdk_code_name.nil?
73
- response_text = "unknown"
74
- else
75
- response_text = sdk_code_name
76
- end
77
-
78
- unless mapping.nil?
79
-
80
- message = message_for_mapping(mapping, response_text)
81
- code = mapping["mapping_code"]
82
- exception_type = mapping["mapping_type"]
83
-
84
- if exception_type == "InvalidRequestException"
85
-
86
- return InvalidRequestException.new(message, mapping["param"], code)
87
-
88
- elsif exception_type == "ApiConnectionException"
89
-
90
- return ApiConnectionException.new(message, inner_exception, code)
91
-
92
- elsif !code.nil?
93
-
94
- return HpsException.new(message, code)
95
-
96
- end
97
-
98
- end
99
-
100
- HpsException.new("unknown", "unknown", inner_exception)
101
-
102
- end
103
-
104
- private
105
-
106
- def message_for_mapping(mapping, original_message)
107
-
108
- return original_message if mapping.nil?
109
-
110
- message = mapping["mapping_message"]
111
-
112
- unless message.nil?
113
-
114
- mapping_message = @exceptions["exception_messages"].detect { |m|
115
- m["code"] == message
116
- }
117
-
118
- return mapping_message["message"] unless mapping_message["message"].nil?
119
-
120
- end
121
-
122
- original_message
123
-
124
- end
125
-
126
- def exception_for_category_and_code(category, code)
127
-
128
- @exceptions["exception_mappings"].detect { |m|
129
- m["category"] == category and m["exception_codes"].include?(code.to_s)
130
- }
131
-
132
- end
133
-
134
- end
1
+ require 'json'
2
+
3
+ module Hps
4
+ class ExceptionMapper
5
+
6
+ attr_reader :exceptions
7
+
8
+ def initialize
9
+ path = File.join( File.dirname(__FILE__), "exceptions.json")
10
+
11
+ File.open(path, "r") do |f|
12
+ @exceptions = JSON.load(f)
13
+ end
14
+ end
15
+
16
+ def version_number
17
+ @exceptions["version"]
18
+ end
19
+
20
+ def map_issuer_exception(transaction_id, response_code, response_text)
21
+
22
+ mapping = exception_for_category_and_code("issuer", response_code)
23
+
24
+ unless mapping.nil?
25
+ message = message_for_mapping(mapping, response_text)
26
+ code = mapping["mapping_code"]
27
+ return CardException.new(transaction_id, code, message)
28
+ else
29
+ return CardException.new(transaction_id, "unknown_card_exception", response_text)
30
+ end
31
+
32
+ end
33
+
34
+ def map_gateway_exception(transaction_id, response_code, response_text)
35
+
36
+ mapping = exception_for_category_and_code("gateway", response_code)
37
+ message = message_for_mapping(mapping, response_text)
38
+
39
+ unless mapping.nil?
40
+
41
+ code = mapping["mapping_code"]
42
+ exception_type = mapping["mapping_type"]
43
+
44
+ if exception_type == "AuthenticationException"
45
+
46
+ return AuthenticationException.new(message)
47
+
48
+ elsif exception_type == "CardException"
49
+
50
+ return CardException.new(transaction_id, code, message)
51
+
52
+ elsif exception_type == "InvalidRequestException"
53
+
54
+ return InvalidRequestException.new(message, mapping["param"], code)
55
+
56
+ elsif !code.nil?
57
+
58
+ return HpsException.new(response_text, code)
59
+
60
+ end
61
+
62
+ end
63
+
64
+ HpsException.new(message, "unknown")
65
+ end
66
+
67
+ def map_sdk_exception(error_code, inner_exception = nil)
68
+
69
+ mapping = exception_for_category_and_code("sdk", error_code)
70
+ sdk_code_name = SdkCodes.instance_methods.detect { |m| SdkCodes.send(m) == error_code }
71
+
72
+ if sdk_code_name.nil?
73
+ response_text = "unknown"
74
+ else
75
+ response_text = sdk_code_name
76
+ end
77
+
78
+ unless mapping.nil?
79
+
80
+ message = message_for_mapping(mapping, response_text)
81
+ code = mapping["mapping_code"]
82
+ exception_type = mapping["mapping_type"]
83
+
84
+ if exception_type == "InvalidRequestException"
85
+
86
+ return InvalidRequestException.new(message, mapping["param"], code)
87
+
88
+ elsif exception_type == "ApiConnectionException"
89
+
90
+ return ApiConnectionException.new(message, inner_exception, code)
91
+
92
+ elsif !code.nil?
93
+
94
+ return HpsException.new(message, code)
95
+
96
+ end
97
+
98
+ end
99
+
100
+ HpsException.new("unknown", "unknown", inner_exception)
101
+
102
+ end
103
+
104
+ private
105
+
106
+ def message_for_mapping(mapping, original_message)
107
+
108
+ return original_message if mapping.nil?
109
+
110
+ message = mapping["mapping_message"]
111
+
112
+ unless message.nil?
113
+
114
+ mapping_message = @exceptions["exception_messages"].detect { |m|
115
+ m["code"] == message
116
+ }
117
+
118
+ return mapping_message["message"] unless mapping_message["message"].nil?
119
+
120
+ end
121
+
122
+ original_message
123
+
124
+ end
125
+
126
+ def exception_for_category_and_code(category, code)
127
+
128
+ @exceptions["exception_mappings"].detect { |m|
129
+ m["category"] == category and m["exception_codes"].include?(code.to_s)
130
+ }
131
+
132
+ end
133
+
134
+ end
135
135
  end
@@ -1,49 +1,49 @@
1
- module Hps
2
- module SdkCodes
3
-
4
- def self.invalid_transaction_id
5
- "0"
6
- end
7
-
8
- def self.invalid_gateway_url
9
- "1"
10
- end
11
-
12
- def self.unable_to_process_transaction
13
- "2"
14
- end
15
-
16
- def self.invalid_start_date
17
- "3"
18
- end
19
-
20
- def self.invalid_end_date
21
- "4"
22
- end
23
-
24
- def self.missing_currency
25
- "5"
26
- end
27
-
28
- def self.invalid_currency
29
- "6"
30
- end
31
-
32
- def self.invalid_amount
33
- "7"
34
- end
35
-
36
- def self.reversal_error_after_gateway_timeout
37
- "8"
38
- end
39
-
40
- def self.reversal_error_after_issuer_timeout
41
- "9"
42
- end
43
-
44
- def self.processing_error
45
- "10"
46
- end
47
-
48
- end
1
+ module Hps
2
+ module SdkCodes
3
+
4
+ def self.invalid_transaction_id
5
+ "0"
6
+ end
7
+
8
+ def self.invalid_gateway_url
9
+ "1"
10
+ end
11
+
12
+ def self.unable_to_process_transaction
13
+ "2"
14
+ end
15
+
16
+ def self.invalid_start_date
17
+ "3"
18
+ end
19
+
20
+ def self.invalid_end_date
21
+ "4"
22
+ end
23
+
24
+ def self.missing_currency
25
+ "5"
26
+ end
27
+
28
+ def self.invalid_currency
29
+ "6"
30
+ end
31
+
32
+ def self.invalid_amount
33
+ "7"
34
+ end
35
+
36
+ def self.reversal_error_after_gateway_timeout
37
+ "8"
38
+ end
39
+
40
+ def self.reversal_error_after_issuer_timeout
41
+ "9"
42
+ end
43
+
44
+ def self.processing_error
45
+ "10"
46
+ end
47
+
48
+ end
49
49
  end
@@ -0,0 +1,6 @@
1
+ module Hps
2
+ class HpsTrackDataMethod
3
+ SWIPE = "swipe"
4
+ PROXIMITY = "proximity"
5
+ end
6
+ end
@@ -1,15 +1,15 @@
1
- module Hps
2
- class InvalidRequestException < HpsException
3
-
4
- attr_accessor :param
5
-
6
- def initialize(message, param = nil, code = nil)
7
-
8
- @param = param
9
-
10
- super(message, code)
11
-
12
- end
13
-
14
- end
15
- end
1
+ module Hps
2
+ class InvalidRequestException < HpsException
3
+
4
+ attr_accessor :param
5
+
6
+ def initialize(message, param = nil, code = nil)
7
+
8
+ @param = param
9
+
10
+ super(message, code)
11
+
12
+ end
13
+
14
+ end
15
+ end