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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 24de3c82081a4eb24f4777e696ff181004009a168cb8a88d289829eb2dede6f1
4
- data.tar.gz: e186054c1fb43bcd9e9ec663c25b70c08bf62ac2136850ac0298d24364776cc2
3
+ metadata.gz: f97b1dde595b948315ab0ec5588dec936a981b2806f69101d2c485319287e66d
4
+ data.tar.gz: e0ca75cc6f4c04e79bfe831dc45cbbae8815ca93778a04aa17855d6eb3b46096
5
5
  SHA512:
6
- metadata.gz: 291231e2ff81415cc3e239524677dbd0da31b3a21c1de6af91cdf9111ec71bf11ef50589e23b7a424bbb87704d69a10ffdd900855146da7f9140db01220333ec
7
- data.tar.gz: '08082a29bf662c340d13fa4aa6b550787bd37e539fb94d7835c9a83c523b43a73af4bbd828119d0ddb6ea578170b2a977d1fd7337e04584a9ab4677283c146eb'
6
+ metadata.gz: 03b9b45f1c8e73d47c594dc3161455ea480f92575020a7725d73d9525e805224256951d0891b0b2c86dcdd727225a16d583bec330c9451f8bfd0a7db1b0e51ed
7
+ data.tar.gz: 7062177ca019b94c23abc6c9c0e8ec8fa2c3a090863b6300b082af59e273d547e397fa4c02054ac92d4dbdebfcb30f1036fd311959ec73b89d63d94e612ecf4a
data/lib/kount/client.rb CHANGED
@@ -5,6 +5,7 @@ require 'kount/request/update'
5
5
  require 'kount/request/inquiry'
6
6
  require 'rest-client'
7
7
  require 'uri'
8
+ require 'kount/utils/khash'
8
9
 
9
10
  # rubocop:disable Style/ClassVars
10
11
  module Kount
@@ -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)
@@ -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.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