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,136 +1,141 @@
1
- require 'active_support/core_ext/hash/conversions'
2
-
3
- module Hps
4
- class HpsService
5
-
6
- attr_accessor :exception_mapper
7
-
8
- attr_accessor *Configuration::VALID_CONFIG_KEYS
9
-
10
- def initialize(options={})
11
-
12
- merged_options = Hps.options.merge(options)
13
-
14
- Configuration::VALID_CONFIG_KEYS.each do |key|
15
- send("#{key}=", merged_options[key])
16
- end
17
-
18
- @exception_mapper = Hps::ExceptionMapper.new
19
- end
20
-
21
- #protected
22
-
23
- def doTransaction(transaction, client_txn_id = nil)
24
-
25
- if configuration_invalid
26
- raise @exception_mapper.map_sdk_exception(SdkCodes.invalid_transaction_id)
27
- end
28
-
29
- xml = Builder::XmlMarkup.new
30
- xml.instruct!(:xml, :encoding => "UTF-8")
31
- xml.SOAP :Envelope, {
32
- 'xmlns:SOAP' => 'http://schemas.xmlsoap.org/soap/envelope/',
33
- 'xmlns:hps' => 'http://Hps.Exchange.PosGateway' } do
34
- xml.SOAP :Body do
35
- xml.hps :PosRequest do
36
- xml.hps 'Ver1.0'.to_sym do
37
- xml.hps :Header do
38
- if self.secret_api_key
39
- self.service_uri = gateway_url_for_key self.secret_api_key
40
- xml.hps :SecretAPIKey, self.secret_api_key.strip
41
- else
42
- xml.hps :UserName, self.user_name
43
- xml.hps :Password, self.password
44
- xml.hps :DeviceId, self.device_id
45
- xml.hps :LicenseId, self.license_id
46
- xml.hps :SiteId, self.site_id
47
- end
48
- xml.hps :DeveloperID, self.developer_id if self.developer_id
49
- xml.hps :VersionNbr, self.version_number if self.version_number
50
- xml.hps :SiteTrace, self.site_trace if self.site_trace
51
- xml.hps :ClientTxnId, client_txn_id if client_txn_id
52
- end
53
-
54
- xml << transaction
55
-
56
- end
57
- end
58
- end
59
- end
60
-
61
- begin
62
-
63
- uri = URI.parse(self.service_uri)
64
- http = Net::HTTP.new uri.host, uri.port
65
- http.use_ssl = true
66
-
67
- # allow SSL verification as opt-in
68
- if self.http_options && self.http_options.verify_mode
69
- http.verify_mode = self.http_options.verify_mode
70
- http.ca_file = self.http_options.ca_file if self.http_options.ca_file
71
- else
72
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
73
- end
74
-
75
- data = xml.target!
76
-
77
- response = http.post(uri.path, data, 'Content-type' => 'text/xml')
78
- # NOTE: If the HTTP request was successful
79
- if response.is_a? Net::HTTPOK
80
-
81
- # NOTE: Convert XML to a Hash
82
- soap_hash = Hash.from_xml(response.body)
83
- # NOTE: Peel away the layers and return only the PosRespose
84
- soap_hash["Envelope"]["Body"]["PosResponse"]["Ver1.0"]
85
-
86
- else
87
- raise @exception_mapper.map_sdk_exception(SdkCodes.unable_to_process_transaction)
88
- end
89
-
90
- rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
91
- Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
92
- raise @exception_mapper.map_sdk_exception(SdkCodes.unable_to_process_transaction, e)
93
- end
94
-
95
- end
96
-
97
- def gateway_url_for_key(api_key)
98
-
99
- gateway_url = "https://api2.heartlandportico.com/Hps.Exchange.PosGateway/PosGatewayService.asmx?wsdl"
100
-
101
- if api_key.include? "_uat_"
102
-
103
- gateway_url = "https://posgateway.uat.secureexchange.net/Hps.Exchange.PosGateway/PosGatewayService.asmx?wsdl"
104
-
105
- elsif api_key.include? "_cert_"
106
-
107
- gateway_url = "https://cert.api2.heartlandportico.com/Hps.Exchange.PosGateway/PosGatewayService.asmx?wsdl"
108
- end
109
-
110
- gateway_url
111
- end
112
-
113
- def hydrate_transaction_header(header)
114
- result = HpsTransactionHeader.new
115
- result.gateway_response_code = header["GatewayRspCode"]
116
- result.gateway_response_message = header["GatewayRspMsg"]
117
- result.response_dt = header["RspDT"]
118
- result.client_txn_id = header["GatewayTxnId"]
119
- result
120
- end
121
-
122
- private
123
-
124
- def configuration_invalid
125
- self.secret_api_key.nil? and (
126
- self.service_uri.nil? or
127
- self.user_name.nil? or
128
- self.password.nil? or
129
- self.license_id.nil? or
130
- self.device_id.nil? or
131
- self.site_id.nil?
132
- )
133
- end
134
-
135
- end
136
- end
1
+ if ActiveSupport::VERSION::MAJOR > 6
2
+ require "active_support/isolated_execution_state"
3
+ end
4
+
5
+ require 'active_support/core_ext/hash/conversions'
6
+
7
+ module Hps
8
+ class HpsService
9
+
10
+ attr_accessor :exception_mapper
11
+
12
+ attr_accessor *Configuration::VALID_CONFIG_KEYS
13
+
14
+ def initialize(options={})
15
+
16
+ merged_options = Hps.options.merge(options)
17
+
18
+ Configuration::VALID_CONFIG_KEYS.each do |key|
19
+ send("#{key}=", merged_options[key])
20
+ end
21
+
22
+ @exception_mapper = Hps::ExceptionMapper.new
23
+ end
24
+
25
+ #protected
26
+
27
+ def doTransaction(transaction, client_txn_id = nil)
28
+
29
+ if configuration_invalid
30
+ raise @exception_mapper.map_sdk_exception(SdkCodes.invalid_transaction_id)
31
+ end
32
+
33
+ xml = Builder::XmlMarkup.new
34
+ xml.instruct!(:xml, :encoding => "UTF-8")
35
+ xml.SOAP :Envelope, {
36
+ 'xmlns:SOAP' => 'http://schemas.xmlsoap.org/soap/envelope/',
37
+ 'xmlns:hps' => 'http://Hps.Exchange.PosGateway' } do
38
+ xml.SOAP :Body do
39
+ xml.hps :PosRequest do
40
+ xml.hps 'Ver1.0'.to_sym do
41
+ xml.hps :Header do
42
+ if self.secret_api_key
43
+ self.service_uri = gateway_url_for_key self.secret_api_key
44
+ xml.hps :SecretAPIKey, self.secret_api_key.strip
45
+ else
46
+ xml.hps :UserName, self.user_name
47
+ xml.hps :Password, self.password
48
+ xml.hps :DeviceId, self.device_id
49
+ xml.hps :LicenseId, self.license_id
50
+ xml.hps :SiteId, self.site_id
51
+ end
52
+ xml.hps :DeveloperID, self.developer_id if self.developer_id
53
+ xml.hps :VersionNbr, self.version_number if self.version_number
54
+ xml.hps :SiteTrace, self.site_trace if self.site_trace
55
+ xml.hps :ClientTxnId, client_txn_id if client_txn_id
56
+ xml.hps :SDKNameVersion, 'ruby;version=2.3.3'
57
+ end
58
+
59
+ xml << transaction
60
+
61
+ end
62
+ end
63
+ end
64
+ end
65
+
66
+ begin
67
+
68
+ uri = URI.parse(self.service_uri)
69
+ http = Net::HTTP.new uri.host, uri.port
70
+ http.use_ssl = true
71
+
72
+ # allow SSL verification as opt-in
73
+ if self.http_options && self.http_options.verify_mode
74
+ http.verify_mode = self.http_options.verify_mode
75
+ http.ca_file = self.http_options.ca_file if self.http_options.ca_file
76
+ else
77
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
78
+ end
79
+
80
+ data = xml.target!
81
+
82
+ response = http.post(uri.path, data, 'Content-type' => 'text/xml')
83
+ # NOTE: If the HTTP request was successful
84
+ if response.is_a? Net::HTTPOK
85
+
86
+ # NOTE: Convert XML to a Hash
87
+ soap_hash = Hash.from_xml(response.body)
88
+ # NOTE: Peel away the layers and return only the PosRespose
89
+ soap_hash["Envelope"]["Body"]["PosResponse"]["Ver1.0"]
90
+
91
+ else
92
+ raise @exception_mapper.map_sdk_exception(SdkCodes.unable_to_process_transaction)
93
+ end
94
+
95
+ rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
96
+ Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
97
+ raise @exception_mapper.map_sdk_exception(SdkCodes.unable_to_process_transaction, e)
98
+ end
99
+
100
+ end
101
+
102
+ def gateway_url_for_key(api_key)
103
+
104
+ gateway_url = "https://api2.heartlandportico.com/Hps.Exchange.PosGateway/PosGatewayService.asmx?wsdl"
105
+
106
+ if api_key.include? "_uat_"
107
+
108
+ gateway_url = "https://posgateway.uat.secureexchange.net/Hps.Exchange.PosGateway/PosGatewayService.asmx?wsdl"
109
+
110
+ elsif api_key.include? "_cert_"
111
+
112
+ gateway_url = "https://cert.api2.heartlandportico.com/Hps.Exchange.PosGateway/PosGatewayService.asmx?wsdl"
113
+ end
114
+
115
+ gateway_url
116
+ end
117
+
118
+ def hydrate_transaction_header(header)
119
+ result = HpsTransactionHeader.new
120
+ result.gateway_response_code = header["GatewayRspCode"]
121
+ result.gateway_response_message = header["GatewayRspMsg"]
122
+ result.response_dt = header["RspDT"]
123
+ result.client_txn_id = header["GatewayTxnId"]
124
+ result
125
+ end
126
+
127
+ private
128
+
129
+ def configuration_invalid
130
+ self.secret_api_key.nil? and (
131
+ self.service_uri.nil? or
132
+ self.user_name.nil? or
133
+ self.password.nil? or
134
+ self.license_id.nil? or
135
+ self.device_id.nil? or
136
+ self.site_id.nil?
137
+ )
138
+ end
139
+
140
+ end
141
+ end
data/lib/hps/version.rb CHANGED
@@ -1,3 +1,3 @@
1
- module Hps
2
- VERSION = "2.3.2"
3
- end
1
+ module Hps
2
+ VERSION = "2.4.0"
3
+ end
data/lib/hps.rb CHANGED
@@ -1,63 +1,63 @@
1
- require 'builder'
2
- require 'net/http'
3
- require 'net/https'
4
- require "hps/version"
5
- require "hps/configuration"
6
-
7
- # Entities
8
- require "hps/entities/hps_transaction"
9
- require "hps/entities/hps_authorization"
10
- require "hps/entities/hps_account_verify"
11
- require "hps/entities/hps_address"
12
- require "hps/entities/hps_batch"
13
- require "hps/entities/hps_cardholder"
14
- require "hps/entities/hps_charge"
15
- require "hps/entities/hps_charge_exceptions"
16
- require "hps/entities/hps_credit_card"
17
- require "hps/entities/hps_encryption_data"
18
- require "hps/entities/hps_refund"
19
- require "hps/entities/hps_report_transaction_details"
20
- require "hps/entities/hps_report_transaction_summary"
21
- require "hps/entities/hps_reversal"
22
- require "hps/entities/hps_token_data"
23
- require "hps/entities/hps_track_data"
24
- require "hps/entities/hps_transaction_header"
25
- require "hps/entities/hps_transaction_type"
26
- require "hps/entities/hps_transaction_details"
27
- require "hps/entities/hps_void"
28
- require "hps/entities/hps_check"
29
- require "hps/entities/hps_check_holder"
30
- require "hps/entities/hps_check_response"
31
- require "hps/entities/hps_check_response_details"
32
- require "hps/entities/hps_manage_tokens"
33
- require "hps/entities/hps_gift_card"
34
-
35
- # Infrastructure
36
- require "hps/infrastructure/hps_sdk_codes"
37
- require "hps/infrastructure/hps_exception"
38
- require "hps/infrastructure/api_connection_exception"
39
- require "hps/infrastructure/authentication_exception"
40
- require "hps/infrastructure/card_exception"
41
- require "hps/infrastructure/invalid_request_exception"
42
- require "hps/infrastructure/hps_exception_mapper"
43
- require "hps/infrastructure/hps_track_data_method"
44
- require "hps/infrastructure/hps_account_type"
45
- require "hps/infrastructure/hps_check_type"
46
- require "hps/infrastructure/hps_data_entry_mode"
47
- require "hps/infrastructure/hps_sec_code"
48
- require "hps/infrastructure/hps_input_validation"
49
- require "hps/infrastructure/hps_gateway_response_validation"
50
- require "hps/infrastructure/hps_check_exception"
51
-
52
- # Services
53
- require "hps/services/hps_service"
54
- require "hps/services/hps_charge_service"
55
- require "hps/services/hps_check_service"
56
- require "hps/services/hps_batch_service"
57
- require "hps/services/hps_gift_card_service"
58
-
59
- module Hps
60
-
61
- extend Configuration
62
-
63
- end
1
+ require 'builder'
2
+ require 'net/http'
3
+ require 'net/https'
4
+ require "hps/version"
5
+ require "hps/configuration"
6
+
7
+ # Entities
8
+ require "hps/entities/hps_transaction"
9
+ require "hps/entities/hps_authorization"
10
+ require "hps/entities/hps_account_verify"
11
+ require "hps/entities/hps_address"
12
+ require "hps/entities/hps_batch"
13
+ require "hps/entities/hps_cardholder"
14
+ require "hps/entities/hps_charge"
15
+ require "hps/entities/hps_charge_exceptions"
16
+ require "hps/entities/hps_credit_card"
17
+ require "hps/entities/hps_encryption_data"
18
+ require "hps/entities/hps_refund"
19
+ require "hps/entities/hps_report_transaction_details"
20
+ require "hps/entities/hps_report_transaction_summary"
21
+ require "hps/entities/hps_reversal"
22
+ require "hps/entities/hps_token_data"
23
+ require "hps/entities/hps_track_data"
24
+ require "hps/entities/hps_transaction_header"
25
+ require "hps/entities/hps_transaction_type"
26
+ require "hps/entities/hps_transaction_details"
27
+ require "hps/entities/hps_void"
28
+ require "hps/entities/hps_check"
29
+ require "hps/entities/hps_check_holder"
30
+ require "hps/entities/hps_check_response"
31
+ require "hps/entities/hps_check_response_details"
32
+ require "hps/entities/hps_manage_tokens"
33
+ require "hps/entities/hps_gift_card"
34
+
35
+ # Infrastructure
36
+ require "hps/infrastructure/hps_sdk_codes"
37
+ require "hps/infrastructure/hps_exception"
38
+ require "hps/infrastructure/api_connection_exception"
39
+ require "hps/infrastructure/authentication_exception"
40
+ require "hps/infrastructure/card_exception"
41
+ require "hps/infrastructure/invalid_request_exception"
42
+ require "hps/infrastructure/hps_exception_mapper"
43
+ require "hps/infrastructure/hps_track_data_method"
44
+ require "hps/infrastructure/hps_account_type"
45
+ require "hps/infrastructure/hps_check_type"
46
+ require "hps/infrastructure/hps_data_entry_mode"
47
+ require "hps/infrastructure/hps_sec_code"
48
+ require "hps/infrastructure/hps_input_validation"
49
+ require "hps/infrastructure/hps_gateway_response_validation"
50
+ require "hps/infrastructure/hps_check_exception"
51
+
52
+ # Services
53
+ require "hps/services/hps_service"
54
+ require "hps/services/hps_charge_service"
55
+ require "hps/services/hps_check_service"
56
+ require "hps/services/hps_batch_service"
57
+ require "hps/services/hps_gift_card_service"
58
+
59
+ module Hps
60
+
61
+ extend Configuration
62
+
63
+ end