kount_complete 1.0.7 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,28 +1,28 @@
1
- module Kount
2
- ##
3
- # This class extends the Request class and is used in the
4
- # process of sending updates to an existing transaction
5
- # generated by a previous Inquiry request.
6
- class Update < Request
7
- # Initialize an Update object
8
- #
9
- # Example usage
10
- # {:MACK => "Y", :AUTH => "A"}
11
- #
12
- # @param initial_params [Hash] Initial params for request
13
- def initialize(initial_params = {})
14
- super(initial_params)
15
- # Default to mode U unless mode X is explicitly set
16
- add_params(MODE: 'U') unless initial_params[:MODE] == 'X'
17
- end
18
-
19
- # @param version [String] RIS version
20
- # @param merchant_id [String] Merchant ID
21
- # @param response_format [String] Response format (JSON)
22
- # @param ksalt [String] Kount supplied secret salt for KHASH
23
- def prepare_params(version, merchant_id, response_format, ksalt)
24
- super(version, merchant_id, response_format, ksalt)
25
- params
26
- end
27
- end
28
- end
1
+ module Kount
2
+ ##
3
+ # This class extends the Request class and is used in the
4
+ # process of sending updates to an existing transaction
5
+ # generated by a previous Inquiry request.
6
+ class Update < Request
7
+ # Initialize an Update object
8
+ #
9
+ # Example usage
10
+ # {:MACK => "Y", :AUTH => "A"}
11
+ #
12
+ # @param initial_params [Hash] Initial params for request
13
+ def initialize(initial_params = {})
14
+ super(initial_params)
15
+ # Default to mode U unless mode X is explicitly set
16
+ add_params(MODE: 'U') unless initial_params[:MODE] == 'X'
17
+ end
18
+
19
+ # @param version [String] RIS version
20
+ # @param merchant_id [String] Merchant ID
21
+ # @param response_format [String] Response format (JSON)
22
+ # @param ksalt [String] Kount supplied secret salt for KHASH
23
+ def prepare_params(version, merchant_id, response_format, ksalt)
24
+ super(version, merchant_id, response_format, ksalt)
25
+ params
26
+ end
27
+ end
28
+ end
@@ -1,82 +1,82 @@
1
- require 'digest/sha1'
2
- module Kount
3
- ##
4
- # This class implements the Kount KHASH for cards and gift cards.
5
- # rubocop:disable Style/Documentation
6
- class SecurityMash
7
- # @param plain_text [String] String to be hashed
8
- # @param ptyp [String] Payment type code: CARD, GIFT, or OTHER
9
- # @return [String] KHASH version of string
10
- def self.hash_token(plain_text, ptyp, ksalt, merchant_id = '')
11
- if ptyp == 'CARD'
12
- hash_credit_card(plain_text, ksalt)
13
- else
14
- hash_gift_card(plain_text, ksalt, merchant_id)
15
- end
16
- end
17
-
18
- # Hash a credit card number.
19
- # Preserves first six characters of the input so that hashed cards can be
20
- # categorized by Bank Identification Number (BIN).
21
- #
22
- # Example usage:
23
- # hashed = Kount::SecurityMash.hash_credit_card("4111111111111111")
24
- # Expect: 411111WMS5YA6FUZA1KC
25
- # hashed = Kount::SecurityMash.hash_credit_card("5199185454061655")
26
- # Expect: 5199182NOQRXNKTTFL11
27
- # hashed = Kount::SecurityMash.hash_credit_card("4259344583883")
28
- # Expect: 425934FEXQI1QS6TH2O5
29
- #
30
- # @param plain_text [String] String to be hashed
31
- # @return [String] KHASH version of string
32
- def self.hash_credit_card(plain_text, ksalt)
33
- return plain_text if khashed?(plain_text)
34
- first_six = plain_text[0..5]
35
- mashed = mash(plain_text, 14, ksalt)
36
- "#{first_six}#{mashed}"
37
- end
38
-
39
- # Hash a gift card number.
40
- # Use the six characters of the merchant id so that hashed cards can be
41
- # unique across the entire domain.
42
- #
43
- # Example usage:
44
- # hashed = Kount::SecurityMash.hash_gift_card("123456", "3245876")
45
- # Expect: 1234569HXH32Y5NNJCGB
46
-
47
- # @param plain_text [String] String to be hashed
48
- # @return [String] KHASH version of string
49
- def self.hash_gift_card(plain_text, ksalt, merchant_id)
50
- mashed = mash(plain_text, 14, ksalt)
51
- "#{merchant_id}#{mashed}"
52
- end
53
-
54
- # Compute a base64 hash of the provided data.
55
- #
56
- # @param data [String] Data to hash
57
- # @param len [int] Length of hash to retain
58
- # @return [String] Hashed data
59
- # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
60
- def self.mash(data, len, m)
61
- a = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
62
- r = Digest::SHA1.hexdigest("#{data}.#{m}")
63
- c = ''
64
- len = 17 if len > 17
65
- limit = 2 * len
66
- i = 0
67
- while i < limit
68
- c << a[r[i..i + 6].to_i(16) % 36]
69
- i += 2
70
- end
71
- c
72
- end
73
-
74
- # end mash
75
-
76
- # @param val [String] Token that may or may not be khashed
77
- # @return [Boolean] True if token is already khashed
78
- def self.khashed?(val)
79
- true if val =~ /(\d{6}[A-Z0-9]{14})/
80
- end
81
- end # end KountSecurityMash
82
- end
1
+ require 'digest/sha1'
2
+ module Kount
3
+ ##
4
+ # This class implements the Kount KHASH for cards and gift cards.
5
+
6
+ class SecurityMash
7
+ # @param plain_text [String] String to be hashed
8
+ # @param ptyp [String] Payment type code: CARD, GIFT, or OTHER
9
+ # @return [String] KHASH version of string
10
+ def self.hash_token(plain_text, ptyp, ksalt, merchant_id = '')
11
+ if ptyp == 'CARD'
12
+ hash_credit_card(plain_text, ksalt)
13
+ else
14
+ hash_gift_card(plain_text, ksalt, merchant_id)
15
+ end
16
+ end
17
+
18
+ # Hash a credit card number.
19
+ # Preserves first six characters of the input so that hashed cards can be
20
+ # categorized by Bank Identification Number (BIN).
21
+ #
22
+ # Example usage:
23
+ # hashed = Kount::SecurityMash.hash_credit_card("4111111111111111")
24
+ # Expect: 411111WMS5YA6FUZA1KC
25
+ # hashed = Kount::SecurityMash.hash_credit_card("5199185454061655")
26
+ # Expect: 5199182NOQRXNKTTFL11
27
+ # hashed = Kount::SecurityMash.hash_credit_card("4259344583883")
28
+ # Expect: 425934FEXQI1QS6TH2O5
29
+ #
30
+ # @param plain_text [String] String to be hashed
31
+ # @return [String] KHASH version of string
32
+ def self.hash_credit_card(plain_text, ksalt)
33
+ return plain_text if khashed?(plain_text)
34
+ first_six = plain_text[0..5]
35
+ mashed = mash(plain_text, 14, ksalt)
36
+ "#{first_six}#{mashed}"
37
+ end
38
+
39
+ # Hash a gift card number.
40
+ # Use the six characters of the merchant id so that hashed cards can be
41
+ # unique across the entire domain.
42
+ #
43
+ # Example usage:
44
+ # hashed = Kount::SecurityMash.hash_gift_card("123456", "3245876")
45
+ # Expect: 1234569HXH32Y5NNJCGB
46
+
47
+ # @param plain_text [String] String to be hashed
48
+ # @return [String] KHASH version of string
49
+ def self.hash_gift_card(plain_text, ksalt, merchant_id)
50
+ mashed = mash(plain_text, 14, ksalt)
51
+ "#{merchant_id}#{mashed}"
52
+ end
53
+
54
+ # Compute a base64 hash of the provided data.
55
+ #
56
+ # @param data [String] Data to hash
57
+ # @param len [int] Length of hash to retain
58
+ # @return [String] Hashed data
59
+ # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
60
+ def self.mash(data, len, m)
61
+ a = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
62
+ r = Digest::SHA1.hexdigest("#{data}.#{m}")
63
+ c = ''
64
+ len = 17 if len > 17
65
+ limit = 2 * len
66
+ i = 0
67
+ while i < limit
68
+ c << a[r[i..i + 6].to_i(16) % 36]
69
+ i += 2
70
+ end
71
+ c
72
+ end
73
+
74
+ # end mash
75
+
76
+ # @param val [String] Token that may or may not be khashed
77
+ # @return [Boolean] True if token is already khashed
78
+ def self.khashed?(val)
79
+ true if val =~ /(\d{6}[A-Z0-9]{14})/
80
+ end
81
+ end # end KountSecurityMash
82
+ end
@@ -1,47 +1,56 @@
1
- module Kount
2
- class Khash
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
- if ptyp == 'CARD'
8
- HashPaymentToken(plain_text, ksalt)
9
- elsif ptyp == 'CHEK'
10
- HashCheckPayment(plain_text, ksalt)
11
- else
12
- HashGiftCard(plain_text, ksalt, merchant_id)
13
- end
14
- end
15
-
16
- def self.getKhash(data, len, m)
17
- a = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
18
- r = Digest::SHA1.hexdigest("#{data}.#{m}")
19
- c = ''
20
- len = 17 if len > 17
21
- limit = 2 * len
22
- i = 0
23
- while i < limit
24
- c << a[r[i..i + 6].to_i(16) % 36]
25
- i += 2
26
- end
27
- c
28
- end
29
-
30
- def self.HashPaymentToken(plain_text, ksalt)
31
- first_six = plain_text[0..5]
32
- mashed = getKhash(plain_text, 14, ksalt)
33
- "#{first_six}#{mashed}"
34
- end
35
-
36
- def self.HashCheckPayment(plain_text, ksalt)
37
- first_six = plain_text[0..5]
38
- mashed = getKhash(plain_text, 14, ksalt)
39
- "#{first_six}#{mashed}"
40
- end
41
-
42
- def self.HashGiftCard(plain_text, ksalt, merchant_id)
43
- mashed = getKhash(plain_text, 14, ksalt)
44
- "#{merchant_id}#{mashed}"
45
- end
46
- end
47
- end
1
+ module Kount
2
+ class Khash
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
+ if ptyp == 'CARD'
8
+ HashPaymentToken(plain_text, ksalt)
9
+ elsif ptyp == 'CHEK'
10
+ HashCheckPayment(plain_text, ksalt)
11
+ else
12
+ HashGiftCard(plain_text, ksalt, merchant_id)
13
+ end
14
+ end
15
+
16
+ def self.getkhash(data, len, m)
17
+ a = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
18
+ r = Digest::SHA1.hexdigest("#{data}.#{m}")
19
+ c = ''
20
+ len = 17 if len > 17
21
+ limit = 2 * len
22
+ i = 0
23
+ while i < limit
24
+ c << a[r[i..i + 6].to_i(16) % 36]
25
+ i += 2
26
+ end
27
+ c
28
+ end
29
+
30
+ def self.hash_payment_token(plain_text, ksalt)
31
+ return plain_text if khashed?(plain_text)
32
+ first_six = plain_text[0..5]
33
+ mashed = getkhash(plain_text, 14, ksalt)
34
+ "#{first_six}#{mashed}"
35
+ end
36
+
37
+ def self.hash_check_payment(plain_text, ksalt)
38
+ return plain_text if khashed?(plain_text)
39
+ first_six = plain_text[0..5]
40
+ mashed = getkhash(plain_text, 14, ksalt)
41
+ "#{first_six}#{mashed}"
42
+ end
43
+
44
+ def self.hash_gift_card(plain_text, ksalt, merchant_id)
45
+ mashed = getkhash(plain_text, 14, ksalt)
46
+ "#{merchant_id}#{mashed}"
47
+ end
48
+
49
+ # @param val [String] Token that may or may not be khashed
50
+ # @return [Boolean] True if token is already khashed
51
+ def self.khashed?(val)
52
+ true if val =~ /(\d{6}[A-Z0-9]{14})/
53
+ end
54
+
55
+ end
56
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kount_complete
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kount
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-04 00:00:00.000000000 Z
11
+ date: 2020-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -51,6 +51,7 @@ extensions: []
51
51
  extra_rdoc_files: []
52
52
  files:
53
53
  - lib/kount.rb
54
+ - lib/kount/Response.rb
54
55
  - lib/kount/cart.rb
55
56
  - lib/kount/client.rb
56
57
  - lib/kount/payment_types.rb
@@ -71,15 +72,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
71
72
  requirements:
72
73
  - - ">="
73
74
  - !ruby/object:Gem::Version
74
- version: 1.9.3
75
+ version: '2.3'
75
76
  required_rubygems_version: !ruby/object:Gem::Requirement
76
77
  requirements:
77
78
  - - ">="
78
79
  - !ruby/object:Gem::Version
79
80
  version: 1.3.5
80
81
  requirements: []
81
- rubyforge_project:
82
- rubygems_version: 2.7.6.2
82
+ rubygems_version: 3.0.3
83
83
  signing_key:
84
84
  specification_version: 4
85
85
  summary: Kount Complete Services Wrapper