Class: Newebpay::QueryTrade::Search
- Inherits:
-
Object
- Object
- Newebpay::QueryTrade::Search
- Defined in:
- lib/newebpay/query_trade/search.rb
Constant Summary collapse
- REQUIRED_ATTRS =
%i[order_number price].freeze
Instance Attribute Summary collapse
-
#attrs ⇒ Object
Returns the value of attribute attrs.
-
#merchant_id ⇒ Object
Returns the value of attribute merchant_id.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #check_value ⇒ Object
- #check_value_raw ⇒ Object
-
#initialize(options) ⇒ Search
constructor
A new instance of Search.
- #version ⇒ Object
Constructor Details
#initialize(options) ⇒ Search
Returns a new instance of Search.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/newebpay/query_trade/search.rb', line 8 def initialize() check_valid() @attrs = {} @merchant_id = [:merchant_id] || Newebpay.config.merchant_id parse_attr() @attrs['Version'] = version @attrs['TimeStamp'] = Time.now.to_i @attrs['RespondType'] = 'JSON' @attrs['CheckValue'] = check_value result = HTTP.post(Newebpay.config.query_trade_url, form: attrs).body.to_s @response = Response.new(result) end |
Instance Attribute Details
#attrs ⇒ Object
Returns the value of attribute attrs.
6 7 8 |
# File 'lib/newebpay/query_trade/search.rb', line 6 def attrs @attrs end |
#merchant_id ⇒ Object
Returns the value of attribute merchant_id.
6 7 8 |
# File 'lib/newebpay/query_trade/search.rb', line 6 def merchant_id @merchant_id end |
#response ⇒ Object
Returns the value of attribute response.
6 7 8 |
# File 'lib/newebpay/query_trade/search.rb', line 6 def response @response end |
Instance Method Details
#check_value ⇒ Object
23 24 25 |
# File 'lib/newebpay/query_trade/search.rb', line 23 def check_value @check_value ||= Newebpay::NewebpayHelper.create_check_value(check_value_raw) end |
#check_value_raw ⇒ Object
27 28 29 |
# File 'lib/newebpay/query_trade/search.rb', line 27 def check_value_raw URI.encode_www_form(attrs.slice('Amt', 'MerchantID', 'MerchantOrderNo').sort) end |
#version ⇒ Object
31 32 33 |
# File 'lib/newebpay/query_trade/search.rb', line 31 def version '1.1' end |