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,56 +1,56 @@
1
- require 'net/http'
2
-
3
- require 'rubygems'
4
- require 'json'
5
-
6
- module Hps
7
- class HpsTokenService
8
- attr_accessor :public_api_key, :url
9
-
10
- def initialize(public_api_key)
11
- @public_api_key = public_api_key
12
- if @public_api_key.nil? || @public_api_key.eql?('')
13
- raise HpsException.new('Public Key Not Found', '0')
14
- end
15
-
16
- components = @public_api_key.split '_'
17
- if components.size < 3
18
- raise HpsException.new('Public API Key must contain at least two underscores','0')
19
- end
20
-
21
- if components[1].downcase.eql? 'prod'
22
- @url = 'https://api.heartlandportico.com/SecureSubmit.v1/api/token'
23
- else
24
- @url = 'https://posgateway.cert.secureexchange.net/Hps.Exchange.PosGateway.Hpf.v1/api/token'
25
- end
26
-
27
- end
28
-
29
- def get_token(card_data)
30
- data = {
31
- 'api_key' => @public_api_key,
32
- 'object' => 'token',
33
- 'token_type' => 'supt',
34
- '_method' => 'post',
35
- 'card[number]' => card_data.number,
36
- 'card[cvv]' => card_data.cvv,
37
- 'card[exp_month]' => card_data.exp_month,
38
- 'card[exp_year]' => card_data.exp_year
39
- }
40
- get_result = get(data)
41
- JSON.parse(get_result)
42
- end
43
-
44
- def get(data)
45
- begin
46
- uri = URI(@url)
47
- uri.query = URI.encode_www_form(data)
48
- res = Net::HTTP.get_response(uri)
49
- res.body
50
-
51
- rescue Exception => e
52
- raise HpsException.new(e.message,'0')
53
- end
54
- end
55
- end
56
- end
1
+ require 'net/http'
2
+
3
+ require 'rubygems'
4
+ require 'json'
5
+
6
+ module Hps
7
+ class HpsTokenService
8
+ attr_accessor :public_api_key, :url
9
+
10
+ def initialize(public_api_key)
11
+ @public_api_key = public_api_key
12
+ if @public_api_key.nil? || @public_api_key.eql?('')
13
+ raise HpsException.new('Public Key Not Found', '0')
14
+ end
15
+
16
+ components = @public_api_key.split '_'
17
+ if components.size < 3
18
+ raise HpsException.new('Public API Key must contain at least two underscores','0')
19
+ end
20
+
21
+ if components[1].downcase.eql? 'prod'
22
+ @url = 'https://api.heartlandportico.com/SecureSubmit.v1/api/token'
23
+ else
24
+ @url = 'https://posgateway.cert.secureexchange.net/Hps.Exchange.PosGateway.Hpf.v1/api/token'
25
+ end
26
+
27
+ end
28
+
29
+ def get_token(card_data)
30
+ data = {
31
+ 'api_key' => @public_api_key,
32
+ 'object' => 'token',
33
+ 'token_type' => 'supt',
34
+ '_method' => 'post',
35
+ 'card[number]' => card_data.number,
36
+ 'card[cvv]' => card_data.cvv,
37
+ 'card[exp_month]' => card_data.exp_month,
38
+ 'card[exp_year]' => card_data.exp_year
39
+ }
40
+ get_result = get(data)
41
+ JSON.parse(get_result)
42
+ end
43
+
44
+ def get(data)
45
+ begin
46
+ uri = URI(@url)
47
+ uri.query = URI.encode_www_form(data)
48
+ res = Net::HTTP.get_response(uri)
49
+ res.body
50
+
51
+ rescue Exception => e
52
+ raise HpsException.new(e.message,'0')
53
+ end
54
+ end
55
+ end
56
+ end