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
data/Rakefile CHANGED
@@ -1,15 +1,15 @@
1
- task :console do
2
- require 'bundler/gem_tasks'
3
- require 'hps'
4
- begin
5
- require 'pry'
6
- ARGV.clear
7
- Pry.start
8
- rescue LoadError
9
- #pry was not found so loading irb
10
- require 'irb'
11
- require 'irb/completion'
12
- ARGV.clear
13
- IRB.start
14
- end
15
- end
1
+ task :console do
2
+ require 'bundler/gem_tasks'
3
+ require 'hps'
4
+ begin
5
+ require 'pry'
6
+ ARGV.clear
7
+ Pry.start
8
+ rescue LoadError
9
+ #pry was not found so loading irb
10
+ require 'irb'
11
+ require 'irb/completion'
12
+ ARGV.clear
13
+ IRB.start
14
+ end
15
+ end
@@ -1,26 +1,28 @@
1
- # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'hps/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "hps"
8
- spec.version = Hps::VERSION
9
- spec.authors = ["Heartland Payment Systems"]
10
- spec.email = ["IntegrationSupportTeam@e-hps.com"]
11
- spec.description = %q{Ruby SDK for processing payments via Portico Gateway}
12
- spec.summary = %q{Heartland Payment Systems - Portico Gateway SDK}
13
- spec.homepage = ""
14
- spec.license = "MIT"
15
-
16
- spec.files = `git ls-files`.split($/)
17
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
- spec.require_paths = ["lib"]
20
-
21
- spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake"
23
- spec.add_dependency('builder', '>= 2.1.2', '< 4.0.0')
24
- spec.add_dependency('activesupport', '>= 2.3.14', '< 5.0.0')
25
-
26
- end
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'hps/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "hps"
8
+ spec.version = Hps::VERSION
9
+ spec.authors = ["Heartland Payment Systems"]
10
+ spec.email = ["IntegrationSupportTeam@e-hps.com"]
11
+ spec.description = %q{Ruby SDK for processing payments via Portico Gateway}
12
+ spec.summary = %q{Heartland Payment Systems - Portico Gateway SDK}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "pry"
25
+ spec.add_dependency('builder', '>= 2.1.2', '< 4.0.0')
26
+ spec.add_dependency('activesupport', '>= 2.3.14', '< 5.0.0')
27
+
28
+ end
data/lib/hps.rb CHANGED
@@ -1,45 +1,48 @@
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_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
+
29
+ # Infrastructure
30
+ require "hps/infrastructure/hps_sdk_codes"
31
+ require "hps/infrastructure/hps_exception"
32
+ require "hps/infrastructure/api_connection_exception"
33
+ require "hps/infrastructure/authentication_exception"
34
+ require "hps/infrastructure/card_exception"
35
+ require "hps/infrastructure/invalid_request_exception"
36
+ require "hps/infrastructure/hps_exception_mapper"
37
+ require "hps/infrastructure/hps_track_data_method"
38
+
39
+ # Services
40
+ require "hps/services/hps_service"
41
+ require "hps/services/hps_charge_service"
42
+ require "hps/services/hps_batch_service"
43
+
44
+ module Hps
45
+
46
+ extend Configuration
47
+
48
+ end
@@ -1,17 +1,17 @@
1
- module Hps
2
- module Configuration
3
-
4
- VALID_CONFIG_KEYS = [ :service_uri, :user_name, :password, :developer_id, :version_number, :license_id, :device_id, :site_id, :site_trace, :secret_api_key ].freeze
5
-
6
- attr_accessor *VALID_CONFIG_KEYS
7
-
8
- def configure
9
- yield self
10
- end
11
-
12
- def options
13
- Hash[ * VALID_CONFIG_KEYS.map { |key| [key, send(key)] }.flatten ]
14
- end
15
-
16
- end
1
+ module Hps
2
+ module Configuration
3
+
4
+ VALID_CONFIG_KEYS = [ :service_uri, :user_name, :password, :developer_id, :version_number, :license_id, :device_id, :site_id, :site_trace, :secret_api_key ].freeze
5
+
6
+ attr_accessor *VALID_CONFIG_KEYS
7
+
8
+ def configure
9
+ yield self
10
+ end
11
+
12
+ def options
13
+ Hash[ * VALID_CONFIG_KEYS.map { |key| [key, send(key)] }.flatten ]
14
+ end
15
+
16
+ end
17
17
  end
@@ -1,9 +1,9 @@
1
- module Hps
2
- class HpsAccountVerify < HpsAuthorization
3
-
4
- def initialize(header)
5
- super(header)
6
- end
7
-
8
- end
1
+ module Hps
2
+ class HpsAccountVerify < HpsAuthorization
3
+
4
+ def initialize(header)
5
+ super(header)
6
+ end
7
+
8
+ end
9
9
  end
@@ -1,7 +1,7 @@
1
- module Hps
2
- class HpsAddress
3
-
4
- attr_accessor :address, :city, :state, :zip, :country
5
-
6
- end
1
+ module Hps
2
+ class HpsAddress
3
+
4
+ attr_accessor :address, :city, :state, :zip, :country
5
+
6
+ end
7
7
  end
@@ -1,13 +1,13 @@
1
- module Hps
2
- class HpsAuthorization < HpsTransaction
3
-
4
- attr_accessor :avs_result_code, :avs_result_text, :cvv_result_code,
5
- :cvv_result_text, :cpc_indicator, :authorization_code,
6
- :authorized_amount, :card_type, :token_data
7
-
8
- def initialize(header)
9
- super(header)
10
- end
11
-
12
- end
1
+ module Hps
2
+ class HpsAuthorization < HpsTransaction
3
+
4
+ attr_accessor :avs_result_code, :avs_result_text, :cvv_result_code,
5
+ :cvv_result_text, :cpc_indicator, :authorization_code,
6
+ :authorized_amount, :card_type, :token_data
7
+
8
+ def initialize(header)
9
+ super(header)
10
+ end
11
+
12
+ end
13
13
  end
