/** * 代付签约接口 * * @param serialno * @param tDetail * @return */ public Response paySign(String serialno, TransDetail tDetail) { Request req = new Request(); RequestBody reqBody = new RequestBody(); RequestInfo reqInfo = new RequestInfo(); // info reqInfo.setTRX_CODE(TRX_CODE_300004); reqInfo.setVERSION("04"); reqInfo.setDATA_TYPE("2"); reqInfo.setUSER_NAME(username); reqInfo.setUSER_PASS(userpass); reqInfo.setREQ_SN(serialno); reqInfo.setSIGNED_MSG(""); req.setINFO(reqInfo); // body/sum TransSum tSum = new TransSum(); tSum.setMERCHANT_ID(merchantId); tSum.setTOTAL_ITEM(1); reqBody.setTRANS_SUM(tSum); // body/details List<TransDetail> tDetailList = new ArrayList<TransDetail>(); tDetailList.add(tDetail); reqBody.setTRANS_DETAIL(tDetailList); req.setBODY(reqBody); return send(req); }
/** * 批量代付接口 * * @param serialno * @param tDetailList * @return */ public Response payMoney(String serialno, List<TransDetail> tDetailList, String businessCode) { Request req = new Request(); RequestBody reqBody = new RequestBody(); RequestInfo reqInfo = new RequestInfo(); // info reqInfo.setTRX_CODE(TRX_CODE_100002); reqInfo.setVERSION("04"); reqInfo.setDATA_TYPE("2"); reqInfo.setUSER_NAME(username); reqInfo.setUSER_PASS(userpass); reqInfo.setREQ_SN(serialno); reqInfo.setSIGNED_MSG(""); req.setINFO(reqInfo); // body/sum int totalSum = 0; for (TransDetail tDetail : tDetailList) { totalSum += tDetail.getAMOUNT(); } TransSum tSum = new TransSum(); tSum.setBUSINESS_CODE(businessCode); tSum.setMERCHANT_ID(merchantId); tSum.setTOTAL_ITEM(tDetailList.size()); tSum.setTOTAL_SUM(totalSum); reqBody.setTRANS_SUM(tSum); // body/details reqBody.setTRANS_DETAIL(tDetailList); req.setBODY(reqBody); return send(req); }
/** * 交易结果查询(单笔) * * @param queryTrans * @return */ public Response queryTrans(QueryTrans queryTrans) { Request req = new Request(); RequestBody reqBody = new RequestBody(); RequestInfo reqInfo = new RequestInfo(); // info reqInfo.setTRX_CODE(TRX_CODE_200001); reqInfo.setVERSION("04"); reqInfo.setDATA_TYPE("2"); reqInfo.setUSER_NAME(username); reqInfo.setUSER_PASS(userpass); reqInfo.setREQ_SN(String.valueOf(System.currentTimeMillis())); reqInfo.setSIGNED_MSG(""); req.setINFO(reqInfo); // querytrans reqBody.setQUERY_TRANS(queryTrans); req.setBODY(reqBody); return send(req); }