【修改单据信息】
|应用场景
该接口只适用于修改已经审核失败的单据。
|接口说明
适用对象:从业机构
请求地址:https://api.mch.weixin.qq.com/v3/rate-activity/applications/id/{application_id}
请求方式:PATCH
接口规则:https://wechatpay-api.gitbook.io/wechatpay-api-v3
@Override
public WechatActivityResult updateDocumentInformation(UpdateDocumentInformationParamDTO updateDocumentInformationParamDTO) {
CloseableHttpClient build = null;
CloseableHttpResponse execute = null;
try {
logger.info("修改单据信息开始", updateDocumentInformationParamDTO);
String url;
if (null == updateDocumentInformationParamDTO.getApplication_id()) {
return new WechatActivityResult(WechatActivityResultEnum.MISSING_PARAMTER.getCode(), WechatActivityResultEnum.MISSING_PARAMTER.getMessage());
}
url = wechatQueryUrl + updateDocumentInformationParamDTO.getApplication_id();
JSONObject param = new JSONObject();
if (null != updateDocumentInformationParamDTO.getActivity_detail_modification()) {
param.put("activity_detail_modification", updateDocumentInformationParamDTO.getActivity_detail_modification());
}
if (null != updateDocumentInformationParamDTO.getAdditional_information()) {
param.put("additional_information", updateDocumentInformationParamDTO.getAdditional_information());
}
String paramStr = param.toJSONString();
String token = WeChatBaseUtil.getToken(paramStr, url, "PATCH", rsaPrivateKey, mchId, mchPrivateSerialNo);
url=baseUrl+url;
HttpPatch httpPatch = new HttpPatch(url);
httpPatch.addHeader("Charsert", "UTF-8");
httpPatch.addHeader("Accept", "application/json");
httpPatch.addHeader("Content-Type", "application/json");
httpPatch.addHeader("Authorization", "WECHATPAY2-SHA256-RSA2048 " + token);
httpPatch.addHeader("Wechatpay-Serial", WechantSerial);
StringEntity stringEntity = new StringEntity(paramStr);
httpPatch.setEntity(stringEntity);
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
build = httpClientBuilder.build();
execute = build.execute(httpPatch);
String result = EntityUtils.toString(execute.getEntity());
logger.info("修改单据信息成功");
return new WechatActivityResult(WechatActivityResultEnum.SUCCESS.getCode(), WechatActivityResultEnum.SUCCESS.getMessage(), result);
} catch (Exception e) {
logger.error("系统异常", e);
return new WechatActivityResult(WechatActivityResultEnum.SYSTEM_EXCEPTION.getCode(), WechatActivityResultEnum.SYSTEM_EXCEPTION.getMessage());
} finally {
closeStream(build, execute);
}
b报签名验证失败,麻烦帮忙看一下哪里有问题
请注意以下几点:
1) 签名与生成Authorization用的同一个时间戳跟随机串。
2) 构造签名串时,里面的url不需要ToLowCase(),不用UrlEncode(),商户请求的url后缀是什么,签名用的url后缀就是什么。
3) 查询订单使用的是GET,构建签名串时,里面用的请求报文为空(但是那个换行符还是要有哈)。
4)检查证书和商户号是否正确,如是服务商模式,需使用服务商的相关证书。
更多签名相关内容可以查看这里:
https://wechatpay-api.gitbook.io/wechatpay-api-v3/chang-jian-wen-ti/qian-ming-xiang-guan#ru-he-ding-wei-cuo-wu-de-qian-ming-dao-zhi-yan-qian-shi-bai-de-cuo-wu
你也可以下载验证工具来验证:https://pay.weixin.qq.com/wiki/doc/apiv3/wechatpay/download/Product_5.zip