hps 2.3.2 → 2.4.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.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -4
  3. data/Gemfile.lock +59 -0
  4. data/LICENSE.md +264 -264
  5. data/PRIVACY.txt +65 -65
  6. data/README.md +213 -213
  7. data/Rakefile +15 -15
  8. data/examples/sinatra-verify-only/Gemfile +4 -4
  9. data/examples/sinatra-verify-only/app.rb +32 -32
  10. data/examples/sinatra-verify-only/views/index.erb +478 -478
  11. data/examples/sinatra-verify-only/views/result.erb +39 -39
  12. data/hps.gemspec +28 -27
  13. data/lib/hps/configuration.rb +17 -17
  14. data/lib/hps/entities/hps_account_verify.rb +8 -8
  15. data/lib/hps/entities/hps_address.rb +6 -6
  16. data/lib/hps/entities/hps_authorization.rb +12 -12
  17. data/lib/hps/entities/hps_batch.rb +6 -6
  18. data/lib/hps/entities/hps_cardholder.rb +6 -6
  19. data/lib/hps/entities/hps_charge.rb +8 -8
  20. data/lib/hps/entities/hps_charge_exceptions.rb +6 -6
  21. data/lib/hps/entities/hps_check.rb +18 -18
  22. data/lib/hps/entities/hps_check_holder.rb +10 -10
  23. data/lib/hps/entities/hps_check_response.rb +45 -45
  24. data/lib/hps/entities/hps_check_response_details.rb +9 -9
  25. data/lib/hps/entities/hps_credit_card.rb +34 -34
  26. data/lib/hps/entities/hps_direct_market_data.rb +5 -5
  27. data/lib/hps/entities/hps_encryption_data.rb +6 -6
  28. data/lib/hps/entities/hps_gift_card.rb +133 -133
  29. data/lib/hps/entities/hps_manage_tokens.rb +8 -8
  30. data/lib/hps/entities/hps_refund.rb +8 -8
  31. data/lib/hps/entities/hps_report_transaction_details.rb +10 -10
  32. data/lib/hps/entities/hps_report_transaction_summary.rb +6 -6
  33. data/lib/hps/entities/hps_reversal.rb +10 -10
  34. data/lib/hps/entities/hps_token_data.rb +10 -10
  35. data/lib/hps/entities/hps_track_data.rb +5 -5
  36. data/lib/hps/entities/hps_transaction.rb +161 -161
  37. data/lib/hps/entities/hps_transaction_details.rb +6 -6
  38. data/lib/hps/entities/hps_transaction_header.rb +8 -8
  39. data/lib/hps/entities/hps_transaction_type.rb +16 -16
  40. data/lib/hps/entities/hps_void.rb +8 -8
  41. data/lib/hps/infrastructure/api_connection_exception.rb +11 -11
  42. data/lib/hps/infrastructure/authentication_exception.rb +11 -11
  43. data/lib/hps/infrastructure/card_exception.rb +15 -15
  44. data/lib/hps/infrastructure/exceptions.json +547 -547
  45. data/lib/hps/infrastructure/hps_account_type.rb +11 -11
  46. data/lib/hps/infrastructure/hps_check_exception.rb +13 -13
  47. data/lib/hps/infrastructure/hps_check_type.rb +11 -11
  48. data/lib/hps/infrastructure/hps_data_entry_mode.rb +11 -11
  49. data/lib/hps/infrastructure/hps_exception.rb +25 -25
  50. data/lib/hps/infrastructure/hps_exception_mapper.rb +145 -145
  51. data/lib/hps/infrastructure/hps_gateway_response_validation.rb +20 -20
  52. data/lib/hps/infrastructure/hps_input_validation.rb +13 -13
  53. data/lib/hps/infrastructure/hps_sdk_codes.rb +48 -48
  54. data/lib/hps/infrastructure/hps_sec_code.rb +27 -27
  55. data/lib/hps/infrastructure/hps_track_data_method.rb +6 -6
  56. data/lib/hps/infrastructure/invalid_request_exception.rb +15 -15
  57. data/lib/hps/services/hps_batch_service.rb +29 -29
  58. data/lib/hps/services/hps_charge_service.rb +773 -773
  59. data/lib/hps/services/hps_check_service.rb +110 -110
  60. data/lib/hps/services/hps_gift_card_service.rb +301 -301
  61. data/lib/hps/services/hps_service.rb +141 -136
  62. data/lib/hps/version.rb +3 -3
  63. data/lib/hps.rb +63 -63
  64. data/tests/amex_tests.rb +292 -292
  65. data/tests/cert_tests.rb +80 -80
  66. data/tests/certification/card_present_spec.rb +320 -320
  67. data/tests/certification/gift_card_certification_test.rb +106 -106
  68. data/tests/certification/gift_card_certification_tests.rb +107 -107
  69. data/tests/check_tests.rb +50 -50
  70. data/tests/discover_tests.rb +386 -386
  71. data/tests/exception_mapper_tests.rb +311 -311
  72. data/tests/general_tests.rb +140 -140
  73. data/tests/giftcard_tests.rb +212 -212
  74. data/tests/hps_token_service.rb +56 -56
  75. data/tests/mastercard_tests.rb +387 -387
  76. data/tests/secret_key.rb +11 -11
  77. data/tests/test_check.rb +77 -77
  78. data/tests/test_data.rb +138 -138
  79. data/tests/test_helper.rb +179 -179
  80. data/tests/token_tests.rb +512 -512
  81. data/tests/visa_tests.rb +445 -445
  82. metadata +31 -11
