Module: ChanPay::Api::WithholdPay
- Included in:
- Client
- Defined in:
- lib/chan_pay/api/withhold_pay.rb
Constant Summary collapse
- SERVICE_NAME =
'nmg_api_quickpay_withhold'
Instance Method Summary collapse
Instance Method Details
#withhold_pay(flow_id, card_id, identity_id, true_name, phone, money) ⇒ Hash
快捷代扣
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 |
# File 'lib/chan_pay/api/withhold_pay.rb', line 22 def withhold_pay(flow_id, card_id, identity_id, true_name, phone, money) params = { :TrxId => flow_id.to_s, # 最长 32 位唯一订单号 :OrdrName => '快捷充值', # 商品名称 :SellerId => @seller_id, # 畅捷提供的商户编号 :ExpiredTime => '90m', # 订单有效期 :BkAcctNo => card_id, # 卡号,需要 rsa 加密 :IDTp => '01', # 证件类型,01 身份证 :IDNo => identity_id, # 证件号,rsa 加密 :CstmrNm => true_name, # 持卡人姓名,rsa 加密 :MobNo => phone, # 银行预留手机号,rsa 加密 :TradeType => '11', # 交易类型(即时 11 担保 12) :TrxAmt => money.to_s, # 交易金额 # 'NotifyUrl' => '', # 异步通知地址,可空 # 'Extension' => '', # 扩展字段,可空 } # 这里是明文参数输出 puts "\n[#{SERVICE_NAME}] 请求参数为:\n#{params.inspect}" # 敏感字段加密 params[:BkAcctNo] = Encrypt::RSA.encrypt(@public_key, card_id) params[:IDNo] = Encrypt::RSA.encrypt(@public_key, identity_id) params[:CstmrNm] = Encrypt::RSA.encrypt(@public_key, true_name) params[:MobNo] = Encrypt::RSA.encrypt(@public_key, phone) response = Http.post(@partner_id, @private_key, @public_key, @server_uri, SERVICE_NAME, params) res = { result: 'P', # 默认 pending msg: response[:RetMsg], ret_code: response[:RetCode], flow_id: flow_id, vendor_order_id: response[:OrderTrxid], extension: response[:Extension], log: [params.to_json, response.to_json], } # 受理失败 || 受理成功但是结果失败 if response[:AcceptStatus] == 'F' || (response[:AcceptStatus] == 'S' && response[:Status] == 'F') res[:result] = 'F' end # 受理成功并且结果成功,才是成功 if response[:AcceptStatus] == 'S' && response[:Status] == 'S' res[:result] = 'S' end res end |