1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
| public void icbcPay(HttpServletResponse response) { byte[] encCert = ReturnValue.base64enc(cert); String CertBase64 = new String(encCert); String reCert = FilesUtils.replace(CertBase64); byte[] encKey = ReturnValue.base64enc(key); String keyBase64 = new String(encKey); String reKey = FilesUtils.replace(keyBase64); UiIcbcClient client = new UiIcbcClient(appId, reKey, IcbcConstants.CHARSET_UTF8, reCert, password); B2cPcPayTransferRequestV1 requestApi = new B2cPcPayTransferRequestV1(); B2cPcPayTransferRequestV1.B2cPayTransferRequestV1Biz bizContent = new B2cPcPayTransferRequestV1.B2cPayTransferRequestV1Biz(); B2cPcPayTransferRequestV1.B2cPcPayTransferRequestV1OrderInfo orderInfo = new B2cPcPayTransferRequestV1.B2cPcPayTransferRequestV1OrderInfo(); B2cPcPayTransferRequestV1.B2cPcPayTransferRequestV1Custom custom = new B2cPcPayTransferRequestV1.B2cPcPayTransferRequestV1Custom(); B2cPcPayTransferRequestV1.B2cPcPayTransferRequestV1Message message = new B2cPcPayTransferRequestV1.B2cPcPayTransferRequestV1Message(); bizContent.setCustom(custom); bizContent.setOrderInfo(orderInfo); bizContent.setMessage(message); orderInfo.setMerID(merId); orderInfo.setMerAcct(merAcct); LocalDateTime time = LocalDateTime.now(); DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); orderInfo.setOrderDate(dtf.format(time)); orderInfo.setOrderId("No1234"); orderInfo.setAmount("100"); orderInfo.setInstallmentTimes("1"); orderInfo.setCurType("001"); custom.setVerifyJoinFlag("0"); custom.setLanguage("zh_CN"); message.setNotifyType("HS"); message.setOrderFlagZtb("0"); message.setResultType("0"); message.setCreditType("2"); message.setO2oMerId(""); message.setElifeMerId(""); message.setPayExpire("300"); message.setMerReference(merReference); message.setReturnUrl(returnUrl); message.setGoodsName(new BASE64Encoder().encode("payment".getBytes())); message.setGoodsType("0"); message.setMerHint("RFJQ"); message.setRemark1(""); message.setRemark2(""); message.setMerCustomIp(""); message.setMerCustomID("1"); message.setMerCustomPhone("18888888888"); message.setGoodsAddress(new BASE64Encoder().encode("none".getBytes())); message.setMerOrderRemark(new BASE64Encoder().encode("none".getBytes())); message.setAuto_refer_sec("5"); message.setBackup1(""); message.setBackup2(""); message.setBackup3(""); message.setBackup4(""); requestApi.setServiceUrl(payServiceUrl); requestApi.setNotifyUrl(notifyUrl); requestApi.setInterfaceName("ICBC_PERBANK_B2C"); requestApi.setInterfaceVersion("1.0.0.11"); requestApi.setBizContent(bizContent); System.out.println("工行支付请求参数为:" + JSONObject.toJSONString(requestApi)); PrintWriter out = null; try { response.setContentType("text/html;charset=utf-8"); out = response.getWriter(); String form = client.buildPostForm(requestApi); out.write("<html>"); out.write("<head>"); out.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" + "utf-8" + "\">"); out.write("</head>"); out.write("<body>"); out.write(form); out.write("</body>"); out.write("</html>"); } catch (Exception e) { e.printStackTrace(); } finally { assert out != null; out.flush(); out.close(); } }
|