kount_complete 2.0.5 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kount/Response.rb +6 -5
- data/lib/kount/client.rb +1 -2
- data/lib/kount/config.rb +14 -0
- data/lib/kount/payment_types.rb +21 -23
- data/lib/kount/request/inquiry.rb +12 -12
- data/lib/kount/request.rb +9 -1
- data/lib/kount/security_mash.rb +15 -70
- data/lib/kount/utils/khash.rb +49 -32
- data/lib/kount.rb +1 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d823582c3fa9dd5d79479b52f4e45365efd72f24a840a0f1aefd3384d41ac44
|
4
|
+
data.tar.gz: d5b0a0664392c3f0cf40b7c10389d2e2425c342e16fd64ebd9a75b947395af43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba23c2a4b10d84e90debc567d6fabd7cfbf4befcadbefc09836d03dda914bb85cf13359bbd294b6ab5ed8ed430be0ee3ee87d437040b899b1fdd1e99f64f5263
|
7
|
+
data.tar.gz: 4be12537ebb05ff14d2cdcf5cb86d549bba92f6ffeae2b3d70926037eda688cec24504f1b1bf194f163be6ab3659080f5cc79e75f59501d8765b85ca88b92771
|
data/lib/kount/Response.rb
CHANGED
@@ -239,7 +239,7 @@ module Response
|
|
239
239
|
end
|
240
240
|
|
241
241
|
def get_secure_merchant_response
|
242
|
-
merchant_response = @paramlist['
|
242
|
+
merchant_response = @paramlist['THREE_DS_MERCHANT_RESPONSE'].to_s
|
243
243
|
return merchant_response unless merchant_response.empty?
|
244
244
|
end
|
245
245
|
|
@@ -327,14 +327,15 @@ module Response
|
|
327
327
|
@paramlist['ERROR_COUNT'].to_s
|
328
328
|
end
|
329
329
|
|
330
|
-
def
|
330
|
+
def get_errors
|
331
331
|
errors = []
|
332
|
-
error_count = get_error_count
|
333
|
-
(0..error_count
|
334
|
-
errors
|
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'
|
@@ -18,7 +17,7 @@ module Kount
|
|
18
17
|
RESPONSE_FORMAT = 'JSON'
|
19
18
|
|
20
19
|
# RIS Version. Can be overridden my merchant if required.
|
21
|
-
DEFAULT_VERSION = '
|
20
|
+
DEFAULT_VERSION = '0720'
|
22
21
|
|
23
22
|
# Default endpoint for production. Used by the DEFAULT_OPTIONS
|
24
23
|
ENDPOINT_PROD = 'https://risk.kount.net'
|
data/lib/kount/config.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
module Kount
|
2
|
+
# This class contains version specifications
|
3
|
+
class Config
|
4
|
+
|
5
|
+
# Which SDK is this
|
6
|
+
SDK = 'RUBY'
|
7
|
+
|
8
|
+
# SDK release version
|
9
|
+
# Set the sdk release version which will be used for git tagging in github
|
10
|
+
# This will be set by the build process
|
11
|
+
SDK_VERSION = '2.3.0'
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
data/lib/kount/payment_types.rb
CHANGED
@@ -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
|
6
|
+
CREDIT_CARD = 'CARD'
|
7
7
|
#Generic Token
|
8
|
-
TOKEN
|
8
|
+
TOKEN = 'TOKEN'
|
9
9
|
# PayPal
|
10
|
-
PAYPAL
|
10
|
+
PAYPAL = 'PYPL'
|
11
11
|
# Check
|
12
|
-
CHECK
|
12
|
+
CHECK = 'CHEK'
|
13
13
|
# Merchant issued gift card (not the ones with VISA/MC on them)
|
14
|
-
GIFT_CARD
|
14
|
+
GIFT_CARD = 'GIFT'
|
15
15
|
# Carte Bleue
|
16
|
-
CARTE_BLEUE
|
16
|
+
CARTE_BLEUE = 'CARTE_BLEUE'
|
17
17
|
# Sofort
|
18
|
-
SOFORT
|
18
|
+
SOFORT = 'SOFORT'
|
19
19
|
# Elv
|
20
|
-
ELV
|
20
|
+
ELV = 'ELV'
|
21
21
|
# Poli
|
22
|
-
POLI
|
22
|
+
POLI = 'POLI'
|
23
23
|
# Neteller
|
24
|
-
NETELLER
|
24
|
+
NETELLER = 'NETELLER'
|
25
25
|
# Giropay
|
26
|
-
GIROPAY
|
26
|
+
GIROPAY = 'GIROPAY'
|
27
27
|
# BPay
|
28
|
-
BPAY
|
28
|
+
BPAY = 'BPAY'
|
29
29
|
# Interac
|
30
|
-
INTERAC
|
30
|
+
INTERAC = 'INTERAC'
|
31
31
|
# Apple Pay
|
32
|
-
APPLE_PAY
|
32
|
+
APPLE_PAY = 'APAY'
|
33
33
|
# Skrill
|
34
|
-
SKRILL
|
34
|
+
SKRILL = 'SKRILL'
|
35
35
|
# Moneybooker (basically another name for Skrill)
|
36
|
-
MONEYBOOKERS
|
36
|
+
MONEYBOOKERS = 'SKRILL'
|
37
37
|
# Mercado Pago
|
38
|
-
MERCADO_PAGO
|
38
|
+
MERCADO_PAGO = 'MERCADE_PAGO'
|
39
39
|
# Bill Me Later
|
40
|
-
BILL_ME_LATER
|
40
|
+
BILL_ME_LATER = 'BLML'
|
41
41
|
# Google Checkout
|
42
|
-
GOOGLE_CHECKOUT
|
42
|
+
GOOGLE_CHECKOUT = 'GOOG'
|
43
43
|
# Green Dot Money Pack
|
44
|
-
GREEN_DOT_MONEY_PACK
|
44
|
+
GREEN_DOT_MONEY_PACK = 'GDMP'
|
45
45
|
# Single Euro Payments Area
|
46
46
|
SINGLE_EURO_PAYMENTS_AREA = 'SEPA'
|
47
47
|
# None
|
48
|
-
NONE
|
49
|
-
# Other
|
50
|
-
OTHER = 'OTHER'
|
48
|
+
NONE = 'NONE'
|
51
49
|
end
|
52
50
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require_relative '../config'
|
2
|
+
|
1
3
|
module Kount
|
2
4
|
##
|
3
5
|
# This class extends the Request class.
|
@@ -16,6 +18,8 @@ module Kount
|
|
16
18
|
# We want Request to default to MODE Q unless a different mode has
|
17
19
|
# been passed.
|
18
20
|
add_params(MODE: 'Q') unless initial_params.key?(:MODE)
|
21
|
+
sdkVersionStructure = "Sdk-Ris-Ruby-"
|
22
|
+
add_params(SDK: Kount::Config::SDK, SDK_VERSION: sdkVersionStructure + Kount::Config::SDK_VERSION)
|
19
23
|
end
|
20
24
|
|
21
25
|
# @param version [String] RIS version
|
@@ -34,23 +38,19 @@ module Kount
|
|
34
38
|
|
35
39
|
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
36
40
|
def fixup_payment_params(ksalt, merchant_id)
|
37
|
-
ptok = params[:PTOK]
|
38
41
|
case params[:PTYP]
|
39
|
-
when 'CARD'
|
40
|
-
|
41
|
-
ptok = Kount::Khash.hash_payment_token(
|
42
|
+
when 'CARD'
|
43
|
+
return if params[:PENC] == 'MASK'
|
44
|
+
ptok = Kount::Khash.hash_payment_token(params[:PTOK], ksalt)
|
42
45
|
params.merge!(PTOK: ptok, PENC: 'KHASH')
|
43
|
-
when '
|
44
|
-
|
45
|
-
ptok = Kount::Khash.hash_gift_card(ptok, ksalt, merchant_id)
|
46
|
+
when 'CHEK', 'PYPL'
|
47
|
+
ptok = Kount::Khash.hash_payment_token(params[:PTOK], ksalt)
|
46
48
|
params.merge!(PTOK: ptok, PENC: 'KHASH')
|
47
|
-
when '
|
48
|
-
ptok = Kount::Khash.
|
49
|
+
when 'GIFT'
|
50
|
+
ptok = Kount::Khash.hash_gift_card(params[:PTOK], ksalt, merchant_id)
|
49
51
|
params.merge!(PTOK: ptok, PENC: 'KHASH')
|
50
52
|
when 'NONE'
|
51
|
-
params.merge!(PTOK: nil
|
52
|
-
else
|
53
|
-
params[:PENC] ||= 'NONE'
|
53
|
+
params.merge!(PTOK: nil)
|
54
54
|
end
|
55
55
|
end
|
56
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.
|
@@ -35,5 +34,14 @@ module Kount
|
|
35
34
|
# subclass prepare_params methods.
|
36
35
|
params.merge!(VERS: version, MERC: merchant_id, FRMT: response_format)
|
37
36
|
end
|
37
|
+
|
38
|
+
# Add LBIN to request
|
39
|
+
# <b>DEPRECATED:</b> Please provide <tt>in the request constructor hash param</tt> instead.
|
40
|
+
# Supports BIN lengths of 6 digits or greater
|
41
|
+
# @param lbin [String] Long Bank Identification Number
|
42
|
+
def add_lbin(lbin)
|
43
|
+
warn "[DEPRECATION] LBIN should be provided in the constructor hash instead"
|
44
|
+
params.merge!(LBIN: lbin)
|
45
|
+
end
|
38
46
|
end
|
39
47
|
end
|
data/lib/kount/security_mash.rb
CHANGED
@@ -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
|
-
|
8
|
-
#
|
9
|
-
|
10
|
-
|
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
|
-
#
|
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
|
-
|
34
|
-
|
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
|
-
#
|
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
|
-
|
51
|
-
|
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
|
-
#
|
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
|
-
|
62
|
-
|
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
|
26
|
+
end
|
82
27
|
end
|
data/lib/kount/utils/khash.rb
CHANGED
@@ -1,21 +1,58 @@
|
|
1
1
|
module Kount
|
2
|
-
|
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
|
13
|
+
# @param ksalt [String] The kount khash salt provided by Kount
|
14
|
+
#
|
5
15
|
# @return [String] KHASH version of string
|
6
|
-
def self.
|
7
|
-
|
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
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
data/lib/kount.rb
CHANGED
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.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:
|
11
|
+
date: 2023-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -54,6 +54,7 @@ files:
|
|
54
54
|
- lib/kount/Response.rb
|
55
55
|
- lib/kount/cart.rb
|
56
56
|
- lib/kount/client.rb
|
57
|
+
- lib/kount/config.rb
|
57
58
|
- lib/kount/payment_types.rb
|
58
59
|
- lib/kount/request.rb
|
59
60
|
- lib/kount/request/inquiry.rb
|
@@ -79,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
80
|
- !ruby/object:Gem::Version
|
80
81
|
version: 1.3.5
|
81
82
|
requirements: []
|
82
|
-
rubygems_version: 3.
|
83
|
+
rubygems_version: 3.2.33
|
83
84
|
signing_key:
|
84
85
|
specification_version: 4
|
85
86
|
summary: Kount Complete Services Wrapper
|