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"}
15 16 17 18 19 20 21 22 23 |
# File 'lib/kount/request/inquiry.rb', line 15 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) sdkVersionStructure = "Sdk-Ris-Ruby-" add_params(SDK: Kount::Config::SDK, SDK_VERSION: sdkVersionStructure + Kount::Config::SDK_VERSION) end |
Instance Attribute Details
#cart ⇒ Object
Returns the value of attribute cart.
7 8 9 |
# File 'lib/kount/request/inquiry.rb', line 7 def cart @cart end |
Instance Method Details
#add_cart(cart) ⇒ Object
Puts the cart object into the request for processing
70 71 72 |
# File 'lib/kount/request/inquiry.rb', line 70 def add_cart(cart) @cart = cart end |
#add_payment(type, token = '') ⇒ Object
Convenience method to create the payment params
84 85 86 |
# File 'lib/kount/request/inquiry.rb', line 84 def add_payment(type, token = '') add_params(PTYP: type, PTOK: token) end |
#add_udf(name, value) ⇒ Object
Add UDF to request
77 78 79 |
# File 'lib/kount/request/inquiry.rb', line 77 def add_udf(name, value) @params.merge!("UDF[#{name}]" => value) end |
#collect_cart_items ⇒ Object
Pulls the cart data into the request params hash
58 59 60 61 62 63 64 65 66 |
# File 'lib/kount/request/inquiry.rb', line 58 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
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/kount/request/inquiry.rb', line 40 def fixup_payment_params(ksalt, merchant_id) case params[:PTYP] when 'CARD' return if params[:PENC] == 'MASK' ptok = Kount::Khash.hash_payment_token(params[:PTOK], ksalt) params.merge!(PTOK: ptok, PENC: 'KHASH') when 'CHEK', 'PYPL' ptok = Kount::Khash.hash_payment_token(params[:PTOK], ksalt) params.merge!(PTOK: ptok, PENC: 'KHASH') when 'GIFT' ptok = Kount::Khash.hash_gift_card(params[:PTOK], ksalt, merchant_id) params.merge!(PTOK: ptok, PENC: 'KHASH') when 'NONE' params.merge!(PTOK: nil) end end |
#prepare_params(version, merchant_id, response_format, ksalt) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/kount/request/inquiry.rb', line 29 def prepare_params(version, merchant_id, response_format, ksalt) super(version, merchant_id, response_format, ksalt) 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) params end |