hps 1.0.1 → 1.0.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.
- checksums.yaml +4 -4
- data/Gemfile +8 -8
- data/LICENSE.txt +32 -32
- data/PRIVACY.txt +65 -65
- data/README.md +40 -40
- data/Rakefile +15 -15
- data/hps.gemspec +26 -26
- data/lib/hps/configuration.rb +16 -16
- 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 +10 -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_credit_card.rb +32 -32
- 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_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 +468 -468
- data/lib/hps/infrastructure/hps_exception.rb +25 -25
- data/lib/hps/infrastructure/hps_exception_mapper.rb +134 -134
- data/lib/hps/infrastructure/hps_sdk_codes.rb +48 -48
- 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 +634 -634
- data/lib/hps/services/hps_service.rb +128 -128
- data/lib/hps/version.rb +3 -3
- data/lib/hps.rb +45 -45
- data/tests/amex_tests.rb +230 -230
- data/tests/cert_tests.rb +80 -80
- data/tests/discover_tests.rb +324 -324
- data/tests/exception_mapper_tests.rb +244 -244
- data/tests/general_tests.rb +58 -58
- data/tests/hps_token_service.rb +56 -56
- data/tests/mastercard_tests.rb +325 -325
- data/tests/secret_key.rb +11 -11
- data/tests/test_data.rb +127 -127
- data/tests/test_helper.rb +108 -92
- data/tests/token_tests.rb +513 -513
- data/tests/visa_tests.rb +378 -378
- metadata +4 -6
- data/.DS_Store +0 -0
- data/.gitignore +0 -24
data/tests/hps_token_service.rb
CHANGED
@@ -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
|