Module: JytPay::Api::QueryOrder
- Included in:
- Client
- Defined in:
- lib/jyt_pay/api/query_order.rb
Constant Summary
- QUERY_PAY_TRAN_CODE =
"TC2001"
- QUERY_DRAW_TRAN_CODE =
"TC2002"
Instance Method Summary collapse
Instance Method Details
#query_order(flow_id, ori_flow_id, tran_type) ⇒ Hash
查询代付代收订单
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 |
# File 'lib/jyt_pay/api/query_order.rb', line 24 def query_order(flow_id, ori_flow_id, tran_type) case tran_type.to_sym when :pay server_uri = @uris[:pay] tran_code = QUERY_PAY_TRAN_CODE when :draw server_uri = @uris[:draw] tran_code = QUERY_DRAW_TRAN_CODE else raise 'unknow query tran code' end params = { ori_tran_flowid: ori_flow_id } xml_str = JytPay::Xml.generate(@merchant_id, tran_code, params, flow_id) response = Http.post(@merchant_id, server_uri, tran_code, xml_str, @rsa_private_key, @rsa_jyt_public_key) res = { result: 'P', # 默认 pending msg: response[:body][:tran_resp_desc] || response[:head][:resp_desc], ret_code: response[:body][:tran_resp_code] || response[:head][:resp_code], flow_id: flow_id, vendor_order_id: nil, # jyt 不会返回他们的订单号 request_body: xml_str, response_body: response[:xml_str], } return res if response[:body][:tran_resp_code].nil? res[:result] = case tran_type.to_sym when :pay Http::RetCode.pay_result(response[:body][:tran_resp_code], response[:body][:tran_state]) when :draw Http::RetCode.draw_result(response[:body][:tran_resp_code], response[:body][:tran_state]) end res end |