test_ruby 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kount/client.rb +1 -0
- data/lib/kount/request/inquiry.rb +7 -2
- data/lib/utils/khash.rb +49 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f97b1dde595b948315ab0ec5588dec936a981b2806f69101d2c485319287e66d
|
4
|
+
data.tar.gz: e0ca75cc6f4c04e79bfe831dc45cbbae8815ca93778a04aa17855d6eb3b46096
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 03b9b45f1c8e73d47c594dc3161455ea480f92575020a7725d73d9525e805224256951d0891b0b2c86dcdd727225a16d583bec330c9451f8bfd0a7db1b0e51ed
|
7
|
+
data.tar.gz: 7062177ca019b94c23abc6c9c0e8ec8fa2c3a090863b6300b082af59e273d547e397fa4c02054ac92d4dbdebfcb30f1036fd311959ec73b89d63d94e612ecf4a
|
data/lib/kount/client.rb
CHANGED
@@ -39,10 +39,15 @@ module Kount
|
|
39
39
|
ptok = params[:PTOK]
|
40
40
|
case params[:PTYP]
|
41
41
|
when 'CARD', 'TOKEN'
|
42
|
-
ptok = Kount::SecurityMash.hash_credit_card(ptok, ksalt)
|
42
|
+
#ptok = Kount::SecurityMash.hash_credit_card(ptok, ksalt)
|
43
|
+
ptok = Kount::NewKhash.HashPaymentToken(ptok, ksalt)
|
43
44
|
params.merge!(PTOK: ptok, PENC: 'KHASH')
|
44
45
|
when 'GIFT', 'OTHER'
|
45
|
-
ptok = Kount::SecurityMash.hash_gift_card(ptok, ksalt, merchant_id)
|
46
|
+
#ptok = Kount::SecurityMash.hash_gift_card(ptok, ksalt, merchant_id)
|
47
|
+
ptok = Kount::NewKhash.HashGiftCard(ptok, ksalt, merchant_id)
|
48
|
+
params.merge!(PTOK: ptok, PENC: 'KHASH')
|
49
|
+
when 'CHEK', 'OTHER'
|
50
|
+
ptok = Kount::NewKhash.HashCheckPayment(ptok, ksalt)
|
46
51
|
params.merge!(PTOK: ptok, PENC: 'KHASH')
|
47
52
|
when 'NONE'
|
48
53
|
params.merge!(PTOK: nil, PENC: nil)
|
data/lib/utils/khash.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
module Kount
|
2
|
+
class NewKhash
|
3
|
+
# @param plain_text [String] String to be hashed
|
4
|
+
# @param ptyp [String] Payment type code: CARD, GIFT, or OTHER
|
5
|
+
# @return [String] KHASH version of string
|
6
|
+
def self.hash_token(plain_text, ptyp, ksalt, merchant_id = '')
|
7
|
+
puts ptyp
|
8
|
+
exit
|
9
|
+
if ptyp == 'CARD'
|
10
|
+
HashPaymentToken(plain_text, ksalt)
|
11
|
+
elsif ptyp == 'CHEK'
|
12
|
+
HashCheckPayment(plain_text, ksalt)
|
13
|
+
else
|
14
|
+
HashGiftCard(plain_text, ksalt, merchant_id)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.getKhash(data, len, m)
|
19
|
+
a = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
20
|
+
r = Digest::SHA1.hexdigest("#{data}.#{m}")
|
21
|
+
c = ''
|
22
|
+
len = 17 if len > 17
|
23
|
+
limit = 2 * len
|
24
|
+
i = 0
|
25
|
+
while i < limit
|
26
|
+
c << a[r[i..i + 6].to_i(16) % 36]
|
27
|
+
i += 2
|
28
|
+
end
|
29
|
+
c
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.HashPaymentToken(plain_text, ksalt)
|
33
|
+
first_six = plain_text[0..5]
|
34
|
+
mashed = getKhash(plain_text, 14, ksalt)
|
35
|
+
"#{first_six}#{mashed}"
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.HashCheckPayment(plain_text, ksalt)
|
39
|
+
first_six = plain_text[0..5]
|
40
|
+
mashed = getKhash(plain_text, 14, ksalt)
|
41
|
+
"#{first_six}#{mashed}"
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.HashGiftCard(plain_text, ksalt, merchant_id)
|
45
|
+
mashed = getKhash(plain_text, 14, ksalt)
|
46
|
+
"#{merchant_id}#{mashed}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: test_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TestRuby
|
@@ -60,6 +60,7 @@ files:
|
|
60
60
|
- lib/kount/ris-inquiry.rb
|
61
61
|
- lib/kount/security_mash.rb
|
62
62
|
- lib/kount/utils/khash.rb
|
63
|
+
- lib/utils/khash.rb
|
63
64
|
homepage: http://rubygems.org/gems/test_ruby
|
64
65
|
licenses:
|
65
66
|
- MIT
|