@@ -1,11 +1,11 @@
1
- module Hps
2
- class HpsAccountType
3
- def self.checking
4
- 'CHECKING'
5
- end
6
-
7
- def self.savings
8
- 'SAVINGS'
9
- end
10
- end
11
- end
1
+ module Hps
2
+ class HpsAccountType
3
+ def self.checking
4
+ 'CHECKING'
5
+ end
6
+
7
+ def self.savings
8
+ 'SAVINGS'
9
+ end
10
+ end
11
+ end
@@ -1,13 +1,13 @@
1
- module Hps
2
- class HpsCheckException < HpsException
3
- attr_accessor :transaction_id,
4
- :details,
5
- :code
6
-
7
- def initialize(transaction_id, details, code, message = nil)
8
- @transaction_id = transaction_id
9
- @details = details
10
- super(message, code)
11
- end
12
- end
13
- end
1
+ module Hps
2
+ class HpsCheckException < HpsException
3
+ attr_accessor :transaction_id,
4
+ :details,
5
+ :code
6
+
7
+ def initialize(transaction_id, details, code, message = nil)
8
+ @transaction_id = transaction_id
9
+ @details = details
10
+ super(message, code)
11
+ end
12
+ end
13
+ end
@@ -1,11 +1,11 @@
1
- module Hps
2
- class HpsCheckType
3
- def self.personal
4
- 'PERSONAL'
5
- end
6
-
7
- def self.business
8
- 'BUSINESS'
9
- end
10
- end
11
- end
1
+ module Hps
2
+ class HpsCheckType
3
+ def self.personal
4
+ 'PERSONAL'
5
+ end
6
+
7
+ def self.business
8
+ 'BUSINESS'
9
+ end
10
+ end
11
+ end
@@ -1,11 +1,11 @@
1
- module Hps
2
- class HpsDataEntryMode
3
- def self.manual
4
- 'MANUAL'
5
- end
6
-
7
- def self.swipe
8
- 'SWIPE'
9
- end
10
- end
11
- end
1
+ module Hps
2
+ class HpsDataEntryMode
3
+ def self.manual
4
+ 'MANUAL'
5
+ end
6
+
7
+ def self.swipe
8
+ 'SWIPE'
9
+ end
10
+ end
11
+ end
@@ -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,146 +1,146 @@
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_gift_card_exception(transaction_id, response_code, response_text)
35
- mapping = exception_for_category_and_code("gift", response_code)
36
- unless mapping.nil?
37
- message = message_for_mapping(mapping, response_text)
38
- code = mapping["mapping_code"]
39
- return CardException.new(transaction_id, code, message)
40
- else
41
- return CardException.new(transaction_id, "unknown_card_exception", response_text)
42
- end
43
- end
44
-
45
- def map_gateway_exception(transaction_id, response_code, response_text)
46
-
47
- mapping = exception_for_category_and_code("gateway", response_code)
48
- message = message_for_mapping(mapping, response_text)
49
-
50
- unless mapping.nil?
51
-
52
- code = mapping["mapping_code"]
53
- exception_type = mapping["mapping_type"]
54
-
55
- if exception_type == "AuthenticationException"
56
-
57
- return AuthenticationException.new(message)
58
-
59
- elsif exception_type == "CardException"
60
-
61
- return CardException.new(transaction_id, code, message)
62
-
63
- elsif exception_type == "InvalidRequestException"
64
-
65
- return InvalidRequestException.new(message, mapping["param"], code)
66
-
67
- elsif !code.nil?
68
-
69
- return HpsException.new(response_text, code)
70
-
71
- end
72
-
73
- end
74
-
75
- HpsException.new(message, "unknown")
76
- end
77
-
78
- def map_sdk_exception(error_code, inner_exception = nil)
79
-
80
- mapping = exception_for_category_and_code("sdk", error_code)
81
- sdk_code_name = SdkCodes.instance_methods.detect { |m| SdkCodes.send(m) == error_code }
82
-
83
- if sdk_code_name.nil?
84
- response_text = "unknown"
85
- else
86
- response_text = sdk_code_name
87
- end
88
-
89
- unless mapping.nil?
90
-
91
- message = message_for_mapping(mapping, response_text)
92
- code = mapping["mapping_code"]
93
- exception_type = mapping["mapping_type"]
94
-
95
- if exception_type == "InvalidRequestException"
96
-
97
- return InvalidRequestException.new(message, mapping["param"], code)
98
-
99
- elsif exception_type == "ApiConnectionException"
100
-
101
- return ApiConnectionException.new(message, inner_exception, code)
102
-
103
- elsif !code.nil?
104
-
105
- return HpsException.new(message, code)
106
-
107
- end
108
-
109
- end
110
-
111
- HpsException.new("unknown", "unknown", inner_exception)
112
-
113
- end
114
-
115
- private
116
-
117
- def message_for_mapping(mapping, original_message)
118
-
119
- return original_message if mapping.nil?
120
-
121
- message = mapping["mapping_message"]
122
-
123
- unless message.nil?
124
-
125
- mapping_message = @exceptions["exception_messages"].detect { |m|
126
- m["code"] == message
127
- }
128
-
129
- return mapping_message["message"] unless mapping_message["message"].nil?
130
-
131
- end
132
-
133
- original_message
134
-
135
- end
136
-
137
- def exception_for_category_and_code(category, code)
138
-
139
- @exceptions["exception_mappings"].detect { |m|
140
- m["category"] == category and m["exception_codes"].include?(code.to_s)
141
- }
142
-
143
- end
144
-
145
- 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_gift_card_exception(transaction_id, response_code, response_text)
35
+ mapping = exception_for_category_and_code("gift", response_code)
36
+ unless mapping.nil?
37
+ message = message_for_mapping(mapping, response_text)
38
+ code = mapping["mapping_code"]
39
+ return CardException.new(transaction_id, code, message)
40
+ else
41
+ return CardException.new(transaction_id, "unknown_card_exception", response_text)
42
+ end
43
+ end
44
+
45
+ def map_gateway_exception(transaction_id, response_code, response_text)
46
+
47
+ mapping = exception_for_category_and_code("gateway", response_code)
48
+ message = message_for_mapping(mapping, response_text)
49
+
50
+ unless mapping.nil?
51
+
52
+ code = mapping["mapping_code"]
53
+ exception_type = mapping["mapping_type"]
54
+
55
+ if exception_type == "AuthenticationException"
56
+
57
+ return AuthenticationException.new(message)
58
+
59
+ elsif exception_type == "CardException"
60
+
61
+ return CardException.new(transaction_id, code, message)
62
+
63
+ elsif exception_type == "InvalidRequestException"
64
+
65
+ return InvalidRequestException.new(message, mapping["param"], code)
66
+
67
+ elsif !code.nil?
68
+
69
+ return HpsException.new(response_text, code)
70
+
71
+ end
72
+
73
+ end
74
+
75
+ HpsException.new(message, "unknown")
76
+ end
77
+
78
+ def map_sdk_exception(error_code, inner_exception = nil)
79
+
80
+ mapping = exception_for_category_and_code("sdk", error_code)
81
+ sdk_code_name = SdkCodes.instance_methods.detect { |m| SdkCodes.send(m) == error_code }
82
+
83
+ if sdk_code_name.nil?
84
+ response_text = "unknown"
85
+ else
86
+ response_text = sdk_code_name
87
+ end
88
+
89
+ unless mapping.nil?
90
+
91
+ message = message_for_mapping(mapping, response_text)
92
+ code = mapping["mapping_code"]
93
+ exception_type = mapping["mapping_type"]
94
+
95
+ if exception_type == "InvalidRequestException"
96
+
97
+ return InvalidRequestException.new(message, mapping["param"], code)
98
+
99
+ elsif exception_type == "ApiConnectionException"
100
+
101
+ return ApiConnectionException.new(message, inner_exception, code)
102
+
103
+ elsif !code.nil?
104
+
105
+ return HpsException.new(message, code)
106
+
107
+ end
108
+
109
+ end
110
+
111
+ HpsException.new("unknown", "unknown", inner_exception)
112
+
113
+ end
114
+
115
+ private
116
+
117
+ def message_for_mapping(mapping, original_message)
118
+
119
+ return original_message if mapping.nil?
120
+
121
+ message = mapping["mapping_message"]
122
+
123
+ unless message.nil?
124
+
125
+ mapping_message = @exceptions["exception_messages"].detect { |m|
126
+ m["code"] == message
127
+ }
128
+
129
+ return mapping_message["message"] unless mapping_message["message"].nil?
130
+
131
+ end
132
+
133
+ original_message
134
+
135
+ end
136
+
137
+ def exception_for_category_and_code(category, code)
138
+
139
+ @exceptions["exception_mappings"].detect { |m|
140
+ m["category"] == category and m["exception_codes"].include?(code.to_s)
141
+ }
142
+
143
+ end
144
+
145
+ end
146
146
  end
