Class: CmbPay::SingleOrderMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/cmb_pay/message/single_order_message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(http_response) ⇒ SingleOrderMessage

Returns a new instance of SingleOrderMessage.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/cmb_pay/message/single_order_message.rb', line 17

def initialize(http_response)
  @raw_http_response = http_response
  return unless http_response.code == 200

  document_root = REXML::Document.new(http_response.body.to_s).root
  head = document_root.elements['Head']
  @code          = head.elements['Code'].text
  @error_message = head.elements['ErrMsg'].text
  return unless succeed?

  body = document_root.elements['Body']
  @bill_no       = body.elements['BillNo'].text
  @amount        = body.elements['Amount'].text
  @accept_date   = body.elements['AcceptDate'].text
  @accept_time   = body.elements['AcceptTime'].text
  @bill_amount   = body.elements['BillAmount'].text
  @status        = body.elements['Status'].text
  @card_type     = body.elements['CardType'].text
  @fee           = body.elements['Fee'].text
  @merchant_para = body.elements['MerchantPara'].text
  @card_no       = body.elements['CardNo'].text
  @bank_seq_no   = body.elements['BankSeqNo'].text
end

Instance Attribute Details

#accept_dateObject (readonly)

Returns the value of attribute accept_date.



5
6
7
# File 'lib/cmb_pay/message/single_order_message.rb', line 5

def accept_date
  @accept_date
end

#accept_timeObject (readonly)

Returns the value of attribute accept_time.



5
6
7
# File 'lib/cmb_pay/message/single_order_message.rb', line 5

def accept_time
  @accept_time
end

#amountObject (readonly)

Returns the value of attribute amount.



5
6
7
# File 'lib/cmb_pay/message/single_order_message.rb', line 5

def amount
  @amount
end

#bank_seq_noObject (readonly)

Returns the value of attribute bank_seq_no.



5
6
7
# File 'lib/cmb_pay/message/single_order_message.rb', line 5

def bank_seq_no
  @bank_seq_no
end

#bill_amountObject (readonly)

Returns the value of attribute bill_amount.



5
6
7
# File 'lib/cmb_pay/message/single_order_message.rb', line 5

def bill_amount
  @bill_amount
end

#bill_noObject (readonly)

Returns the value of attribute bill_no.



5
6
7
# File 'lib/cmb_pay/message/single_order_message.rb', line 5

def bill_no
  @bill_no
end

#card_noObject (readonly)

Returns the value of attribute card_no.



5
6
7
# File 'lib/cmb_pay/message/single_order_message.rb', line 5

def card_no
  @card_no
end

#card_typeObject (readonly)

Returns the value of attribute card_type.



5
6
7
# File 'lib/cmb_pay/message/single_order_message.rb', line 5

def card_type
  @card_type
end

#codeObject (readonly)

Returns the value of attribute code.



5
6
7
# File 'lib/cmb_pay/message/single_order_message.rb', line 5

def code
  @code
end

#error_messageObject (readonly)

Returns the value of attribute error_message.



5
6
7
# File 'lib/cmb_pay/message/single_order_message.rb', line 5

def error_message
  @error_message
end

#feeObject (readonly)

Returns the value of attribute fee.



5
6
7
# File 'lib/cmb_pay/message/single_order_message.rb', line 5

def fee
  @fee
end

#merchant_paraObject (readonly)

Returns the value of attribute merchant_para.



5
6
7
# File 'lib/cmb_pay/message/single_order_message.rb', line 5

def merchant_para
  @merchant_para
end

#raw_http_responseObject (readonly)

Returns the value of attribute raw_http_response.



5
6
7
# File 'lib/cmb_pay/message/single_order_message.rb', line 5

def raw_http_response
  @raw_http_response
end

#statusObject (readonly)

Returns the value of attribute status.



5
6
7
# File 'lib/cmb_pay/message/single_order_message.rb', line 5

def status
  @status
end

Instance Method Details

#succeed?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/cmb_pay/message/single_order_message.rb', line 41

def succeed?
  code.nil? && error_message.nil?
end