hps 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +8 -8
  3. data/LICENSE.txt +32 -32
  4. data/PRIVACY.txt +65 -65
  5. data/README.md +40 -40
  6. data/Rakefile +15 -15
  7. data/hps.gemspec +26 -26
  8. data/lib/hps/configuration.rb +16 -16
  9. data/lib/hps/entities/hps_account_verify.rb +8 -8
  10. data/lib/hps/entities/hps_address.rb +6 -6
  11. data/lib/hps/entities/hps_authorization.rb +12 -12
  12. data/lib/hps/entities/hps_batch.rb +6 -6
  13. data/lib/hps/entities/hps_cardholder.rb +10 -6
  14. data/lib/hps/entities/hps_charge.rb +8 -8
  15. data/lib/hps/entities/hps_charge_exceptions.rb +6 -6
  16. data/lib/hps/entities/hps_credit_card.rb +32 -32
  17. data/lib/hps/entities/hps_refund.rb +8 -8
  18. data/lib/hps/entities/hps_report_transaction_details.rb +10 -10
  19. data/lib/hps/entities/hps_report_transaction_summary.rb +6 -6
  20. data/lib/hps/entities/hps_reversal.rb +10 -10
  21. data/lib/hps/entities/hps_token_data.rb +10 -10
  22. data/lib/hps/entities/hps_transaction.rb +161 -161
  23. data/lib/hps/entities/hps_transaction_details.rb +6 -6
  24. data/lib/hps/entities/hps_transaction_header.rb +8 -8
  25. data/lib/hps/entities/hps_transaction_type.rb +16 -16
  26. data/lib/hps/entities/hps_void.rb +8 -8
  27. data/lib/hps/infrastructure/api_connection_exception.rb +11 -11
  28. data/lib/hps/infrastructure/authentication_exception.rb +11 -11
  29. data/lib/hps/infrastructure/card_exception.rb +15 -15
  30. data/lib/hps/infrastructure/exceptions.json +468 -468
  31. data/lib/hps/infrastructure/hps_exception.rb +25 -25
  32. data/lib/hps/infrastructure/hps_exception_mapper.rb +134 -134
  33. data/lib/hps/infrastructure/hps_sdk_codes.rb +48 -48
  34. data/lib/hps/infrastructure/invalid_request_exception.rb +15 -15
  35. data/lib/hps/services/hps_batch_service.rb +29 -29
  36. data/lib/hps/services/hps_charge_service.rb +634 -634
  37. data/lib/hps/services/hps_service.rb +128 -128
  38. data/lib/hps/version.rb +3 -3
  39. data/lib/hps.rb +45 -45
  40. data/tests/amex_tests.rb +230 -230
  41. data/tests/cert_tests.rb +80 -80
  42. data/tests/discover_tests.rb +324 -324
  43. data/tests/exception_mapper_tests.rb +244 -244
  44. data/tests/general_tests.rb +58 -58
  45. data/tests/hps_token_service.rb +56 -56
  46. data/tests/mastercard_tests.rb +325 -325
  47. data/tests/secret_key.rb +11 -11
  48. data/tests/test_data.rb +127 -127
  49. data/tests/test_helper.rb +108 -92
  50. data/tests/token_tests.rb +513 -513
  51. data/tests/visa_tests.rb +378 -378
  52. metadata +4 -6
  53. data/.DS_Store +0 -0
  54. data/.gitignore +0 -24
