- /v3/papay/contracts/*/notify 我都签约了,为什么报模板不是周期扣费类型?
IJPayHttpResponse{body='{"code":"INVALID_REQUEST","message":"当前签约的模板不是周期扣费类型,不能下发扣费前通知"}', status=400, headers={Keep-Alive=[timeout=8], null=[HTTP/1.1 400 Bad Request], Wechatpay-Timestamp=[*], Server=[nginx], X-Content-Type-Options=[nosniff], Connection=[keep-alive], Date=[Fri, 24 Jul 2020 09:40:06 GMT], Wechatpay-Serial=[*], Wechatpay-Nonce=[*], Wechatpay-Signature=[*], Cache-Control=[no-cache, must-revalidate], Content-Length=[114], Content-Language=[zh-CN], Request-ID=[g4pgjj], Content-Type=[application/json; charset=utf-8]}}
2020-07-24 - H5纯签约 根据文档拼接得url 请求是空白页面?
public String wxH5Sign(String merNo, String pkgCode, String plan_id,String contractOuterid, RequestHandler requestHandler, String returnUrl, String clientip) { try { List<ConfigEntity> configEntityList = configService.findList(merNo, pkgCode); MainEntity merchantMainEntity = mainService.find(configEntityList.get(0).getProviderCode(), configEntityList.get(0).getMainNo()); WxMerchantEntity wxMerchantEntity = wxMerchantService.queryWxMerchantInfo(merchantMainEntity.getMainNo()); String appid = wxMerchantEntity.getAppId(); String mch_id = wxMerchantEntity.getPartner(); String contract_code = orderNoService.getContractCode(); String request_serial = orderNoService.getRequestSerial(); String contract_display_account = "正隆保险"; String orderNo = orderNoService.getOrderNo(); String notify_url = "https://testpp.bxlsj.com/sign/wechat/callback/" + orderNo; String version = "1.0"; String timestamp = String.valueOf(System.currentTimeMillis() / 1000); SortedMap<String, String> packageParams = new TreeMap<>(); packageParams.put("appid", appid); packageParams.put("mch_id", mch_id); packageParams.put("plan_id", plan_id); packageParams.put("contract_code", contract_code); packageParams.put("request_serial", request_serial); packageParams.put("contract_display_account", contract_display_account); packageParams.put("notify_url", notify_url); packageParams.put("version", version); packageParams.put("timestamp", timestamp); packageParams.put("clientip", clientip); packageParams.put("outerid", contractOuterid); requestHandler.init(appid, wxMerchantEntity.getAppsecret(), wxMerchantEntity.getPartnerkey()); String sign = requestHandler.createHmacSign(packageParams); notify_url = URLEncoder.encode(notify_url); String url = "https://api.mch.weixin.qq.com/papay/h5entrustweb?appid=" + appid + "&contract_code=" + contract_code + "&contract_display_account=" + contract_display_account + "&mch_id=" + mch_id + "¬ify_url=" + notify_url + "&plan_id=" + plan_id + "&request_serial=" + request_serial + "&clientip=" + clientip + "×tamp=" + timestamp + "&version=" + version + "&sign=" + sign+"&outerid="+contractOuterid; log.info("wxH5Sign H5纯签约 merNo:[{}],pkgCode:[{}] url[{}]", merNo, pkgCode, url); return url; } catch (Exception e) { log.error("wxH5Sign H5纯签约 merNo:[{}],pkgCode:[{}] clientip[{}]", merNo, pkgCode, clientip); } return null; } /** * 创建HmacSHA256摘要,规则是:按参数名称a-z排序,遇到空值的参数不参加签名。 */ public String createHmacSign(SortedMap<String, String> packageParams) throws Exception { StringBuffer sb = new StringBuffer(); Set es = packageParams.entrySet(); Iterator it = es.iterator(); while (it.hasNext()) { Map.Entry entry = (Map.Entry) it.next(); String k = (String) entry.getKey(); String v = (String) entry.getValue(); if (null != v && !"".equals(v) && !"sign".equals(k) && !"key".equals(k)) { sb.append(k + "=" + v + "&"); } } //sb.append("key=" + this.getKey()); return WXPayUtil.HMACSHA256(sb.toString(),this.key); } /** * 生成 HMACSHA256 * * @param data 待处理数据 * @param key 密钥 * @return 加密结果 * @throws Exception */ public static String HMACSHA256(String data, String key) throws Exception { Mac sha256_HMAC = Mac.getInstance("HmacSHA256"); SecretKeySpec secret_key = new SecretKeySpec(key.getBytes("UTF-8"), "HmacSHA256"); sha256_HMAC.init(secret_key); byte[] array = sha256_HMAC.doFinal(data.getBytes("UTF-8")); StringBuilder sb = new StringBuilder(); for (byte item : array) { sb.append(Integer.toHexString((item & 0xFF) | 0x100).substring(1, 3)); } return sb.toString().toUpperCase(); }
2020-05-14