Module: JytPay::Api::QuickPay

Included in:
Client
Defined in:
lib/jyt_pay/api/quick_pay.rb

Constant Summary

QUICK_PAY_TRAN_CODE =
"TC1001"

Instance Method Summary collapse

Instance Method Details

#quick_pay(flow_id, money, bank_business_name, card_id, true_name, identity_id, phone) ⇒ Hash

单笔同步代付

Parameters:

  • flow_id (String)

    订单号

  • money (Float)

    代付金额(精确到2位)

  • bank_business_name (String)

    银行卡的中文名(在银行卡认证后有返回)

  • card_id (String)

    银行卡号

  • true_name (String)

    真实姓名

  • identity_id (String)

    身份证

  • phone (String)

    银行卡预留手机号

Returns:

  • (Hash)

    结果集

    • :result [String] 是否成功,`F`, `S`, `P`

    • :msg [String] 结果说明

    • :ret_code [String] 结果 CODE

    • :flow_id [String] 订单号

    • :request_body [String] 请求报文

    • :response_body [String] 响应报文



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
# File 'lib/jyt_pay/api/quick_pay.rb', line 27

def quick_pay(flow_id, money,
              bank_business_name, card_id,
              true_name, identity_id, phone)

  params = {
    mer_viral_acct: "",
    agrt_no: "",
    bank_name: bank_business_name,
    account_no: card_id,
    account_name: true_name,
    account_type: "00", #对私
    branch_bank_province: "",
    branch_bank_city: "",
    branch_bank_name: "",
    tran_amt: money, #两位小数
    currency: "CNY",
    bsn_code: "11203", #14900其他费用
    cert_type: "01",
    cert_no: identity_id,
    mobile: phone,
    remark: "",
    reserve: "",
  }

  xml_str = JytPay::Xml.generate(@merchant_id, QUICK_PAY_TRAN_CODE,
                                 params, flow_id)

  response = Http.post(@merchant_id, @uris[:pay],
                       QUICK_PAY_TRAN_CODE, xml_str,
                       @rsa_private_key, @rsa_jyt_public_key)

  res = {
    result: 'P', # 默认 pending
    msg: response[:head][:resp_desc],
    ret_code: response[:head][:resp_code],
    flow_id: flow_id,
    vendor_order_id: nil, # jyt 不会返回他们的订单号
    request_body: xml_str,
    response_body: response[:xml_str],
  }

  res[:result] = Http::RetCode.pay_result(response[:head][:resp_code],
                                          response[:body][:tran_state])

  res
end