rubycicd_uat 3.0.0 → 3.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.rb +31 -31
- data/lib/kount/Logs.log +497 -473
- data/lib/kount/Response.rb +344 -344
- data/lib/kount/cart.rb +36 -36
- data/lib/kount/client.rb +147 -147
- data/lib/kount/payment_types.rb +52 -52
- data/lib/kount/request.rb +50 -50
- data/lib/kount/request/inquiry.rb +90 -90
- data/lib/kount/request/update.rb +28 -28
- data/lib/kount/ris_inquiry.rb +73 -73
- data/lib/kount/security_mash.rb +82 -82
- data/lib/kount/utils/khash.rb +56 -56
- metadata +3 -3
data/lib/kount/cart.rb
CHANGED
@@ -1,36 +1,36 @@
|
|
1
|
-
module Kount
|
2
|
-
##
|
3
|
-
# This class handles cart data until the get_request is ready
|
4
|
-
# to push the data into the form fields
|
5
|
-
class Cart
|
6
|
-
attr_accessor :items
|
7
|
-
|
8
|
-
# Initialize cart object
|
9
|
-
def initialize
|
10
|
-
@items = []
|
11
|
-
end
|
12
|
-
|
13
|
-
# Add cart items
|
14
|
-
#
|
15
|
-
# @param item [String] Cart item name
|
16
|
-
# @param type [String] Cart type name
|
17
|
-
# @param desc [String] Cart item long description
|
18
|
-
# @param quant [String] Cart item quantity
|
19
|
-
# @param price [String] Cart item price in cents
|
20
|
-
def add_item(item, type, desc, quant, price)
|
21
|
-
@items << { TYPE: type,
|
22
|
-
DESC: desc,
|
23
|
-
ITEM: item,
|
24
|
-
QUANT: quant,
|
25
|
-
PRICE: price }
|
26
|
-
end
|
27
|
-
|
28
|
-
# Initialize an Inquiry object
|
29
|
-
#
|
30
|
-
# @param param [String] Param type: :TYPE, :DESC, :ITEM, :PRICE, or :QUANT
|
31
|
-
# @return [Array] Ordered array of the cart contents for each param type
|
32
|
-
def get_item(param)
|
33
|
-
@items.collect { |item| item[param] }
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
1
|
+
module Kount
|
2
|
+
##
|
3
|
+
# This class handles cart data until the get_request is ready
|
4
|
+
# to push the data into the form fields
|
5
|
+
class Cart
|
6
|
+
attr_accessor :items
|
7
|
+
|
8
|
+
# Initialize cart object
|
9
|
+
def initialize
|
10
|
+
@items = []
|
11
|
+
end
|
12
|
+
|
13
|
+
# Add cart items
|
14
|
+
#
|
15
|
+
# @param item [String] Cart item name
|
16
|
+
# @param type [String] Cart type name
|
17
|
+
# @param desc [String] Cart item long description
|
18
|
+
# @param quant [String] Cart item quantity
|
19
|
+
# @param price [String] Cart item price in cents
|
20
|
+
def add_item(item, type, desc, quant, price)
|
21
|
+
@items << { TYPE: type,
|
22
|
+
DESC: desc,
|
23
|
+
ITEM: item,
|
24
|
+
QUANT: quant,
|
25
|
+
PRICE: price }
|
26
|
+
end
|
27
|
+
|
28
|
+
# Initialize an Inquiry object
|
29
|
+
#
|
30
|
+
# @param param [String] Param type: :TYPE, :DESC, :ITEM, :PRICE, or :QUANT
|
31
|
+
# @return [Array] Ordered array of the cart contents for each param type
|
32
|
+
def get_item(param)
|
33
|
+
@items.collect { |item| item[param] }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/kount/client.rb
CHANGED
@@ -1,147 +1,147 @@
|
|
1
|
-
require 'kount/security_mash'
|
2
|
-
require 'kount/cart'
|
3
|
-
require 'kount/request'
|
4
|
-
require 'kount/request/update'
|
5
|
-
require 'kount/request/inquiry'
|
6
|
-
require 'rest-client'
|
7
|
-
require 'uri'
|
8
|
-
require 'kount/utils/khash'
|
9
|
-
require 'logger'
|
10
|
-
|
11
|
-
|
12
|
-
module Kount
|
13
|
-
##
|
14
|
-
# This class is where the primary interaction with
|
15
|
-
# the merchant integration will take place.
|
16
|
-
class Client
|
17
|
-
# Tells the RIS server to respond in JSON instead of key/value pairs
|
18
|
-
# This cannot be overridden.
|
19
|
-
RESPONSE_FORMAT = 'JSON'
|
20
|
-
|
21
|
-
# RIS Version. Can be overridden my merchant if required.
|
22
|
-
DEFAULT_VERSION = '0700'
|
23
|
-
|
24
|
-
# Default endpoint for production. Used by the DEFAULT_OPTIONS
|
25
|
-
ENDPOINT_PROD = 'https://risk.kount.net'
|
26
|
-
|
27
|
-
# Default endpoint for test. Used by the TEST_DEFAULT_OPTIONS
|
28
|
-
ENDPOINT_TEST = 'https://risk.test.kount.net'
|
29
|
-
|
30
|
-
# Default params for production
|
31
|
-
PROD_DEFAULT_OPTIONS = {
|
32
|
-
endpoint: ENDPOINT_PROD,
|
33
|
-
version: DEFAULT_VERSION,
|
34
|
-
is_test: false,
|
35
|
-
timeout: 10
|
36
|
-
}
|
37
|
-
|
38
|
-
# Default params for test if is_test is TRUE
|
39
|
-
TEST_DEFAULT_OPTIONS = {
|
40
|
-
endpoint: ENDPOINT_TEST,
|
41
|
-
version: DEFAULT_VERSION,
|
42
|
-
timeout: 10
|
43
|
-
}
|
44
|
-
|
45
|
-
# Initialize a client object
|
46
|
-
#
|
47
|
-
# Example usage
|
48
|
-
# {:merchant_id => "123456", :key => "trhvihsrihsta7ftadk6edkre7y8..."}
|
49
|
-
#
|
50
|
-
# @param params [Hash] Hash with merchant_id, ksalt and key, plus any
|
51
|
-
# other optional params
|
52
|
-
def initialize(params = {})
|
53
|
-
@logger = Logger.new("Logs.log")
|
54
|
-
@options = {}
|
55
|
-
if params[:is_test]
|
56
|
-
@options.merge!(TEST_DEFAULT_OPTIONS)
|
57
|
-
else
|
58
|
-
@options.merge!(PROD_DEFAULT_OPTIONS)
|
59
|
-
end
|
60
|
-
@options.merge!(params)
|
61
|
-
@logger.info("Options Params : #{@options}")
|
62
|
-
end
|
63
|
-
|
64
|
-
# Makes the call to the Kount RIS server
|
65
|
-
#
|
66
|
-
# @param request [Kount::Request] Kount inquiry or update object
|
67
|
-
# @return [Hash] RIS response formatted into a native hash
|
68
|
-
def get_response(request)
|
69
|
-
params = prepare_request_params(request)
|
70
|
-
response = {}
|
71
|
-
begin
|
72
|
-
response = RestClient::Resource.new(
|
73
|
-
endpoint,
|
74
|
-
verify_ssl: verify_ssl_option, timeout: timeout, log: @logger
|
75
|
-
).post params, x_kount_api_key: key
|
76
|
-
|
77
|
-
@logger.info("Response Object : #{JSON.parse(response)}")
|
78
|
-
JSON.parse(response)
|
79
|
-
rescue StandardError
|
80
|
-
# RIS errors do not come back as JSON, so just pass them along raw.
|
81
|
-
# @logger.error("Error : Network Timeout Getting #{response} Response.
|
82
|
-
# Your Timeout option valus is #{timeout},
|
83
|
-
# Use Default timeout which is 10 sec.")
|
84
|
-
if response.empty?
|
85
|
-
@logger.debug("Network Timeout Getting #{response} Response.
|
86
|
-
Current Timeout option valus is #{timeout},
|
87
|
-
Use Default timeout which is 10 sec.")
|
88
|
-
else
|
89
|
-
@logger.error("#{response}")
|
90
|
-
end
|
91
|
-
response
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
# Give the request object what it needs to know to process the params
|
96
|
-
# to send to RIS.
|
97
|
-
def prepare_request_params(request)
|
98
|
-
request.prepare_params(version, merchant_id, RESPONSE_FORMAT, ksalt)
|
99
|
-
end
|
100
|
-
|
101
|
-
# Kount Merchant ID
|
102
|
-
def merchant_id
|
103
|
-
@options[:merchant_id]
|
104
|
-
end
|
105
|
-
|
106
|
-
# RIS Interface Version
|
107
|
-
def version
|
108
|
-
@options[:version]
|
109
|
-
end
|
110
|
-
|
111
|
-
# RIS Endpoint URL
|
112
|
-
def endpoint
|
113
|
-
@options[:endpoint]
|
114
|
-
end
|
115
|
-
|
116
|
-
# Timeout settings
|
117
|
-
def timeout
|
118
|
-
@options[:timeout]
|
119
|
-
end
|
120
|
-
|
121
|
-
# Merchant API for RIS acess
|
122
|
-
def key
|
123
|
-
@options[:key]
|
124
|
-
end
|
125
|
-
|
126
|
-
# Secret Kount salt for KHASH
|
127
|
-
def ksalt
|
128
|
-
@options[:ksalt]
|
129
|
-
end
|
130
|
-
|
131
|
-
# Is test or production setting
|
132
|
-
def test?
|
133
|
-
@options[:is_test]
|
134
|
-
end
|
135
|
-
|
136
|
-
private
|
137
|
-
|
138
|
-
# Helper method to turn on/off the SSL cert verify based on is_test config
|
139
|
-
def verify_ssl_option
|
140
|
-
if test?
|
141
|
-
OpenSSL::SSL::VERIFY_NONE
|
142
|
-
else
|
143
|
-
OpenSSL::SSL::VERIFY_PEER
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
1
|
+
require 'kount/security_mash'
|
2
|
+
require 'kount/cart'
|
3
|
+
require 'kount/request'
|
4
|
+
require 'kount/request/update'
|
5
|
+
require 'kount/request/inquiry'
|
6
|
+
require 'rest-client'
|
7
|
+
require 'uri'
|
8
|
+
require 'kount/utils/khash'
|
9
|
+
require 'logger'
|
10
|
+
|
11
|
+
|
12
|
+
module Kount
|
13
|
+
##
|
14
|
+
# This class is where the primary interaction with
|
15
|
+
# the merchant integration will take place.
|
16
|
+
class Client
|
17
|
+
# Tells the RIS server to respond in JSON instead of key/value pairs
|
18
|
+
# This cannot be overridden.
|
19
|
+
RESPONSE_FORMAT = 'JSON'
|
20
|
+
|
21
|
+
# RIS Version. Can be overridden my merchant if required.
|
22
|
+
DEFAULT_VERSION = '0700'
|
23
|
+
|
24
|
+
# Default endpoint for production. Used by the DEFAULT_OPTIONS
|
25
|
+
ENDPOINT_PROD = 'https://risk.kount.net'
|
26
|
+
|
27
|
+
# Default endpoint for test. Used by the TEST_DEFAULT_OPTIONS
|
28
|
+
ENDPOINT_TEST = 'https://risk.test.kount.net'
|
29
|
+
|
30
|
+
# Default params for production
|
31
|
+
PROD_DEFAULT_OPTIONS = {
|
32
|
+
endpoint: ENDPOINT_PROD,
|
33
|
+
version: DEFAULT_VERSION,
|
34
|
+
is_test: false,
|
35
|
+
timeout: 10
|
36
|
+
}
|
37
|
+
|
38
|
+
# Default params for test if is_test is TRUE
|
39
|
+
TEST_DEFAULT_OPTIONS = {
|
40
|
+
endpoint: ENDPOINT_TEST,
|
41
|
+
version: DEFAULT_VERSION,
|
42
|
+
timeout: 10
|
43
|
+
}
|
44
|
+
|
45
|
+
# Initialize a client object
|
46
|
+
#
|
47
|
+
# Example usage
|
48
|
+
# {:merchant_id => "123456", :key => "trhvihsrihsta7ftadk6edkre7y8..."}
|
49
|
+
#
|
50
|
+
# @param params [Hash] Hash with merchant_id, ksalt and key, plus any
|
51
|
+
# other optional params
|
52
|
+
def initialize(params = {})
|
53
|
+
@logger = Logger.new("Logs.log")
|
54
|
+
@options = {}
|
55
|
+
if params[:is_test]
|
56
|
+
@options.merge!(TEST_DEFAULT_OPTIONS)
|
57
|
+
else
|
58
|
+
@options.merge!(PROD_DEFAULT_OPTIONS)
|
59
|
+
end
|
60
|
+
@options.merge!(params)
|
61
|
+
@logger.info("Options Params : #{@options}")
|
62
|
+
end
|
63
|
+
|
64
|
+
# Makes the call to the Kount RIS server
|
65
|
+
#
|
66
|
+
# @param request [Kount::Request] Kount inquiry or update object
|
67
|
+
# @return [Hash] RIS response formatted into a native hash
|
68
|
+
def get_response(request)
|
69
|
+
params = prepare_request_params(request)
|
70
|
+
response = {}
|
71
|
+
begin
|
72
|
+
response = RestClient::Resource.new(
|
73
|
+
endpoint,
|
74
|
+
verify_ssl: verify_ssl_option, timeout: timeout, log: @logger
|
75
|
+
).post params, x_kount_api_key: key
|
76
|
+
|
77
|
+
@logger.info("Response Object : #{JSON.parse(response)}")
|
78
|
+
JSON.parse(response)
|
79
|
+
rescue StandardError
|
80
|
+
# RIS errors do not come back as JSON, so just pass them along raw.
|
81
|
+
# @logger.error("Error : Network Timeout Getting #{response} Response.
|
82
|
+
# Your Timeout option valus is #{timeout},
|
83
|
+
# Use Default timeout which is 10 sec.")
|
84
|
+
if response.empty?
|
85
|
+
@logger.debug("Network Timeout Getting #{response} Response.
|
86
|
+
Current Timeout option valus is #{timeout},
|
87
|
+
Use Default timeout which is 10 sec.")
|
88
|
+
else
|
89
|
+
@logger.error("#{response}")
|
90
|
+
end
|
91
|
+
response
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
# Give the request object what it needs to know to process the params
|
96
|
+
# to send to RIS.
|
97
|
+
def prepare_request_params(request)
|
98
|
+
request.prepare_params(version, merchant_id, RESPONSE_FORMAT, ksalt)
|
99
|
+
end
|
100
|
+
|
101
|
+
# Kount Merchant ID
|
102
|
+
def merchant_id
|
103
|
+
@options[:merchant_id]
|
104
|
+
end
|
105
|
+
|
106
|
+
# RIS Interface Version
|
107
|
+
def version
|
108
|
+
@options[:version]
|
109
|
+
end
|
110
|
+
|
111
|
+
# RIS Endpoint URL
|
112
|
+
def endpoint
|
113
|
+
@options[:endpoint]
|
114
|
+
end
|
115
|
+
|
116
|
+
# Timeout settings
|
117
|
+
def timeout
|
118
|
+
@options[:timeout]
|
119
|
+
end
|
120
|
+
|
121
|
+
# Merchant API for RIS acess
|
122
|
+
def key
|
123
|
+
@options[:key]
|
124
|
+
end
|
125
|
+
|
126
|
+
# Secret Kount salt for KHASH
|
127
|
+
def ksalt
|
128
|
+
@options[:ksalt]
|
129
|
+
end
|
130
|
+
|
131
|
+
# Is test or production setting
|
132
|
+
def test?
|
133
|
+
@options[:is_test]
|
134
|
+
end
|
135
|
+
|
136
|
+
private
|
137
|
+
|
138
|
+
# Helper method to turn on/off the SSL cert verify based on is_test config
|
139
|
+
def verify_ssl_option
|
140
|
+
if test?
|
141
|
+
OpenSSL::SSL::VERIFY_NONE
|
142
|
+
else
|
143
|
+
OpenSSL::SSL::VERIFY_PEER
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
data/lib/kount/payment_types.rb
CHANGED
@@ -1,52 +1,52 @@
|
|
1
|
-
module Kount
|
2
|
-
##
|
3
|
-
# Convenience class to provide a list of PTYP values
|
4
|
-
class PaymentTypes
|
5
|
-
# Credit card (VISA, MasterCard, Amercian Express, etc)
|
6
|
-
CREDIT_CARD = 'CARD'
|
7
|
-
#Generic Token
|
8
|
-
TOKEN = 'TOKEN'
|
9
|
-
# PayPal
|
10
|
-
PAYPAL = 'PYPL'
|
11
|
-
# Check
|
12
|
-
CHECK = 'CHEK'
|
13
|
-
# Merchant issued gift card (not the ones with VISA/MC on them)
|
14
|
-
GIFT_CARD = 'GIFT'
|
15
|
-
# Carte Bleue
|
16
|
-
CARTE_BLEUE = 'CARTE_BLEUE'
|
17
|
-
# Sofort
|
18
|
-
SOFORT = 'SOFORT'
|
19
|
-
# Elv
|
20
|
-
ELV = 'ELV'
|
21
|
-
# Poli
|
22
|
-
POLI = 'POLI'
|
23
|
-
# Neteller
|
24
|
-
NETELLER = 'NETELLER'
|
25
|
-
# Giropay
|
26
|
-
GIROPAY = 'GIROPAY'
|
27
|
-
# BPay
|
28
|
-
BPAY = 'BPAY'
|
29
|
-
# Interac
|
30
|
-
INTERAC = 'INTERAC'
|
31
|
-
# Apple Pay
|
32
|
-
APPLE_PAY = 'APAY'
|
33
|
-
# Skrill
|
34
|
-
SKRILL = 'SKRILL'
|
35
|
-
# Moneybooker (basically another name for Skrill)
|
36
|
-
MONEYBOOKERS = 'SKRILL'
|
37
|
-
# Mercado Pago
|
38
|
-
MERCADO_PAGO = 'MERCADE_PAGO'
|
39
|
-
# Bill Me Later
|
40
|
-
BILL_ME_LATER = 'BLML'
|
41
|
-
# Google Checkout
|
42
|
-
GOOGLE_CHECKOUT = 'GOOG'
|
43
|
-
# Green Dot Money Pack
|
44
|
-
GREEN_DOT_MONEY_PACK = 'GDMP'
|
45
|
-
# Single Euro Payments Area
|
46
|
-
SINGLE_EURO_PAYMENTS_AREA = 'SEPA'
|
47
|
-
# None
|
48
|
-
NONE = 'NONE'
|
49
|
-
# Other
|
50
|
-
OTHER = 'OTHER'
|
51
|
-
end
|
52
|
-
end
|
1
|
+
module Kount
|
2
|
+
##
|
3
|
+
# Convenience class to provide a list of PTYP values
|
4
|
+
class PaymentTypes
|
5
|
+
# Credit card (VISA, MasterCard, Amercian Express, etc)
|
6
|
+
CREDIT_CARD = 'CARD'
|
7
|
+
#Generic Token
|
8
|
+
TOKEN = 'TOKEN'
|
9
|
+
# PayPal
|
10
|
+
PAYPAL = 'PYPL'
|
11
|
+
# Check
|
12
|
+
CHECK = 'CHEK'
|
13
|
+
# Merchant issued gift card (not the ones with VISA/MC on them)
|
14
|
+
GIFT_CARD = 'GIFT'
|
15
|
+
# Carte Bleue
|
16
|
+
CARTE_BLEUE = 'CARTE_BLEUE'
|
17
|
+
# Sofort
|
18
|
+
SOFORT = 'SOFORT'
|
19
|
+
# Elv
|
20
|
+
ELV = 'ELV'
|
21
|
+
# Poli
|
22
|
+
POLI = 'POLI'
|
23
|
+
# Neteller
|
24
|
+
NETELLER = 'NETELLER'
|
25
|
+
# Giropay
|
26
|
+
GIROPAY = 'GIROPAY'
|
27
|
+
# BPay
|
28
|
+
BPAY = 'BPAY'
|
29
|
+
# Interac
|
30
|
+
INTERAC = 'INTERAC'
|
31
|
+
# Apple Pay
|
32
|
+
APPLE_PAY = 'APAY'
|
33
|
+
# Skrill
|
34
|
+
SKRILL = 'SKRILL'
|
35
|
+
# Moneybooker (basically another name for Skrill)
|
36
|
+
MONEYBOOKERS = 'SKRILL'
|
37
|
+
# Mercado Pago
|
38
|
+
MERCADO_PAGO = 'MERCADE_PAGO'
|
39
|
+
# Bill Me Later
|
40
|
+
BILL_ME_LATER = 'BLML'
|
41
|
+
# Google Checkout
|
42
|
+
GOOGLE_CHECKOUT = 'GOOG'
|
43
|
+
# Green Dot Money Pack
|
44
|
+
GREEN_DOT_MONEY_PACK = 'GDMP'
|
45
|
+
# Single Euro Payments Area
|
46
|
+
SINGLE_EURO_PAYMENTS_AREA = 'SEPA'
|
47
|
+
# None
|
48
|
+
NONE = 'NONE'
|
49
|
+
# Other
|
50
|
+
OTHER = 'OTHER'
|
51
|
+
end
|
52
|
+
end
|