一、背景
上一篇我们介绍了支付回调接口的对接情况,当回调出现网络等异常情况,导致用户的支付订单未及时处理或处理失败的时候,商户则需要自己主动向浦发银行发起查询支付结果。
主动查询支付结果,发挥补偿重试的重要作用,在对接支付的流程中,是不可缺少的一个环节。
支付回调是被动接收“消息”,查询支付结果则是主动去获取“消息”。(这里的消息是指订单支付的结果通知)
共同点是:它们的业务逻辑处理相同,触发更新支付订单。
本文仅对主动查询支付结果的接口介绍,后文将要对接查询退款结果接口所使用的是同一个接口。支付和退款的处理逻辑大差不差,处理对象不同而已。(前者是支付订单,后者是退款订单)
二、流程图
三、接口说明
- 接口名称:对公收款交易查证
- 接口URI:/api/corporateAccounts/payments/status
- 调用方式:GET
- 必填的请求参数:
浦发银行官方提供的文档不准确,详细见下文。
-
- tranOrdrNo:实际是非必填参数,文档也即下面的截图不对,它和后面的mrchOrdrNo两者二选一的关系。
-
- mrchOrdrNo:平台支付流水号,它和上一个参数tranOrdrNo二者是二选一的关系。
-
- tranDate:必填参数,还是那句话,画蛇添足的一个字段。如果不传,则报错–“errInfo”: “输入交易日期不能为空”
-
- mrchId:商户号,必填参数
订正文档:tranOrdrNo和mrchOrdrNo的必填选项应该是C,表示某条件成立时必须填写的域。
- mrchId:商户号,必填参数
报文示例
- 请求报文
交易日期tranDate,是在发起支付请求接口中,和银行支付流水号tranOrdrNo一起保存在支付订单里。只因为它是必传参数,可是其他支付渠道并无此要求,所以我把tranDate保存在字段–支付成功时间payOkDate。
1、以平台支付流水号为依据发起主动查询(建议)
{"mrchId": "310319982990001",# 平台支付流水号"mrchOrdrNo": "0624041809544B0018534","tranDate": "20240418"
}
2、以浦发银行支付流水号为依据发起主动查询(文档说tranOrdrNo字段是必填,说法不对,这里再次提醒)
{"mrchId": "310319982990001",# 银行支付流水号"tranOrdrNo": "1901041809532900122081065712","tranDate": "20240418"
}
- 响应报文
并不会返回商户支付流水号!!!关键返回字段:{ “ordrSt”: “00”,
“tranAmt”: “0.01”,
“ordrSt”: “00”,
“tranTimep”: “20240418095400”,
“frmrMrchOrdrNo”: “1901041809532900122081065712” }
{"statusCode": "0000","transNo": "04972404186851005317430509","usrFlgId": "","isSbscrbFlg": "","usrChildFlg": "","isFlag": "","transAmt": "","busnPckt": "","clueDtl": "","totalAmt": "","ordrAmt": "","wthdrwnUsAmtCnl": "","retGdsAmt": "","rfdAmt": "","vcherNum": "","fundSource": "","inAcctName": "","rfndRlst": "","byrOfAlipayAcctNO": "","actRcvAmt": "","byrPayAmt": "","usPntsPayAmt": "","toUsEstbInvAmt": "","clientID": "","inrChlCnlNo": "","mrchStrNm": "","userId": "","addItInNal": "","infoDsc": "","fldData": "","bussRetCd": "","returnInfo": "","trdMerMechNo": "","weChatSubMechNo": "","errCode1": "","errInfo": "","terminalNo": "","tranType": "","ordrSt": "00","pyBnkInfo": "","cmdtyInfo": "","tranAmt": "0.01","ccy": "","thdPltfrmTm": "","thdPtySeq": "","tranOrdrNo": "","tranDate": "20240418","clrgDate": "","tranTimep": "20240418095400","mrchTm": "","bussLstNo": "","frmrMrchDate": "","frmrMrchOrdrNo": "1901041809532900122081065712","orgClrgDt": "","tranCode": "OOPY","mrchId": "310319982990001","openBrNo": "","instId": "","mrchDvlpmBnkNo": "","mrchDvlpmBnkBrId": "","strNo": "","cshrNo": "","mrchlInfmAdr": "","channelNo": "","hvWthdrwnAmt": "0.00","rfndblAmt": "0.01","hvThdChrgAmt": "","reserveAmt": "","chrgAmt": "","charges": "","prjPrdTp": "","ordrPcsSt": "","trdRtCd": "00","feeRtId": "","cmdtyDsc": "","crdType": "","bussTrm": "","thdPtyObjNo": "","remark1": "","remark2": "11","dcnRfdDtl": "","crtTm": "","cashRfndAmt": "","pblcAcctId": "","bussRetInfo": "","trdStInfo": "","bussStatusDsc": "","weRfndStatus": "","aLTrnCrc": "","pymtMd": "","dscntAmnt": "","mdsctAmnt": "","byUserType": "","acceptEndTime": "","pftSt": "","errCode2": "","byrRfndAmnt": "","dscntRfndAmnt": "","mdsctRfndAmnt": "","trdChnl": "","rsrvFld1": "","rsrvFld2": "","rsrvFld3": "","rsrvFld4": "","rsrvFld5": "","rsrvFld6": "","rsrvFld7": "","remark3": "","tranVrfyInfo": []
}
订单状态的字典
订单状态:
- 00-交易成功
- 01-交易失败
- 03-部分退货
- 04-全部退货
- 05-退货中
- 09-支付中
- 99-超时
四、总结
最后,说一说什么时候触发主动查询支付结果。
- 定时查询一定时间区间内,未支付成功的支付订单,主动询问第三方支付。
- 查询支付订单详情
- 关单前
可以说,作为支付回调的补偿功能,定期发起查询支付结果,在支付体验已经打折扣的情况下,大大减少用户的投诉,给你的支付系统挽回一定的口碑。