Module: JytPay::Api::AuthCard

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

Constant Summary

AUTH_CARD_TRAN_CODE =
"TR4003"

Instance Method Summary collapse

Instance Method Details

#auth_card(flow_id, card_id, true_name, identity_id, phone) ⇒ Hash

四要素认证

Parameters:

  • flow_id (String)

    订单号

  • card_id (String)

    银行卡号

  • true_name (String)

    真实姓名

  • identity_id (String)

    身份证

  • phone (String)

    银行卡预留手机号

Returns:

  • (Hash)

    结果集

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

    • :bank_name [String] 成功后会返回该卡在 jyt 系统内的中文名

    • :msg [String] 结果说明

    • :ret_code [String] 结果 CODE

    • :flow_id [String] 订单号

    • :request_body [String] 请求报文

    • :response_body [String] 响应报文



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

def auth_card(flow_id, card_id, true_name, identity_id, phone)

  params = {
    bank_card_no: card_id,
    id_num: identity_id,
    id_name: true_name,
    terminal_type: '01',
    bank_card_type: 'D',
    phone_no: phone,
  }

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

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

  res = {
    result: 'S0000000' == response[:head][:resp_code] ? 'S' : 'F',
    bank_name: response[:body][:bank_name],
    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
end