调用工商二维码退款查询接口 这里使用main方法调用
特别说明 二维码退款成功 使用RSA 退款就用RSA
文档很坑直接写死RSA2
public class QrGenerateQueryTest { public static void main(String[] args) { String appId = "你公司的appid"; String privateKey = "私钥"; String icbcPulicKey = "公钥" //签名类型为RSA2时,需传入appid,私钥和网关公钥,签名类型使用定值IcbcConstants.SIGN_TYPE_RSA2,其他参数使用缺省值 DefaultIcbcClient client = new DefaultIcbcClient(appId, IcbcConstants.SIGN_TYPE_RSA, privateKey, icbcPulicKey); QrcodeRejectQueryRequestV4 request = new QrcodeRejectQueryRequestV4(); request.setServiceUrl("https://gw.open.icbc.com.cn/api/qrcode/reject/query/V4"); QrcodeRejectQueryRequestV4.QrcodeRejectQueryRequestV4Biz bizContent = new QrcodeRejectQueryRequestV4.QrcodeRejectQueryRequestV4Biz(); bizContent.setMerId("1******9"); // 商户线下档案编号(特约商户12位,特约部门15位) //bizContent.setCustId("1076dAbpBsrJXpI4J+/HXthaHj+mORib");//该字段非必输项 bizContent.setOutTradeNo("Z******6");//该字段非必输项,out_trade_no和order_id选一项上送即可 // bizContent.setOrderId("0*************1");//该字段非必输项,out_trade_no和order_id选一项上送即可 bizContent.setRejectNo("X000000001"); request.setBizContent(bizContent); QrcodeRejectQueryResponseV4 response; try { response = client.execute(request, "msgId"); if (response.isSuccess()) { // 业务成功处理 System.out.println("ReturnCode:" + response.getReturnCode()); System.out.println("response:" + response); } else { // 失败 System.out.println("失败"); System.out.println("ReturnCode:" + response.getReturnCode()); System.out.println("ReturnMsg:" + response.getReturnMsg()); } } catch (IcbcApiException e) { e.printStackTrace(); } } }
运行结果 returncode 0 就是成功