@@ -1,7 +1,7 @@
1
- module Hps
2
- class HpsBatch
3
-
4
- attr_accessor :id, :transaction_count, :total_amount, :sequence_number
5
-
6
- end
1
+ module Hps
2
+ class HpsBatch
3
+
4
+ attr_accessor :id, :transaction_count, :total_amount, :sequence_number
5
+
6
+ end
7
7
  end
@@ -1,11 +1,7 @@
1
- module Hps
2
- class HpsCardHolder
3
-
4
- attr_accessor :first_name, :last_name, :phone, :email_address, :address
5
-
6
- def initialize
7
- self.address = Hps::HpsAddress.new
8
- end
9
-
10
- end
1
+ module Hps
2
+ class HpsCardHolder
3
+
4
+ attr_accessor :first_name, :last_name, :phone, :email_address, :address
5
+
6
+ end
11
7
  end
@@ -1,9 +1,9 @@
1
- module Hps
2
- class HpsCharge < HpsAuthorization
3
-
4
- def initialize(header)
5
- super(header)
6
- end
7
-
8
- end
1
+ module Hps
2
+ class HpsCharge < HpsAuthorization
3
+
4
+ def initialize(header)
5
+ super(header)
6
+ end
7
+
8
+ end
9
9
  end
@@ -1,7 +1,7 @@
1
- module Hps
2
- class HpsChargeExceptions
3
-
4
- attr_accessor :card_exception, :hps_exception
5
-
6
- end
1
+ module Hps
2
+ class HpsChargeExceptions
3
+
4
+ attr_accessor :card_exception, :hps_exception
5
+
6
+ end
7
7
  end
@@ -1,33 +1,34 @@
1
- module Hps
2
- class HpsCreditCard
3
-
4
- attr_accessor :number, :cvv, :exp_month, :exp_year
5
-
6
- def initialize
7
-
8
- @regex_map = {
9
- :Amex => /^3[47][0-9]{13}$/,
10
- :MasterCard => /^5[1-5][0-9]{14}$/,
11
- :Visa => /^4[0-9]{12}(?:[0-9]{3})?$/,
12
- :DinersClub => /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/,
13
- :EnRoute => /^(2014|2149)/,
14
- :Discover => /^6(?:011|5[0-9]{2})[0-9]{12}$/,
15
- :Jcb => /^(?:2131|1800|35\\d{3})\\d{11}$/
16
- }
17
-
18
- end
19
-
20
- def card_type
21
-
22
- @regex_map.each { |key, value|
23
- unless value.match(number.to_s).nil?
24
- return key
25
- end
26
- }
27
-
28
- "Unknown"
29
-
30
- end
31
-
32
- end
33
- end
1
+ module Hps
2
+ class HpsCreditCard
3
+
4
+ attr_accessor :number, :cvv, :exp_month,
5
+ :exp_year, :card_present, :reader_present
6
+
7
+ def initialize
8
+
9
+ @regex_map = {
10
+ :Amex => /^3[47][0-9]{13}$/,
11
+ :MasterCard => /^5[1-5][0-9]{14}$/,
12
+ :Visa => /^4[0-9]{12}(?:[0-9]{3})?$/,
13
+ :DinersClub => /^3(?:0[0-5]|[68][0-9])[0-9]{11}$/,
14
+ :EnRoute => /^(2014|2149)/,
15
+ :Discover => /^6(?:011|5[0-9]{2})[0-9]{12}$/,
16
+ :Jcb => /^(?:2131|1800|35\\d{3})\\d{11}$/
17
+ }
18
+
19
+ end
20
+
21
+ def card_type
22
+
23
+ @regex_map.each { |key, value|
24
+ unless value.match(number.to_s).nil?
25
+ return key
26
+ end
27
+ }
28
+
29
+ "Unknown"
30
+
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,5 @@
1
+ module Hps
2
+ class HpsDirectMarketData
3
+ attr_accessor :invoice_number, :ship_month, :ship_day
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ module Hps
2
+ class HpsEncryptionData
3
+ attr_accessor :version, :encrypted_track_number,
4
+ :ktb, :ksn
5
+ end
6
+ end
@@ -1,9 +1,9 @@
1
- module Hps
2
- class HpsRefund < HpsTransaction
3
-
4
- def initialize(header)
5
- super(header)
6
- end
7
-
8
- end
1
+ module Hps
2
+ class HpsRefund < HpsTransaction
3
+
4
+ def initialize(header)
5
+ super(header)
6
+ end
7
+
8
+ end
9
9
  end
@@ -1,11 +1,11 @@
1
- module Hps
2
- class HpsReportTransactionDetails < HpsAuthorization
3
-
4
- attr_accessor :original_transaction_id, :masked_card_number, :transaction_type, :transaction_date, :exceptions
5
-
6
- def initialize(header)
7
- super(header)
8
- end
9
-
10
- end
1
+ module Hps
2
+ class HpsReportTransactionDetails < HpsAuthorization
3
+
4
+ attr_accessor :original_transaction_id, :masked_card_number, :transaction_type, :transaction_date, :exceptions
5
+
6
+ def initialize(header)
7
+ super(header)
8
+ end
9
+
10
+ end
11
11
  end