Class: CcbConnectClient::PaymentDetailsQueryResponse

Inherits:
BaseResponse
  • Object
show all
Defined in:
lib/ccb_connect_client/models/payment_details_query_response.rb

Instance Attribute Summary collapse

Attributes inherited from BaseResponse

#request_sn, #return_code, #return_msg, #successful

Instance Method Summary collapse

Methods inherited from BaseResponse

from_xml

Constructor Details

#initializePaymentDetailsQueryResponse

Returns a new instance of PaymentDetailsQueryResponse.



10
11
12
# File 'lib/ccb_connect_client/models/payment_details_query_response.rb', line 10

def initialize
  super
end

Instance Attribute Details

#cur_pageObject

Returns the value of attribute cur_page.



8
9
10
# File 'lib/ccb_connect_client/models/payment_details_query_response.rb', line 8

def cur_page
  @cur_page
end

#cust_idObject

Returns the value of attribute cust_id.



8
9
10
# File 'lib/ccb_connect_client/models/payment_details_query_response.rb', line 8

def cust_id
  @cust_id
end

#languageObject

Returns the value of attribute language.



8
9
10
# File 'lib/ccb_connect_client/models/payment_details_query_response.rb', line 8

def language
  @language
end

#listObject

Returns the value of attribute list.



8
9
10
# File 'lib/ccb_connect_client/models/payment_details_query_response.rb', line 8

def list
  @list
end

#noticeObject

Returns the value of attribute notice.



8
9
10
# File 'lib/ccb_connect_client/models/payment_details_query_response.rb', line 8

def notice
  @notice
end

#page_countObject

Returns the value of attribute page_count.



8
9
10
# File 'lib/ccb_connect_client/models/payment_details_query_response.rb', line 8

def page_count
  @page_count
end

#tx_codeObject

Returns the value of attribute tx_code.



8
9
10
# File 'lib/ccb_connect_client/models/payment_details_query_response.rb', line 8

def tx_code
  @tx_code
end

Instance Method Details

#from_xml(xml) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/ccb_connect_client/models/payment_details_query_response.rb', line 14

def from_xml xml
  response = PaymentDetailsQueryResponse.new
  doc = Document.new(xml)
  # logger = Logger.new('foo.log', 'monthly')
  # logger.datetime_format = '%Y-%m-%d %H:%M:%S'

  if CcbConnectClient.debug_mode
    # logger.info("PaymentDetailsQueryResponse response xml: #{doc}")
    puts "PaymentDetailsQueryResponse response xml: #{doc}"
  end

  response.request_sn = doc.elements["TX/REQUEST_SN"].text
  response.cust_id = doc.elements["TX/CUST_ID"].text
  response.tx_code = doc.elements["TX/TX_CODE"].text
  response.return_code = doc.elements["TX/RETURN_CODE"].text
  response.return_msg = doc.elements["TX/RETURN_MSG"].text
  response.language = doc.elements["TX/LANGUAGE"].text
  # INFO
  response.cur_page = doc.elements["TX/TX_INFO/CUR_PAGE"].text
  response.page_count = doc.elements["TX/TX_INFO/PAGE_COUNT"].text
  response.list = Array.new
  # LIST
  doc.elements.each("TX/TX_INFO/LIST") { |e|
    response_element = PaymentDetailsQueryResponseElement.new
    response_element.tran_date = e.elements["TRAN_DATE"].text
    response_element.acc_date = e.elements["ACC_DATE"].text
    response_element.order = e.elements["ORDER"].text
    response_element. = e.elements["ACCOUNT"].text
    response_element.acc_name = e.elements["ACC_NAME"].text
    response_element.payment_money = e.elements["PAYMENT_MONEY"].text
    response_element.refund_money = e.elements["REFUND_MONEY"].text
    response_element.pos_id = e.elements["POS_ID"].text
    response_element.rem1 = e.elements["REM1"].text
    response_element.rem2 = e.elements["REM2"].text
    order_status = OrderStatus.new
    order_status.status = e.elements["ORDER_STATUS"].text
    case order_status.status
      when '0'
        order_status.status_name = "失败"
      when '1'
        order_status.status_name = "成功"
      when '2'
        order_status.status_name = "待银行确认"
      when '3'
        order_status.status_name = "已部分退款"
      when '4'
        order_status.status_name = "已全额退款"
      when '5'
        order_status.status_name = "待银行确认"
    end
    response_element.order_status = order_status
    response.list.push(response_element)
  }

  if CcbConnectClient.debug_mode
    # logger.info("PaymentDetailsQueryResponse response xml: #{doc}")
    puts "PaymentDetailsQueryResponse response object: #{response.inspect}"
  end
  response
end