rubycicd_uat 3.0.2 → 3.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,50 +1,50 @@
1
- require 'kount/security_mash'
2
- require 'logger'
3
-
4
- module Kount
5
- ##
6
- # This class acts as an abstract class for each type of request.
7
- class Request
8
- attr_accessor :params
9
-
10
- # Initialize a Request object
11
- #
12
- # Example usage
13
- # Not used directly. Use Inquiry or Update instead.
14
- #
15
- # @param initial_params [Hash] Initial params for request
16
- def initialize(initial_params = {})
17
- @logger = Logger.new("Logs.log")
18
- raise "Cannot directly instantiate a #{self.class}." if
19
- self.class == Request
20
- @params = initial_params
21
- @logger.info("Request Objects : #{@params}")
22
- end
23
-
24
- # Add params to the current request object
25
- # @param hash [Hash] Hash of values to be added
26
- def add_params(hash)
27
- @params.merge!(hash)
28
- end
29
-
30
- # This method creates the final state of the params collection such that
31
- # it can be sent to RIS. Items that are specific to either the Inquiry
32
- # or Update calls are delegated to the prepare_params method in each
33
- # respective class.
34
- #
35
- # @param version [String] RIS version
36
- # @param merchant_id [String] Merchant ID
37
- # @param response_format [String] Response format (JSON)
38
- # @param _ksalt [String] Kount supplied secret salt for KHASH
39
- def prepare_params(version, merchant_id, response_format, _ksalt = '')
40
- # The KSALT is not used here, however, it is used in the corresponding
41
- # subclass prepare_params methods.
42
- if merchant_id == '' # Check if merchant_id is set or not
43
- @logger.debug("Merchant Id not set.")
44
- elsif version.empty? # Check VERSION is set or not
45
- @logger.debug("Version not set")
46
- end
47
- params.merge!(VERS: version, MERC: merchant_id, FRMT: response_format)
48
- end
49
- end
50
- end
1
+ require 'kount/security_mash'
2
+ require 'logger'
3
+
4
+ module Kount
5
+ ##
6
+ # This class acts as an abstract class for each type of request.
7
+ class Request
8
+ attr_accessor :params
9
+
10
+ # Initialize a Request object
11
+ #
12
+ # Example usage
13
+ # Not used directly. Use Inquiry or Update instead.
14
+ #
15
+ # @param initial_params [Hash] Initial params for request
16
+ def initialize(initial_params = {})
17
+ @logger = Logger.new("Logs.log")
18
+ raise "Cannot directly instantiate a #{self.class}." if
19
+ self.class == Request
20
+ @params = initial_params
21
+ @logger.info("Request Objects : #{@params}")
22
+ end
23
+
24
+ # Add params to the current request object
25
+ # @param hash [Hash] Hash of values to be added
26
+ def add_params(hash)
27
+ @params.merge!(hash)
28
+ end
29
+
30
+ # This method creates the final state of the params collection such that
31
+ # it can be sent to RIS. Items that are specific to either the Inquiry
32
+ # or Update calls are delegated to the prepare_params method in each
33
+ # respective class.
34
+ #
35
+ # @param version [String] RIS version
36
+ # @param merchant_id [String] Merchant ID
37
+ # @param response_format [String] Response format (JSON)
38
+ # @param _ksalt [String] Kount supplied secret salt for KHASH
39
+ def prepare_params(version, merchant_id, response_format, _ksalt = '')
40
+ # The KSALT is not used here, however, it is used in the corresponding
41
+ # subclass prepare_params methods.
42
+ if merchant_id == '' # Check if merchant_id is set or not
43
+ @logger.debug("Merchant Id not set.")
44
+ elsif version.empty? # Check VERSION is set or not
45
+ @logger.debug("Version not set")
46
+ end
47
+ params.merge!(VERS: version, MERC: merchant_id, FRMT: response_format)
48
+ end
49
+ end
50
+ end
@@ -1,90 +1,90 @@
1
- module Kount
2
- ##
3
- # This class extends the Request class.
4
- class Inquiry < Request
5
- attr_accessor :cart
6
-
7
- # Initialize an Inquiry 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
- @cart = Cart.new
16
- # We want Request to default to MODE Q unless a different mode has
17
- # been passed.
18
- add_params(MODE: 'Q') unless initial_params.key?(:MODE)
19
- end
20
-
21
- # @param version [String] RIS version
22
- # @param merchant_id [String] Merchant ID
23
- # @param response_format [String] Response format (JSON)
24
- # @param ksalt [String] Kount supplied secret salt for KHASH
25
- def prepare_params(version, merchant_id, response_format, ksalt)
26
- super(version, merchant_id, response_format, ksalt)
27
- begin
28
- params.merge! collect_cart_items
29
- # The Kount::Request has no knowledge of the KSALT or merchant_id, both
30
- # of which are needed for KHASH. Request form params have everything we
31
- # need at this point to do the KHASH if needed.
32
- fixup_payment_params(ksalt, merchant_id)
33
- end
34
- params
35
- end
36
-
37
- # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
38
- def fixup_payment_params(ksalt, merchant_id)
39
- ptok = params[:PTOK]
40
- case params[:PTYP]
41
- when 'CARD', 'TOKEN'
42
- #ptok = Kount::SecurityMash.hash_credit_card(ptok, ksalt)
43
- ptok = Kount::Khash.hash_payment_token(ptok, ksalt)
44
- params.merge!(PTOK: ptok, PENC: 'KHASH')
45
- when 'GIFT', 'OTHER'
46
- #ptok = Kount::SecurityMash.hash_gift_card(ptok, ksalt, merchant_id)
47
- ptok = Kount::Khash.hash_gift_card(ptok, ksalt, merchant_id)
48
- params.merge!(PTOK: ptok, PENC: 'KHASH')
49
- when 'CHEK', 'OTHER'
50
- ptok = Kount::Khash.hash_check_payment(ptok, ksalt)
51
- params.merge!(PTOK: ptok, PENC: 'KHASH')
52
- when 'NONE'
53
- params.merge!(PTOK: nil, PENC: nil)
54
- else
55
- params[:PENC] ||= 'NONE'
56
- end
57
- end
58
-
59
- # Pulls the cart data into the request params hash
60
- def collect_cart_items
61
- {
62
- PROD_TYPE: cart.get_item(:TYPE),
63
- PROD_DESC: cart.get_item(:DESC),
64
- PROD_ITEM: cart.get_item(:ITEM),
65
- PROD_PRICE: cart.get_item(:PRICE),
66
- PROD_QUANT: cart.get_item(:QUANT)
67
- }
68
- end
69
-
70
- # Puts the cart object into the request for processing
71
- # @param cart [Kount::Cart] Cart object
72
- def add_cart(cart)
73
- @cart = cart
74
- end
75
-
76
- # Add UDF to request
77
- # @param name [String] UDF label name
78
- # @param value [String] UDF value
79
- def add_udf(name, value)
80
- @params.merge!("UDF[#{name}]" => value)
81
- end
82
-
83
- # Convenience method to create the payment params
84
- # @param type [String] Payment type
85
- # @param token [String] Payment token
86
- def add_payment(type, token = '')
87
- add_params(PTYP: type, PTOK: token)
88
- end
89
- end
90
- end
1
+ module Kount
2
+ ##
3
+ # This class extends the Request class.
4
+ class Inquiry < Request
5
+ attr_accessor :cart
6
+
7
+ # Initialize an Inquiry 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
+ @cart = Cart.new
16
+ # We want Request to default to MODE Q unless a different mode has
17
+ # been passed.
18
+ add_params(MODE: 'Q') unless initial_params.key?(:MODE)
19
+ end
20
+
21
+ # @param version [String] RIS version
22
+ # @param merchant_id [String] Merchant ID
23
+ # @param response_format [String] Response format (JSON)
24
+ # @param ksalt [String] Kount supplied secret salt for KHASH
25
+ def prepare_params(version, merchant_id, response_format, ksalt)
26
+ super(version, merchant_id, response_format, ksalt)
27
+ begin
28
+ params.merge! collect_cart_items
29
+ # The Kount::Request has no knowledge of the KSALT or merchant_id, both
30
+ # of which are needed for KHASH. Request form params have everything we
31
+ # need at this point to do the KHASH if needed.
32
+ fixup_payment_params(ksalt, merchant_id)
33
+ end
34
+ params
35
+ end
36
+
37
+ # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
38
+ def fixup_payment_params(ksalt, merchant_id)
39
+ ptok = params[:PTOK]
40
+ case params[:PTYP]
41
+ when 'CARD', 'TOKEN'
42
+ #ptok = Kount::SecurityMash.hash_credit_card(ptok, ksalt)
43
+ ptok = Kount::Khash.hash_payment_token(ptok, ksalt)
44
+ params.merge!(PTOK: ptok, PENC: 'KHASH')
45
+ when 'GIFT', 'OTHER'
46
+ #ptok = Kount::SecurityMash.hash_gift_card(ptok, ksalt, merchant_id)
47
+ ptok = Kount::Khash.hash_gift_card(ptok, ksalt, merchant_id)
48
+ params.merge!(PTOK: ptok, PENC: 'KHASH')
49
+ when 'CHEK', 'OTHER'
50
+ ptok = Kount::Khash.hash_check_payment(ptok, ksalt)
51
+ params.merge!(PTOK: ptok, PENC: 'KHASH')
52
+ when 'NONE'
53
+ params.merge!(PTOK: nil, PENC: nil)
54
+ else
55
+ params[:PENC] ||= 'NONE'
56
+ end
57
+ end
58
+
59
+ # Pulls the cart data into the request params hash
60
+ def collect_cart_items
61
+ {
62
+ PROD_TYPE: cart.get_item(:TYPE),
63
+ PROD_DESC: cart.get_item(:DESC),
64
+ PROD_ITEM: cart.get_item(:ITEM),
65
+ PROD_PRICE: cart.get_item(:PRICE),
66
+ PROD_QUANT: cart.get_item(:QUANT)
67
+ }
68
+ end
69
+
70
+ # Puts the cart object into the request for processing
71
+ # @param cart [Kount::Cart] Cart object
72
+ def add_cart(cart)
73
+ @cart = cart
74
+ end
75
+
76
+ # Add UDF to request
77
+ # @param name [String] UDF label name
78
+ # @param value [String] UDF value
79
+ def add_udf(name, value)
80
+ @params.merge!("UDF[#{name}]" => value)
81
+ end
82
+
83
+ # Convenience method to create the payment params
84
+ # @param type [String] Payment type
85
+ # @param token [String] Payment token
86
+ def add_payment(type, token = '')
87
+ add_params(PTYP: type, PTOK: token)
88
+ end
89
+ end
90
+ end
@@ -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,73 +1,73 @@
1
- require 'kount'
2
- require_relative 'Response'
3
- require 'kount/utils/khash'
4
-
5
-
6
- class RisRequest
7
-
8
- options = {
9
- merchant_id: 900431, # required (6 digit number, assigned by Kount)
10
- key: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiI5MDA0MzEiLCJhdWQiOiJLb3VudC4xIiwiaWF0IjoxNTYzOTM4NjA2LCJzY3AiOnsia2EiOnRydWUsImtjIjp0cnVlLCJhcGkiOnRydWUsInJpcyI6dHJ1ZX19.WidWQkNcPeVRlBdu77cgsyQOSMRqzQHnzH3S70cnU38', #required (created in the AWC web app by merchant)
11
- ksalt: '1b^jIFD)e1@<ZKuH"A+?Ea`p+ATAo6@:Wee+EM+(FD5Z2/N<', #required (provided by Kount)
12
- is_test: true, # RIS endpoint is set to Kount Test Server setting
13
- timeout:3
14
- }
15
-
16
-
17
- client = Kount.new(options)
18
- inquiry = Kount::Inquiry.new(
19
- SITE: "DEFAULT",
20
- MACK: "Y",
21
- AUTH: "A",
22
- ORDR: "989898900",
23
- TOTL: "8240",
24
- EMAL: "test@example.com",
25
- MODE:'Q',
26
- ANID: "+380931234567",
27
- B2A1: "Street F",
28
- B2A2: "",
29
- B2CC: "US",
30
- B2CI: "LA",
31
- B2ST: "LA",
32
- B2PC: "",
33
- B2PN: "+380931234567",
34
- NAME: "Smith",
35
- S2A1: "Street A",
36
- S2A2: "",
37
- S2PC: "",
38
- S2PN: "+380931234567",
39
- S2CC: "US",
40
- S2CI: "LA",
41
- S2ST: "LA",
42
- PTYP: "CARD",
43
- PTOK: "123456XXXXXXXXXX3456",
44
- PENC: "MASK",
45
- CURR: "USD",
46
- IPAD: "192.168.0.1",
47
- SESS: "5qteg2qjenchtasga2ro3862cg"
48
- )
49
-
50
- $i=0
51
- $num=3
52
- # inquiryArr = Array.new
53
- while $i < $num do
54
- puts("Inside loop = #{$i}")
55
-
56
- inquiry.add_udf("PROMO",45678)
57
- cart = Kount::Cart.new()
58
- cart.add_item('32 inch LCD TV', 'Electronics', 'Television', '44', '1000')
59
- inquiry.add_cart(cart)
60
- # puts inquiry
61
- # inquiryList = Hash.new(inquiry)
62
- response = client.get_response(inquiry)
63
- puts response
64
- $i +=1
65
- end
66
- # inquiryArr = Array.new(inquiry)
67
- # puts inquiryList[5]
68
- # response = client.get_response(inquiryList)
69
- #puts response
70
- # ris = Response::Resp.new(response)
71
- # puts ris.get_mode()
72
- end
73
- RisRequest.new()
1
+ require 'kount'
2
+ require_relative 'Response'
3
+ require 'kount/utils/khash'
4
+
5
+
6
+ class RisRequest
7
+
8
+ options = {
9
+ merchant_id: 900431, # required (6 digit number, assigned by Kount)
10
+ key: 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiI5MDA0MzEiLCJhdWQiOiJLb3VudC4xIiwiaWF0IjoxNTYzOTM4NjA2LCJzY3AiOnsia2EiOnRydWUsImtjIjp0cnVlLCJhcGkiOnRydWUsInJpcyI6dHJ1ZX19.WidWQkNcPeVRlBdu77cgsyQOSMRqzQHnzH3S70cnU38', #required (created in the AWC web app by merchant)
11
+ ksalt: '1b^jIFD)e1@<ZKuH"A+?Ea`p+ATAo6@:Wee+EM+(FD5Z2/N<', #required (provided by Kount)
12
+ is_test: true, # RIS endpoint is set to Kount Test Server setting
13
+ timeout:3
14
+ }
15
+
16
+
17
+ client = Kount.new(options)
18
+ inquiry = Kount::Inquiry.new(
19
+ SITE: "DEFAULT",
20
+ MACK: "Y",
21
+ AUTH: "A",
22
+ ORDR: "989898900",
23
+ TOTL: "8240",
24
+ EMAL: "test@example.com",
25
+ MODE:'Q',
26
+ ANID: "+380931234567",
27
+ B2A1: "Street F",
28
+ B2A2: "",
29
+ B2CC: "US",
30
+ B2CI: "LA",
31
+ B2ST: "LA",
32
+ B2PC: "",
33
+ B2PN: "+380931234567",
34
+ NAME: "Smith",
35
+ S2A1: "Street A",
36
+ S2A2: "",
37
+ S2PC: "",
38
+ S2PN: "+380931234567",
39
+ S2CC: "US",
40
+ S2CI: "LA",
41
+ S2ST: "LA",
42
+ PTYP: "CARD",
43
+ PTOK: "123456XXXXXXXXXX3456",
44
+ PENC: "MASK",
45
+ CURR: "USD",
46
+ IPAD: "192.168.0.1",
47
+ SESS: "5qteg2qjenchtasga2ro3862cg"
48
+ )
49
+
50
+ $i=0
51
+ $num=3
52
+ # inquiryArr = Array.new
53
+ while $i < $num do
54
+ puts("Inside loop = #{$i}")
55
+
56
+ inquiry.add_udf("PROMO",45678)
57
+ cart = Kount::Cart.new()
58
+ cart.add_item('32 inch LCD TV', 'Electronics', 'Television', '44', '1000')
59
+ inquiry.add_cart(cart)
60
+ # puts inquiry
61
+ # inquiryList = Hash.new(inquiry)
62
+ response = client.get_response(inquiry)
63
+ puts response
64
+ $i +=1
65
+ end
66
+ # inquiryArr = Array.new(inquiry)
67
+ # puts inquiryList[5]
68
+ # response = client.get_response(inquiryList)
69
+ #puts response
70
+ # ris = Response::Resp.new(response)
71
+ # puts ris.get_mode()
72
+ end
73
+ RisRequest.new()