class Newebpay::CancelAuth::Response

Attributes

message[R]
status[R]

Public Class Methods

new(response_params) click to toggle source
# File lib/newebpay/cancel_auth/response.rb, line 7
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/cancel_auth/response.rb, line 34
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/cancel_auth/response.rb, line 30
def expected_check_code
  Newebpay::NewebpayHelper.create_check_code(check_data_raw)
end
success?() click to toggle source
# File lib/newebpay/cancel_auth/response.rb, line 22
def success?
  status == 'SUCCESS'
end
valid?() click to toggle source
# File lib/newebpay/cancel_auth/response.rb, line 26
def valid?
  check_code == expected_check_code
end