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.
- checksums.yaml +4 -4
- data/Gemfile +4 -4
- data/Gemfile.lock +59 -0
- data/LICENSE.md +264 -264
- data/PRIVACY.txt +65 -65
- data/README.md +213 -213
- data/Rakefile +15 -15
- data/examples/sinatra-verify-only/Gemfile +4 -4
- data/examples/sinatra-verify-only/app.rb +32 -32
- data/examples/sinatra-verify-only/views/index.erb +478 -478
- data/examples/sinatra-verify-only/views/result.erb +39 -39
- data/hps.gemspec +28 -27
- data/lib/hps/configuration.rb +17 -17
- data/lib/hps/entities/hps_account_verify.rb +8 -8
- data/lib/hps/entities/hps_address.rb +6 -6
- data/lib/hps/entities/hps_authorization.rb +12 -12
- data/lib/hps/entities/hps_batch.rb +6 -6
- data/lib/hps/entities/hps_cardholder.rb +6 -6
- data/lib/hps/entities/hps_charge.rb +8 -8
- data/lib/hps/entities/hps_charge_exceptions.rb +6 -6
- data/lib/hps/entities/hps_check.rb +18 -18
- data/lib/hps/entities/hps_check_holder.rb +10 -10
- data/lib/hps/entities/hps_check_response.rb +45 -45
- data/lib/hps/entities/hps_check_response_details.rb +9 -9
- data/lib/hps/entities/hps_credit_card.rb +34 -34
- data/lib/hps/entities/hps_direct_market_data.rb +5 -5
- data/lib/hps/entities/hps_encryption_data.rb +6 -6
- data/lib/hps/entities/hps_gift_card.rb +133 -133
- data/lib/hps/entities/hps_manage_tokens.rb +8 -8
- data/lib/hps/entities/hps_refund.rb +8 -8
- data/lib/hps/entities/hps_report_transaction_details.rb +10 -10
- data/lib/hps/entities/hps_report_transaction_summary.rb +6 -6
- data/lib/hps/entities/hps_reversal.rb +10 -10
- data/lib/hps/entities/hps_token_data.rb +10 -10
- data/lib/hps/entities/hps_track_data.rb +5 -5
- data/lib/hps/entities/hps_transaction.rb +161 -161
- data/lib/hps/entities/hps_transaction_details.rb +6 -6
- data/lib/hps/entities/hps_transaction_header.rb +8 -8
- data/lib/hps/entities/hps_transaction_type.rb +16 -16
- data/lib/hps/entities/hps_void.rb +8 -8
- data/lib/hps/infrastructure/api_connection_exception.rb +11 -11
- data/lib/hps/infrastructure/authentication_exception.rb +11 -11
- data/lib/hps/infrastructure/card_exception.rb +15 -15
- data/lib/hps/infrastructure/exceptions.json +547 -547
- data/lib/hps/infrastructure/hps_account_type.rb +11 -11
- data/lib/hps/infrastructure/hps_check_exception.rb +13 -13
- data/lib/hps/infrastructure/hps_check_type.rb +11 -11
- data/lib/hps/infrastructure/hps_data_entry_mode.rb +11 -11
- data/lib/hps/infrastructure/hps_exception.rb +25 -25
- data/lib/hps/infrastructure/hps_exception_mapper.rb +145 -145
- data/lib/hps/infrastructure/hps_gateway_response_validation.rb +20 -20
- data/lib/hps/infrastructure/hps_input_validation.rb +13 -13
- data/lib/hps/infrastructure/hps_sdk_codes.rb +48 -48
- data/lib/hps/infrastructure/hps_sec_code.rb +27 -27
- data/lib/hps/infrastructure/hps_track_data_method.rb +6 -6
- data/lib/hps/infrastructure/invalid_request_exception.rb +15 -15
- data/lib/hps/services/hps_batch_service.rb +29 -29
- data/lib/hps/services/hps_charge_service.rb +773 -773
- data/lib/hps/services/hps_check_service.rb +110 -110
- data/lib/hps/services/hps_gift_card_service.rb +301 -301
- data/lib/hps/services/hps_service.rb +141 -136
- data/lib/hps/version.rb +3 -3
- data/lib/hps.rb +63 -63
- data/tests/amex_tests.rb +292 -292
- data/tests/cert_tests.rb +80 -80
- data/tests/certification/card_present_spec.rb +320 -320
- data/tests/certification/gift_card_certification_test.rb +106 -106
- data/tests/certification/gift_card_certification_tests.rb +107 -107
- data/tests/check_tests.rb +50 -50
- data/tests/discover_tests.rb +386 -386
- data/tests/exception_mapper_tests.rb +311 -311
- data/tests/general_tests.rb +140 -140
- data/tests/giftcard_tests.rb +212 -212
- data/tests/hps_token_service.rb +56 -56
- data/tests/mastercard_tests.rb +387 -387
- data/tests/secret_key.rb +11 -11
- data/tests/test_check.rb +77 -77
- data/tests/test_data.rb +138 -138
- data/tests/test_helper.rb +179 -179
- data/tests/token_tests.rb +512 -512
- data/tests/visa_tests.rb +445 -445
- metadata +31 -11
@@ -1,136 +1,141 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
xml.hps :
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
result
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
self.
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
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
|
-
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
|