kount_complete 2.2.0 → 2.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e78ba40ade6af05b00f647e187aa66351ca6cd67472b5de0b84f39b2008326a9
4
- data.tar.gz: 8a149dffc64cf06e1e00f96765ce004ab2df2c44465f51853e353882581bef7a
3
+ metadata.gz: 6d823582c3fa9dd5d79479b52f4e45365efd72f24a840a0f1aefd3384d41ac44
4
+ data.tar.gz: d5b0a0664392c3f0cf40b7c10389d2e2425c342e16fd64ebd9a75b947395af43
5
5
  SHA512:
6
- metadata.gz: fb98d21ba72460bcc18c5b7581110566969755c1bc476e6b6e834c34928b626b16a92fca128a36ac99d2de82928877ee55275650b91d698607fb843ed84c1b56
7
- data.tar.gz: f7e0937dda76d2919e20487a34d8c51a337b79745c7b72d5ec5527e1bfd1a76e5ffbeabdc8e590693c9e935266305015507c6f9b93c1481c17e54167ca711f50
6
+ metadata.gz: ba23c2a4b10d84e90debc567d6fabd7cfbf4befcadbefc09836d03dda914bb85cf13359bbd294b6ab5ed8ed430be0ee3ee87d437040b899b1fdd1e99f64f5263
7
+ data.tar.gz: 4be12537ebb05ff14d2cdcf5cb86d549bba92f6ffeae2b3d70926037eda688cec24504f1b1bf194f163be6ab3659080f5cc79e75f59501d8765b85ca88b92771
@@ -327,14 +327,15 @@ module Response
327
327
  @paramlist['ERROR_COUNT'].to_s
328
328
  end
329
329
 
330
- def geterrors
330
+ def get_errors
331
331
  errors = []
332
- error_count = get_error_count
333
- (0..error_count.to_i - 1).each do |i|
334
- errors = @paramlist["ERROR_#{i}"]
332
+ error_count = get_error_count.to_i
333
+ (0..error_count - 1).each do |i|
334
+ errors << @paramlist["ERROR_#{i}"]
335
335
  end
336
336
  errors.compact
337
337
  end
338
+ alias geterrors get_errors
338
339
 
339
340
  def get_numbercounters_triggered
340
341
  # changed due to rubocop styling rules for ruby
data/lib/kount/client.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'kount/security_mash'
2
1
  require 'kount/cart'
3
2
  require 'kount/request'
4
3
  require 'kount/request/update'
data/lib/kount/config.rb CHANGED
@@ -8,7 +8,7 @@ module Kount
8
8
  # SDK release version
9
9
  # Set the sdk release version which will be used for git tagging in github
10
10
  # This will be set by the build process
11
- SDK_VERSION = '2.2.0'
11
+ SDK_VERSION = '2.3.0'
12
12
 
13
13
  end
14
14
  end
@@ -3,50 +3,48 @@ module Kount
3
3
  # Convenience class to provide a list of PTYP values
4
4
  class PaymentTypes
5
5
  # Credit card (VISA, MasterCard, Amercian Express, etc)
6
- CREDIT_CARD = 'CARD'
6
+ CREDIT_CARD = 'CARD'
7
7
  #Generic Token
8
- TOKEN = 'TOKEN'
8
+ TOKEN = 'TOKEN'
9
9
  # PayPal
10
- PAYPAL = 'PYPL'
10
+ PAYPAL = 'PYPL'
11
11
  # Check
12
- CHECK = 'CHEK'
12
+ CHECK = 'CHEK'
13
13
  # Merchant issued gift card (not the ones with VISA/MC on them)
14
- GIFT_CARD = 'GIFT'
14
+ GIFT_CARD = 'GIFT'
15
15
  # Carte Bleue
16
- CARTE_BLEUE = 'CARTE_BLEUE'
16
+ CARTE_BLEUE = 'CARTE_BLEUE'
17
17
  # Sofort
18
- SOFORT = 'SOFORT'
18
+ SOFORT = 'SOFORT'
19
19
  # Elv
20
- ELV = 'ELV'
20
+ ELV = 'ELV'
21
21
  # Poli
22
- POLI = 'POLI'
22
+ POLI = 'POLI'
23
23
  # Neteller
24
- NETELLER = 'NETELLER'
24
+ NETELLER = 'NETELLER'
25
25
  # Giropay
26
- GIROPAY = 'GIROPAY'
26
+ GIROPAY = 'GIROPAY'
27
27
  # BPay
28
- BPAY = 'BPAY'
28
+ BPAY = 'BPAY'
29
29
  # Interac
30
- INTERAC = 'INTERAC'
30
+ INTERAC = 'INTERAC'
31
31
  # Apple Pay
32
- APPLE_PAY = 'APAY'
32
+ APPLE_PAY = 'APAY'
33
33
  # Skrill
34
- SKRILL = 'SKRILL'
34
+ SKRILL = 'SKRILL'
35
35
  # Moneybooker (basically another name for Skrill)
36
- MONEYBOOKERS = 'SKRILL'
36
+ MONEYBOOKERS = 'SKRILL'
37
37
  # Mercado Pago
