- 商户意愿确认-提交申请单API
上送: POST /v3/apply4subject/applyment 1584596389 KD0Lc6sByJxJ69IifmQcnkg4GFzbiHwN {"business_code":"1111111111","contact_info":{"name":"����","mobile":"13312345678","id_card_number":"430422199001236704"},"subject_info":{"subject_type":"SUBJECT_TYPE_ENTERPRISE","business_licence_info":{"licence_number":"914201123033363296","licence_copy":"333","merchant_name":"sss","legal_person":"ss","company_address":"ss","licence_valid_date":"1970-01-01"},"company_prove_copy":"33"},"identification_info":{"identification_type":"IDENTIFICATION_TYPE_IDCARD","identification_name":"ss","identification_number":"430422199001236705","identification_valid_date":"1970 - 01 - 01","identification_front_copy":"11","identification_back_copy":"323"}} 返回:{ "code": "SIGN_ERROR", "detail": { "detail": { "issue": "sign not match" }, "field": "signature", "location": "authorization", "sign_information": { "method": "POST", "sign_message_length": 78, "truncated_sign_message": "POST\n/v3/apply4subject/applyment\n1584596389\nKD0Lc6sByJxJ69IifmQcnkg4GFzbiHwN\n\n", "url": "/v3/apply4subject/applyment" } }, "message": "错误的签名,验签失败" } 请求发起是有body的,为什么微信返回的没有body,是空的,就像是没有上送body一样, 同样的json请求,图片上传是ok的, 参数也完全按照官网文档,编写的json串, 到底是哪出的问题??!!!!!!求解。
2020-03-19 - 微信商户开户意愿 -提交申请单API
1 图片上传post ok, 签名Ok,返回正常 2 提交申请单api,同样的方法拼装json,返回: {"code":"SIGN_ERROR","detail":{"detail":{"issue":"sign not match"},"field":"signature","location":"authorization","sign_information":{"method":"POST","sign_message_length":78,"truncated_sign_message":"POST\n/v3/apply4subject/applyment\n1584584235\nWQeqUDrJOmM073PJLJhk2T0B0jDmpNze\n\n","url":"/v3/apply4subject/applyment"}},"message":"错误的签名,验签失败"} 方法: public static String getAuthorization(String method, HttpUrl url, String body, PrivateKey yourPrivateKey, String yourMerchantId, String yourCertificateSerialNo) throws Exception { String nonceStr = generateNonceStr(); long timestamp = System.currentTimeMillis() / 1000; String message = buildMessage(method, url, timestamp, nonceStr, body); System.out.println("message===="+message); String signature = sign(message.getBytes("utf-8"),yourPrivateKey); System.out.println("SHA256withRSA签名是:"+signature); return schema+" "+"mchid=\"" + yourMerchantId + "\"," + "nonce_str=\"" + nonceStr + "\"," + "timestamp=\"" + timestamp + "\"," + "serial_no=\"" + yourCertificateSerialNo + "\"," + "signature=\"" + signature + "\""; } private static String buildMessage(String method, HttpUrl url, long timestamp, String nonceStr, String body) { String canonicalUrl = url.encodedPath(); if (url.encodedQuery() != null) { canonicalUrl += "?" + url.encodedQuery(); } return method + "\n" + canonicalUrl + "\n" + timestamp + "\n" + nonceStr + "\n" + body + "\n"; } private static String sign(byte[] message, PrivateKey yourPrivateKey) throws Exception { Signature sign = Signature.getInstance("SHA256withRSA"); sign.initSign(yourPrivateKey); sign.update(message); return Base64.getEncoder().encodeToString(sign.sign()); } message====打印信息为: message====POST /v3/apply4subject/applyment 1584584235 WQeqUDrJOmM073PJLJhk2T0B0jDmpNze {"business_code":"1111111111"} s所以 为什么官方返回的truncated_sign_message 标签 里在,签名是没有body的????!!!
2020-03-19