@@ -1,20 +1,20 @@
1
- module Hps
2
- class HpsGatewayResponseValidation
3
- def self.check_response(response, expected_type)
4
- response_code = response["Header"]["GatewayRspCode"]
5
- response_text = response["Header"]["GatewayRspMsg"]
6
- transaction_id = response["Header"]["GatewayTxnId"]
7
-
8
- if !response_code.eql? "0"
9
- exception = Hps::ExceptionMapper.new.map_gateway_exception(transaction_id, response_code, response_text)
10
- exception.response_code = response_code
11
- exception.response_text = response_text
12
- raise exception
13
- end
14
-
15
- unless response["Transaction"] && response["Transaction"][expected_type.to_s]
16
- raise HpsGatewayException
17
- end
18
- end
19
- end
20
- end
1
+ module Hps
2
+ class HpsGatewayResponseValidation
3
+ def self.check_response(response, expected_type)
4
+ response_code = response["Header"]["GatewayRspCode"]
5
+ response_text = response["Header"]["GatewayRspMsg"]
6
+ transaction_id = response["Header"]["GatewayTxnId"]
7
+
8
+ if !response_code.eql? "0"
9
+ exception = Hps::ExceptionMapper.new.map_gateway_exception(transaction_id, response_code, response_text)
10
+ exception.response_code = response_code
11
+ exception.response_text = response_text
12
+ raise exception
13
+ end
14
+
15
+ unless response["Transaction"] && response["Transaction"][expected_type.to_s]
16
+ raise HpsGatewayException
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,13 +1,13 @@
1
- module Hps
2
- class HpsInputValidation
3
- def self.check_amount(amount)
4
- if amount < 0 || amount == nil
5
- raise InvalidRequestException.new "Amount must be greater than or equal 0."
6
- end
7
-
8
- return amount if amount.is_a? Float
9
-
10
- amount.gsub(/[^0-9\.]/, '')
11
- end
12
- end
13
- end
1
+ module Hps
2
+ class HpsInputValidation
3
+ def self.check_amount(amount)
4
+ if amount < 0 || amount == nil
5
+ raise InvalidRequestException.new "Amount must be greater than or equal 0."
6
+ end
7
+
8
+ return amount if amount.is_a? Float
9
+
10
+ amount.gsub(/[^0-9\.]/, '')
11
+ end
12
+ end
13
+ 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
@@ -1,27 +1,27 @@
1
- module Hps
2
- class HpsSECCode
3
- def self.ppd
4
- 'PPD'
5
- end
6
-
7
- def self.ccd
8
- 'CCD'
9
- end
10
-
11
- def self.pop
12
- 'POP'
13
- end
14
-
15
- def self.web
16
- 'WEB'
17
- end
18
-
19
- def self.tel
20
- 'TEL'
21
- end
22
-
23
- def self.e_bronze
24
- 'eBronze'
25
- end
26
- end
27
- end
1
+ module Hps
2
+ class HpsSECCode
3
+ def self.ppd
4
+ 'PPD'
5
+ end
6
+
7
+ def self.ccd
8
+ 'CCD'
9
+ end
10
+
11
+ def self.pop
12
+ 'POP'
13
+ end
14
+
15
+ def self.web
16
+ 'WEB'
17
+ end
18
+
19
+ def self.tel
20
+ 'TEL'
21
+ end
22
+
23
+ def self.e_bronze
24
+ 'eBronze'
25
+ end
26
+ end
27
+ end
@@ -1,6 +1,6 @@
1
- module Hps
2
- class HpsTrackDataMethod
3
- SWIPE = "swipe"
4
- PROXIMITY = "proximity"
5
- end
6
- end
1
+ module Hps
2
+ class HpsTrackDataMethod
3
+ SWIPE = "swipe"
4
+ PROXIMITY = "proximity"
5
+ end
6
+ end