38
- MERCADO_PAGO = 'MERCADE_PAGO'
38
+ MERCADO_PAGO = 'MERCADE_PAGO'
39
39
  # Bill Me Later
40
- BILL_ME_LATER = 'BLML'
40
+ BILL_ME_LATER = 'BLML'
41
41
  # Google Checkout
42
- GOOGLE_CHECKOUT = 'GOOG'
42
+ GOOGLE_CHECKOUT = 'GOOG'
43
43
  # Green Dot Money Pack
44
- GREEN_DOT_MONEY_PACK = 'GDMP'
44
+ GREEN_DOT_MONEY_PACK = 'GDMP'
45
45
  # Single Euro Payments Area
46
46
  SINGLE_EURO_PAYMENTS_AREA = 'SEPA'
47
47
  # None
48
- NONE = 'NONE'
49
- # Other
50
- OTHER = 'OTHER'
48
+ NONE = 'NONE'
51
49
  end
52
50
  end
@@ -38,23 +38,19 @@ module Kount
38
38
 
39
39
  # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
40
40
  def fixup_payment_params(ksalt, merchant_id)
41
- ptok = params[:PTOK]
42
41
  case params[:PTYP]
43
- when 'CARD', 'TOKEN'
44
- #ptok = Kount::SecurityMash.hash_credit_card(ptok, ksalt)
45
- ptok = Kount::Khash.hash_payment_token(ptok, ksalt)
42
+ when 'CARD'
43
+ return if params[:PENC] == 'MASK'
44
+ ptok = Kount::Khash.hash_payment_token(params[:PTOK], ksalt)
46
45
  params.merge!(PTOK: ptok, PENC: 'KHASH')
47
- when 'GIFT', 'OTHER'
48
- #ptok = Kount::SecurityMash.hash_gift_card(ptok, ksalt, merchant_id)
49
- ptok = Kount::Khash.hash_gift_card(ptok, ksalt, merchant_id)
46
+ when 'CHEK', 'PYPL'
47
+ ptok = Kount::Khash.hash_payment_token(params[:PTOK], ksalt)
50
48
  params.merge!(PTOK: ptok, PENC: 'KHASH')
51
- when 'CHEK', 'OTHER'
52
- ptok = Kount::Khash.hash_check_payment(ptok, ksalt)
49
+ when 'GIFT'
50
+ ptok = Kount::Khash.hash_gift_card(params[:PTOK], ksalt, merchant_id)
53
51
  params.merge!(PTOK: ptok, PENC: 'KHASH')
54
52
  when 'NONE'
55
- params.merge!(PTOK: nil, PENC: nil)
56
- else
57
- params[:PENC] ||= 'NONE'
53
+ params.merge!(PTOK: nil)
58
54
  end
59
55
  end
60
56
 
data/lib/kount/request.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'kount/security_mash'
2
1
  module Kount
3
2
  ##
4
3
  # This class acts as an abstract class for each type of request.
@@ -37,9 +36,11 @@ module Kount
37
36
  end
38
37
 
39
38
  # Add LBIN to request
39
+ # <b>DEPRECATED:</b> Please provide <tt>in the request constructor hash param</tt> instead.
40
40
  # Supports BIN lengths of 6 digits or greater
41
41
  # @param lbin [String] Long Bank Identification Number
42
42
  def add_lbin(lbin)
43
+ warn "[DEPRECATION] LBIN should be provided in the constructor hash instead"
43
44
  params.merge!(LBIN: lbin)
44
45
  end
45
46
  end
@@ -1,82 +1,27 @@
1
- require 'digest/sha1'
2
1
  module Kount
3
- ##
4
- # This class implements the Kount KHASH for cards and gift cards.
5
-
6
2
  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
3
+
4
+ # <b>DEPRECATED:</b> This function should not be used. It duplicates the concerns of Kount::Inquiry.fixup_payment_params.
5
+ def self.hash_token(_plain_text, _ptyp, _ksalt, _merchant_id = '')
6
+ raise "do not use this function, prefer to use Kount::Inquiry.fixup_payment_params"
16
7
  end
17
8
 
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
9
+ # <b>DEPRECATED:</b> Use Kount::Khash.hash_payment_token instead.
32
10
  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}"
11
+ warn "[DEPRECATION] use Kount::Khash.hash_payment_token instead"
12
+ Kount::Khash.hash_payment_token(plain_text, ksalt)
37
13
  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
14
+
15
+ # <b>DEPRECATED:</b> Use Kount::Khash.hash_gift_card instead.
49
16
  def self.hash_gift_card(plain_text, ksalt, merchant_id)
50
- mashed = mash(plain_text, 14, ksalt)
51
- "#{merchant_id}#{mashed}"
17
+ warn "[DEPRECATION] use Kount::Khash.has_gift_card instead"
18
+ Kount::Khash.hash_gift_card(plain_text, ksalt, merchant_id)
52
19
  end
53
20
 
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
21
+ # <b>DEPRECATED:</b> Use Kount::Khash.hash_gift_card instead.
60
22
  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})/
