class Newebpay::QueryTrade::Response
Attributes
message[R]
status[R]
Public Class Methods
new(response_params)
click to toggle source
# File lib/newebpay/query_trade/response.rb, line 6 def initialize(response_params) response_data = JSON.parse(response_params) @status = response_data['Status'] @message = response_data['Message'] @result = response_data['Result'] @result.each do |key, values| define_singleton_method(key.underscore) do values end end end
Public Instance Methods
check_data_raw()
click to toggle source
# File lib/newebpay/query_trade/response.rb, line 31 def check_data_raw @check_data_raw ||= URI.encode_www_form(@result.slice('Amt', 'MerchantID', 'MerchantOrderNo', 'TradeNo').sort) end
expected_check_code()
click to toggle source
# File lib/newebpay/query_trade/response.rb, line 27 def expected_check_code Newebpay::NewebpayHelper.create_check_code(check_data_raw) end
success?()
click to toggle source
# File lib/newebpay/query_trade/response.rb, line 19 def success? status == 'SUCCESS' end
valid?()
click to toggle source
# File lib/newebpay/query_trade/response.rb, line 23 def valid? check_code == expected_check_code end