@@ -1,128 +1,128 @@
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)
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
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
- end
52
-
53
- xml << transaction
54
-
55
- end
56
- end
57
- end
58
- end
59
-
60
- begin
61
-
62
- uri = URI.parse(self.service_uri)
63
- http = Net::HTTP.new uri.host, uri.port
64
- http.use_ssl = true
65
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
66
- data = xml.target!
67
-
68
- response = http.post(uri.path, data, 'Content-type' => 'text/xml')
69
-
70
- # NOTE: If the HTTP request was successful
71
- if response.is_a? Net::HTTPOK
72
-
73
- # NOTE: Convert XML to a Hash
74
- soap_hash = Hash.from_xml(response.body)
75
- # NOTE: Peel away the layers and return only the PosRespose
76
- soap_hash["Envelope"]["Body"]["PosResponse"]["Ver1.0"]
77
-
78
- else
79
- raise @exception_mapper.map_sdk_exception(SdkCodes.unable_to_process_transaction)
80
- end
81
-
82
- rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
83
- Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
84
- raise @exception_mapper.map_sdk_exception(SdkCodes.unable_to_process_transaction, e)
85
- end
86
-
87
- end
88
-
89
- def gateway_url_for_key(api_key)
90
-
91
- gateway_url = "https://posgateway.secureexchange.net/Hps.Exchange.PosGateway/PosGatewayService.asmx?wsdl"
92
-
93
- if api_key.include? "_uat_"
94
-
95
- gateway_url = "https://posgateway.uat.secureexchange.net/Hps.Exchange.PosGateway/PosGatewayService.asmx?wsdl"
96
-
97
- elsif api_key.include? "_cert_"
98
-
99
- gateway_url = "https://posgateway.cert.secureexchange.net/Hps.Exchange.PosGateway/PosGatewayService.asmx?wsdl"
100
- end
101
-
102
- gateway_url
103
- end
104
-
105
- def hydrate_transaction_header(header)
106
- result = HpsTransactionHeader.new
107
- result.gateway_response_code = header["GatewayRspCode"]
108
- result.gateway_response_message = header["GatewayRspMsg"]
109
- result.response_dt = header["RspDT"]
110
- result.client_txn_id = header["GatewayTxnId"]
111
- result
112
- end
113
-
114
- private
115
-
116
- def configuration_invalid
117
- self.secret_api_key.nil? and (
118
- self.service_uri.nil? or
119
- self.user_name.nil? or
120
- self.password.nil? or
121
- self.license_id.nil? or
122
- self.device_id.nil? or
123
- self.site_id.nil?
124
- )
125
- end
126
-
127
- end
128
- end
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)
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
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
+ end
52
+
53
+ xml << transaction
54
+
55
+ end
56
+ end
57
+ end
58
+ end
59
+
60
+ begin
61
+
62
+ uri = URI.parse(self.service_uri)
63
+ http = Net::HTTP.new uri.host, uri.port
64
+ http.use_ssl = true
65
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
66
+ data = xml.target!
67
+
68
+ response = http.post(uri.path, data, 'Content-type' => 'text/xml')
69
+
70
+ # NOTE: If the HTTP request was successful
71
+ if response.is_a? Net::HTTPOK
72
+
73
+ # NOTE: Convert XML to a Hash
74
+ soap_hash = Hash.from_xml(response.body)
75
+ # NOTE: Peel away the layers and return only the PosRespose
76
+ soap_hash["Envelope"]["Body"]["PosResponse"]["Ver1.0"]
77
+
78
+ else
79
+ raise @exception_mapper.map_sdk_exception(SdkCodes.unable_to_process_transaction)
80
+ end
81
+
82
+ rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError,
83
+ Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
84
+ raise @exception_mapper.map_sdk_exception(SdkCodes.unable_to_process_transaction, e)
85
+ end
86
+
87
+ end
88
+
89
+ def gateway_url_for_key(api_key)
90
+
91
+ gateway_url = "https://posgateway.secureexchange.net/Hps.Exchange.PosGateway/PosGatewayService.asmx?wsdl"
92
+
93
+ if api_key.include? "_uat_"
94
+
95
+ gateway_url = "https://posgateway.uat.secureexchange.net/Hps.Exchange.PosGateway/PosGatewayService.asmx?wsdl"
96
+
97
+ elsif api_key.include? "_cert_"
98
+
99
+ gateway_url = "https://posgateway.cert.secureexchange.net/Hps.Exchange.PosGateway/PosGatewayService.asmx?wsdl"
100
+ end
101
+
102
+ gateway_url
103
+ end
104
+
105
+ def hydrate_transaction_header(header)
106
+ result = HpsTransactionHeader.new
107
+ result.gateway_response_code = header["GatewayRspCode"]
108
+ result.gateway_response_message = header["GatewayRspMsg"]
109
+ result.response_dt = header["RspDT"]
110
+ result.client_txn_id = header["GatewayTxnId"]
111
+ result
112
+ end
113
+
114
+ private
115
+
116
+ def configuration_invalid
117
+ self.secret_api_key.nil? and (
118
+ self.service_uri.nil? or
119
+ self.user_name.nil? or
120
+ self.password.nil? or
121
+ self.license_id.nil? or
122
+ self.device_id.nil? or
123
+ self.site_id.nil?
124
+ )
125
+ end
126
+
127
+ end
128
+ end
data/lib/hps/version.rb CHANGED
@@ -1,3 +1,3 @@
1
- module Hps
2
- VERSION = "1.0.1"
3
- end
1
+ module Hps
2
+ VERSION = "1.0.2"
3
+ end
data/lib/hps.rb CHANGED
@@ -1,45 +1,45 @@
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_refund"
18
- require "hps/entities/hps_report_transaction_details"
19
- require "hps/entities/hps_report_transaction_summary"
20
- require "hps/entities/hps_reversal"
21
- require "hps/entities/hps_token_data"
22
- require "hps/entities/hps_transaction_header"
23
- require "hps/entities/hps_transaction_type"
24
- require "hps/entities/hps_transaction_details"
25
- require "hps/entities/hps_void"
26
-
27
- # Infrastructure
28
- require "hps/infrastructure/hps_sdk_codes"
29
- require "hps/infrastructure/hps_exception"
30
- require "hps/infrastructure/api_connection_exception"
31
- require "hps/infrastructure/authentication_exception"
32
- require "hps/infrastructure/card_exception"
33
- require "hps/infrastructure/invalid_request_exception"
34
- require "hps/infrastructure/hps_exception_mapper"
35
-
36
- # Services
37
- require "hps/services/hps_service"
38
- require "hps/services/hps_charge_service"
39
- require "hps/services/hps_batch_service"
40
-
41
- module Hps
42
-
43
- extend Configuration
44
-
45
- 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_refund"
18
+ require "hps/entities/hps_report_transaction_details"
19
+ require "hps/entities/hps_report_transaction_summary"
20
+ require "hps/entities/hps_reversal"
21
+ require "hps/entities/hps_token_data"
22
+ require "hps/entities/hps_transaction_header"
23
+ require "hps/entities/hps_transaction_type"
24
+ require "hps/entities/hps_transaction_details"
25
+ require "hps/entities/hps_void"
26
+
27
+ # Infrastructure
28
+ require "hps/infrastructure/hps_sdk_codes"
29
+ require "hps/infrastructure/hps_exception"
30
+ require "hps/infrastructure/api_connection_exception"
31
+ require "hps/infrastructure/authentication_exception"
32
+ require "hps/infrastructure/card_exception"
33
+ require "hps/infrastructure/invalid_request_exception"
34
+ require "hps/infrastructure/hps_exception_mapper"
35
+
36
+ # Services
37
+ require "hps/services/hps_service"
38
+ require "hps/services/hps_charge_service"
39
+ require "hps/services/hps_batch_service"
40
+
41
+ module Hps
42
+
43
+ extend Configuration
44
+
45
+ end