Class: Focas::QueryTradeInfo
- Inherits:
-
Object
- Object
- Focas::QueryTradeInfo
- Defined in:
- lib/focas/query_trade_info.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#trade_info ⇒ Object
Returns the value of attribute trade_info.
Instance Method Summary collapse
-
#initialize(lidm: nil, purch_amt: nil, res_url: nil) ⇒ QueryTradeInfo
constructor
A new instance of QueryTradeInfo.
- #request! ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(lidm: nil, purch_amt: nil, res_url: nil) ⇒ QueryTradeInfo
Returns a new instance of QueryTradeInfo.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/focas/query_trade_info.rb', line 14 def initialize( lidm: nil, purch_amt: nil, res_url: nil ) unless lidm && purch_amt raise Focas::PaymentArgumentError, '請確認以下參數皆有填寫: - lidm - purch_amt ' end @lidm = lidm @purch_amt = purch_amt @res_url = res_url @xid = xid set_trade_info set_check_value end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
12 13 14 |
# File 'lib/focas/query_trade_info.rb', line 12 def response @response end |
#trade_info ⇒ Object
Returns the value of attribute trade_info.
11 12 13 |
# File 'lib/focas/query_trade_info.rb', line 11 def trade_info @trade_info end |
Instance Method Details
#request! ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/focas/query_trade_info.rb', line 36 def request! uri = URI("#{Config.api_base_url}/FOCAS_WEBPOS/orderInquery/") res = Net::HTTP.post_form(uri, merID: Config.[:merID], MerchantID: Config.[:MerchantID], TerminalID: Config.[:TerminalID], lidm: @lidm, purchAmt: @purch_amt, ResURL: @res_url, xid: @xid ) @response = JSON.parse(res.body) end |
#success? ⇒ Boolean
52 53 54 55 56 |
# File 'lib/focas/query_trade_info.rb', line 52 def success? return if @response.nil? @response['Status'] == 'SUCCESS' end |