Class: Kount::Inquiry
Overview
This class extends the Request class.
Instance Attribute Summary collapse
-
#cart ⇒ Object
Returns the value of attribute cart.
Attributes inherited from Request
Instance Method Summary collapse
-
#add_cart(cart) ⇒ Object
Puts the cart object into the request for processing.
-
#add_payment(type, token = '') ⇒ Object
Convenience method to create the payment params.
-
#add_udf(name, value) ⇒ Object
Add UDF to request.
-
#collect_cart_items ⇒ Object
Pulls the cart data into the request params hash.
-
#fixup_payment_params(ksalt, merchant_id) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength.
-
#initialize(initial_params = {}) ⇒ Inquiry
constructor
Initialize an Inquiry object.
- #prepare_params(version, merchant_id, response_format, ksalt) ⇒ Object
Methods inherited from Request
Constructor Details
#initialize(initial_params = {}) ⇒ Inquiry
Initialize an Inquiry object
Example usage
{:MACK => "Y", :AUTH => "A"}
13 14 15 16 17 18 19 |
# File 'lib/kount/request/inquiry.rb', line 13 def initialize(initial_params = {}) super(initial_params) @cart = Cart.new # We want Request to default to MODE Q unless a different mode has # been passed. add_params(MODE: 'Q') unless initial_params.key?(:MODE) end |
Instance Attribute Details
#cart ⇒ Object
Returns the value of attribute cart.
5 6 7 |
# File 'lib/kount/request/inquiry.rb', line 5 def cart @cart end |
Instance Method Details
#add_cart(cart) ⇒ Object
Puts the cart object into the request for processing
72 73 74 |
# File 'lib/kount/request/inquiry.rb', line 72 def add_cart(cart) @cart = cart end |
#add_payment(type, token = '') ⇒ Object
Convenience method to create the payment params
86 87 88 |
# File 'lib/kount/request/inquiry.rb', line 86 def add_payment(type, token = '') add_params(PTYP: type, PTOK: token) end |
#add_udf(name, value) ⇒ Object
Add UDF to request
79 80 81 |
# File 'lib/kount/request/inquiry.rb', line 79 def add_udf(name, value) @params.merge!("UDF[#{name}]" => value) end |
#collect_cart_items ⇒ Object
Pulls the cart data into the request params hash
60 61 62 63 64 65 66 67 68 |
# File 'lib/kount/request/inquiry.rb', line 60 def collect_cart_items { PROD_TYPE: cart.get_item(:TYPE), PROD_DESC: cart.get_item(:DESC), PROD_ITEM: cart.get_item(:ITEM), PROD_PRICE: cart.get_item(:PRICE), PROD_QUANT: cart.get_item(:QUANT) } end |
#fixup_payment_params(ksalt, merchant_id) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/kount/request/inquiry.rb', line 38 def fixup_payment_params(ksalt, merchant_id) ptok = params[:PTOK] case params[:PTYP] when 'CARD', 'TOKEN' #ptok = Kount::SecurityMash.hash_credit_card(ptok, ksalt) ptok = Kount::Khash.hash_payment_token(ptok, ksalt) params.merge!(PTOK: ptok, PENC: 'KHASH') when 'GIFT', 'OTHER' #ptok = Kount::SecurityMash.hash_gift_card(ptok, ksalt, merchant_id) ptok = Kount::Khash.hash_gift_card(ptok, ksalt, merchant_id) params.merge!(PTOK: ptok, PENC: 'KHASH') when 'CHEK', 'OTHER' ptok = Kount::Khash.hash_check_payment(ptok, ksalt) params.merge!(PTOK: ptok, PENC: 'KHASH') when 'NONE' params.merge!(PTOK: nil, PENC: nil) else params[:PENC] ||= 'NONE' end end |
#prepare_params(version, merchant_id, response_format, ksalt) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/kount/request/inquiry.rb', line 25 def prepare_params(version, merchant_id, response_format, ksalt) super(version, merchant_id, response_format, ksalt) begin params.merge! collect_cart_items # The Kount::Request has no knowledge of the KSALT or merchant_id, both # of which are needed for KHASH. Request form params have everything we # need at this point to do the KHASH if needed. fixup_payment_params(ksalt, merchant_id) end params end |