23
+ warn "[DEPRECATION] use Kount::Khash.getkhash instead"
24
+ Kount::Khash.getkhash(data, len, m)
80
25
  end
81
- end # end KountSecurityMash
26
+ end
82
27
  end
@@ -1,21 +1,58 @@
1
1
  module Kount
2
- class Khash
2
+ module Khash
3
+ # Hash a PAN.
4
+ #
5
+ # Preserves first six characters of the input so that hashed cards can be
6
+ # categorized by Bank Identification Number (BIN).
7
+ #
8
+ # Example usage:
9
+ # hashed = Kount::Khash.hash_payment_token("4111111111111111", ksalt)
10
+ # Expect: 411111WMS5YA6FUZA1KC
11
+ #
3
12
  # @param plain_text [String] String to be hashed
4
- # @param ptyp [String] Payment type code: CARD, GIFT, or OTHER
13
+ # @param ksalt [String] The kount khash salt provided by Kount
14
+ #
5
15
  # @return [String] KHASH version of string
6
- def self.hash_token(plain_text, ptyp, ksalt, merchant_id = '')
7
- # changed if-else to case-when to follow ruby coding standard
16
+ def self.hash_payment_token(plain_text, ksalt)
17
+ return plain_text if khashed?(plain_text)
18
+ mashed = getkhash(plain_text, 14, ksalt)
19
+ "#{plain_text[0..5]}#{mashed}"
20
+ end
8
21
 
9
- case ptyp
10
- when 'CARD'
11
- HashPaymentToken(plain_text, ksalt)
12
- when 'CHEK'
13
- HashCheckPayment(plain_text, ksalt)
14
- else
15
- HashGiftCard(plain_text, ksalt, merchant_id)
16
- end
22
+ # <b>DEPRECATED:</b> Use Kount::Khash.hash_payment_token instead.
23
+ def self.hash_check_payment(plain_text, ksalt)
24
+ warn "[DEPRECATION] use Kount::Khash.hash_payment_token instead"
25
+ hash_payment_token(plain_text, ksalt)
17
26
  end
18
27
 
28
+ # Hash a gift card number.
29
+ #
30
+ # Use the six characters of the merchant id so that hashed cards can be
31
+ # unique across the entire domain.
32
+ #
33
+ # Example usage:
34
+ # hashed = Kount::SecurityMash.hash_gift_card("3245876", salt, "123456")
35
+ # Expect: 1234569HXH32Y5NNJCGB
36
+ #
37
+ # @param plain_text [String] String to be hashed
38
+ # @param ksalt [String] The kount khash salt provided by Kount
39
+ # @param merchant_id [String] The merchant id that will serve as the common domain of all gift
40
+ # cards
41
+ #
42
+ # @return [String] KHASH version of string
43
+ def self.hash_gift_card(plain_text, ksalt, merchant_id)
44
+ return plain_text if khashed?(plain_text)
45
+ mashed = getkhash(plain_text, 14, ksalt)
46
+ "#{merchant_id}#{mashed}"
47
+ end
48
+
49
+ # Compute a base64 hash of the provided data.
50
+ #
51
+ # @param data [String] Data to hash
52
+ # @param len [int] Length of hash to retain
53
+ # @param m [String] The kount khash salt
54
+ #
55
+ # @return [String] Hashed data
19
56
  def self.getkhash(data, len, m)
20
57
  a = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
21
58
  r = Digest::SHA1.hexdigest("#{data}.#{m}")
@@ -30,30 +67,10 @@ module Kount
30
67
  c
31
68
  end
32
69
 
33
- def self.hash_payment_token(plain_text, ksalt)
34
- return plain_text if khashed?(plain_text)
35
- first_six = plain_text[0..5]
36
- mashed = getkhash(plain_text, 14, ksalt)
37
- "#{first_six}#{mashed}"
38
- end
39
-
40
- def self.hash_check_payment(plain_text, ksalt)
41
- return plain_text if khashed?(plain_text)
42
- first_six = plain_text[0..5]
43
- mashed = getkhash(plain_text, 14, ksalt)
44
- "#{first_six}#{mashed}"
45
- end
46
-
47
- def self.hash_gift_card(plain_text, ksalt, merchant_id)
48
- mashed = getkhash(plain_text, 14, ksalt)
49
- "#{merchant_id}#{mashed}"
50
- end
51
-
52
70
  # @param val [String] Token that may or may not be khashed
53
71
  # @return [Boolean] True if token is already khashed
54
72
  def self.khashed?(val)
55
73
  true if val =~ /(\d{6}[A-Z0-9]{14})/
56
74
  end
57
-
58
75
  end
59
76
  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: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kount
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-08 00:00:00.000000000 Z
11
+ date: 2023-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  - !ruby/object:Gem::Version
81
81
  version: 1.3.5
82
82
  requirements: []
83
- rubygems_version: 3.2.32
83
+ rubygems_version: 3.2.33
84
84
  signing_key:
85
85
  specification_version: 4
86
86
  summary: Kount Complete Services Wrapper