Class: Newebpay::MPG::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/newebpay/mpg/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response_params) ⇒ Response

Returns a new instance of Response.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/newebpay/mpg/response.rb', line 6

def initialize(response_params)
  raw_params = Newebpay::NewebpayHelper.decrypt_data(response_params)

  response_data = JSON.parse(raw_params)
  @status = response_data['Status']
  @message = response_data['Message']
  @trade_info = response_data['TradeInfo']
  @trade_sha = response_data['TradeSha']
  @result = response_data['Result']

  @result.each do |key, values|
    define_singleton_method(key.underscore) do
      values
    end
  end
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



5
6
7
# File 'lib/newebpay/mpg/response.rb', line 5

def message
  @message
end

#statusObject (readonly)

Returns the value of attribute status.



5
6
7
# File 'lib/newebpay/mpg/response.rb', line 5

def status
  @status
end

#trade_infoObject (readonly)

Returns the value of attribute trade_info.



5
6
7
# File 'lib/newebpay/mpg/response.rb', line 5

def trade_info
  @trade_info
end

#trade_shaObject (readonly)

Returns the value of attribute trade_sha.



5
6
7
# File 'lib/newebpay/mpg/response.rb', line 5

def trade_sha
  @trade_sha
end

Instance Method Details

#success?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/newebpay/mpg/response.rb', line 23

def success?
  status == 'SUCCESS'
end