开发指引
更新时间:2024.11.291. 接口规则
为了在保证支付安全的前提下,带给商户简单、一致且易用的开发体验,我们推出了全新的微信支付APIv3接口。该版本API的具体规则请参考APIv3接口规则。
2. 开发准备
2.1. 搭建和配置开发环境
开发者应当依据自身的编程语言来构建并配置相应的开发环境。
3. 快速接入
3.1. 业务流程图
业务流程时序图
申请单状态变化如下
重点步骤说明:
步骤3 商户入驻,服务商收集商户资料后,调用提交申请单接口,提交创建入驻申请单。
步骤5 创建申请单后,可通过查询申请单状态接口,获取特约商户签约链接,让商户扫码确认联系信息,后续申请单进度可通过公众号自动通知超级管理员(简称超管)。
3.2. API接入(含示例代码)
文档展示了如何使用微信支付服务端 SDK 快速接入支付有礼,完成与微信支付对接的部分。
|
3.2.1. 【服务端】提交申请单
步骤说明:服务商收集商户资料后,调用提交申请单接口,提交创建入驻申请单。
JAVA
1public void ApplymentSubMch() throws Exception { 2 //请求URL 3 HttpPost httpPost = new HttpPost("https://api.mch.weixin.qq.com/v3/applyment4sub/applyment/"); 4 // 请求body参数 5 String reqdata = "{" 6 + "\"business_info\": {" 7 + "\"merchant_shortname\":\"上海XXX有限公司\"," 8 + "\"service_phone\":\"139XXXX\"," 9 + "\"sales_info\": {" 10 + "\"mini_program_info\": {" 11 + "\"mini_program_pics\": [" 12 + "\"0\":\"F8O5MNAOlYZyxZcLnWXkyk72coZ3CVX3XobPZng-xepKPTrcH_XMfrGGYLi1XFogMG9P25LSUX6gjXU5iPI74YqiRUDfORyw2d76wK3vzuQ\"" 13 + "]," 14 + "\"mini_program_sub_appid\":\"wx76c3f74c108876c2\"" 15 + "}," 16 + "\"mp_info\": {" 17 + "\"mp_pics\": [" 18 + "\"0\":\"F8O5MNAOlYZyxZcLnWXkys5TBxf0dyfesnyfNuquBMArHRfgCq8hDRdscDpblCcEgvgV5MkVch9IBEX7aatZCmI8k5Wdb_M8a4bYcmlg6V8\"" 19 + "]," 20 + "\"mp_sub_appid\":\"wx85c88c63bd22651f\"" 21 + "}," 22 + "\"sales_scenes_type\": [" 23 + "\"0\":\"SALES_SCENES_MP\"," 24 + "\"1\":\"SALES_SCENES_MINI_PROGRAM\"" 25 + "]" 26 + "}" 27 + "}," 28 + "\"subject_info\": {" 29 + "\"business_license_info\": {" 30 + "\"legal_person\":\"江XX\"," 31 + "\"license_copy\":\"F8O5MNAOlYZyxZcLnWXkysZ5xo8fE3SHJ1pHUe6OJKmNIWtqUVyv4aY2-JLTgjDOSovWaKkBu3AbkjGuQXhesDzREu2pT_Yf_hxlFKPJMwQ\"," 32 + "\"merchant_name\":\"上海XXX有限公司\"," 33 + "\"license_number\":\"91310118MA1JXXXX\"" 34 + "}," 35 + "\"subject_type\":\"SUBJECT_TYPE_ENTERPRISE\"," 36 + "\"identity_info\": {" 37 + "\"owner\":true," 38 + "\"id_doc_type\":\"IDENTIFICATION_TYPE_IDCARD\"," 39 + "\"id_card_info\": {" 40 + "\"id_card_copy\":\"F8O5MNAOlYZyxZcLnWXkyvLpqoz7MNRULxju0NqUCtLGBl_vm8Bhj9uAyuLyDART9UsA10spF9gbT3DEoM85HxPQOhMuilK0zLtOxAjPx58\"," 41 + "\"card_period_end\":\"2035-12-28\"," 42 + "\"card_period_begin\":\"2015-12-28\"," 43 + "\"id_card_name\":\"JRMJGA7B7oSVS+krFeaQn4AvYZE2LL9tTwA+XXa9lYJU4AhS+Qheb7fhgo+D+hfa0v+ykU1BVvVo7NpCfgOYQqmYDyYF27Q/p4hB7IoqZLhJUE+hTG45VNoa9ASaKG79Hg+eGz4YTIHFGMFm1ljyg4fd5lGJixCqn38/gCfwm5x6vDOMVkFpqbUdR7klQwReGoG7iSlEpr4gZPqzItcBHiuXidMToKZTX1Lol1Lx52DHk0blcdh1CMRhv+wxQzF0lJMy/WtVyjKuB8daDbLJKTEwDx5KfkTZGHmGiaJnWY0qFX03sXsufvfB0Wj6Z37+nJnV16fplPmdr1/KEHamLw==\"," 44 + "\"id_card_national\":\"F8O5MNAOlYZyxZcLnWXkyvcmQrkBXCIo2vZGUoM6ER-skL5k6IOhzeJ34tNNUggQIPfJbM_pzdg9jM4pQbkIm84_bKfi2JKNn99xIurNgwI\"," 45 + "\"id_card_number\":\"V0quwnIu/PLbdQQ3/nzMqjvHtChDqed4Jpc3Iy2lgnFoWVNXguRWBHMYKHaLgLvnxLvO6TciMnrSw13QzUJD4ZnEIiks8gGTd+OCzl5Jl3F+sneQ+Js4akBnCSBQso/SERvi6vUqCeRhX1vtiFsmKtqlL8r/ssrFev4FoJEka5gGME1osTgcpMMTIR8rolIO1oXbl3e8z5RDics5xKH2Ogjzis73yq9M18ap0uRRdLWoX/cxeG3tbU1bi5jZsAU9hGHXs4BKTaHfrslsKIkqXR0f2Jpk7H5qtwAyP8glcALN7gB5DIOmBEIZ5zx2PrDm38CsZHstu0hF8beXV/PG2w==\"" 46 + "}" 47 + "}" 48 + "}," 49 + "\"business_code\":\"20201126100507000003\"," 50 + "\"contact_info\": {" 51 + "\"contact_name\":\"AD2jwe8eYFYfeoSmBpyRYUawyQgQkUoAajOlHnQM/JzproDF7hikLDouMr5Mb1W5otvdJZYEipG0HzwLpG9NXbqP6SXSpzQFb8fY5cpuXZsIbDy70lAybF0bbxJiJw1PHSd7KpMbu0XHqwlicePLUOw7HCNV6euQsKEvtusiWsaVrNNdKXpj3ONhyAg2ws4ibc56GUVoNll3osmGLPi6/bIn3pD6sjNThgPE9UzRQax0XPwgIpafIewQiVy0GNtv5P33wqPa9pAsdEmaLXNtQr2Ddjw5SYMInen1qbVO8NP0VhuWmYiAjd1WbkNnR+gbwsilBCYYeRuFbKfqatASnA==\"," 52 + "\"mobile_phone\":\"GLc5+TuqJbxLeQO+CrKeDWF+7lZq9IsidIU4zcMpus4qsE8r1qNyvVMjrZfWLrjOItiQhXqkiKZs0B4M0UWAviWwmBhNWW0BJrauBjZbGZU+pLHC/2eOetdDC4sQqHN7Xw0N4tizqeQNu49n+DbSiv0TL09EcmNUUV9rImfjpVyo77MxKhPvdg3ODwS+IVvY2Tc9q11iBgaPIQ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iqU0DqKAUt7q+L6jZ8lrSlGFPI/1RkXCGAhlTSZ/iAJYDWzcN/E0cno9BQPYCmEIWldzj7W3Tmhi1eaZYX5mlLWnTOuVmMsRXIehb4y6LCi6T0kS7/c3GOFwlTzHVaaUgFqZhOL00h2G4Cl94uZfuVNO7KTiFaWtV61muEN6JfaSnFwRDSHxhtsRg==\"," 58 + "\"bank_address_code\":\"310101\"," 59 + "\"account_name\":\"RVBRWZKlmzrjkDmz4uEkaLQLU5q5xErXGoWhzDNdnQjRlfn1NVHL2EtIE+B0BULFNOHrX61q13lcgo9CDal9YJ/LjZkzAAsivwJZpNSRZbAsNNjqbYiiVhdnxYpwMqtukVgZAFgx0XMovOeSGX1+Dosc2vKJSsxtUw6wJXcZbMjvsX5/xamFTvRIx1J2a/q3ODBJ9URO5O2FDhGwLx8LQnFIv7xUDM3JXw7c6+eNy1OYTVwlj3/MIDQVw2eiPjpG1vC6K6PRwCI4wFZk1QwH99Xa3Wwvf+ek54j7FQTh0N703dK6jjonL5L6Lh9ZsckLx45InkARlPnU0KQpoK5g9w==\"," 60 + "\"bank_account_type\":\"BANK_ACCOUNT_TYPE_CORPORATE\"," 61 + "\"account_bank\":\"招商银行\"" 62 + "}," 63 + "\"settlement_info\": {" 64 + "\"settlement_id\":\"716\"," 65 + "\"qualification_type\":\"零售批发/生活娱乐/网上商城/其他\"" 66 + "}" 67 + "}"; 68 StringEntity entity = new StringEntity(reqdata,"utf-8"); 69 entity.setContentType("application/json"); 70 httpPost.setEntity(entity); 71 httpPost.setHeader("Accept", "application/json"); 72 httpPost.setHeader("Wechatpay-Serial", "XXXXXXXXXXXXXX"); 73 //完成签名并执行请求 74 CloseableHttpResponse response = httpClient.execute(httpPost); 75 try { 76 int statusCode = response.getStatusLine().getStatusCode(); 77 if (statusCode == 200) { //处理成功 78 System.out.println("success,return body = " + EntityUtils.toString(response.getEntity())); 79 } else if (statusCode == 204) { //处理成功,无返回Body 80 System.out.println("success"); 81 } else { 82 System.out.println("failed,resp code = " + statusCode+ ",return body = " + EntityUtils.toString(response.getEntity())); 83 throw new IOException("request failed"); 84 } 85 } finally { 86 response.close(); 87 } 88}
PHP
1try { 2 $resp = $client->request( 3 'POST', 4 'https://api.mch.weixin.qq.com/v3/applyment4sub/applyment/', //请求URL 5 [ 6 // JSON请求体 7 'json' => [ 8 "business_info" => [ 9 "merchant_shortname" => "上海XXX有限公司", 10 "service_phone" => "139XXXX", 11 "sales_info" => [ 12 "mini_program_info" => [ 13 "mini_program_pics" => [ 14 "0" => "F8O5MNAOlYZyxZcLnWXkyk72coZ3CVX3XobPZng-xepKPTrcH_XMfrGGYLi1XFogMG9P25LSUX6gjXU5iPI74YqiRUDfORyw2d76wK3vzuQ", 15 ], 16 "mini_program_sub_appid" => "wx76c3f74c108876c2", 17 ], 18 "mp_info" => [ 19 "mp_pics" => [ 20 "0" => "F8O5MNAOlYZyxZcLnWXkys5TBxf0dyfesnyfNuquBMArHRfgCq8hDRdscDpblCcEgvgV5MkVch9IBEX7aatZCmI8k5Wdb_M8a4bYcmlg6V8", 21 ], 22 "mp_sub_appid" => "wx85c88c63bd22651f", 23 ], 24 "sales_scenes_type" => [ 25 "0" => "SALES_SCENES_MP", 26 "1" => "SALES_SCENES_MINI_PROGRAM", 27 ], 28 ], 29 ], 30 "subject_info" => [ 31 "business_license_info" => [ 32 "legal_person" => "江XX", 33 "license_copy" => "F8O5MNAOlYZyxZcLnWXkysZ5xo8fE3SHJ1pHUe6OJKmNIWtqUVyv4aY2-JLTgjDOSovWaKkBu3AbkjGuQXhesDzREu2pT_Yf_hxlFKPJMwQ", 34 "merchant_name" => "上海XXX有限公司", 35 "license_number" => "91310118MA1JXXXX", 36 ], 37 "subject_type" => "SUBJECT_TYPE_ENTERPRISE", 38 "identity_info" => [ 39 "owner" => true, 40 "id_doc_type" => "IDENTIFICATION_TYPE_IDCARD", 41 "id_card_info" => [ 42 "id_card_copy" => "F8O5MNAOlYZyxZcLnWXkyvLpqoz7MNRULxju0NqUCtLGBl_vm8Bhj9uAyuLyDART9UsA10spF9gbT3DEoM85HxPQOhMuilK0zLtOxAjPx58", 43 "card_period_end" => "2035-12-28", 44 "card_period_begin" => "2015-12-28", 45 "id_card_name" => "JRMJGA7B7oSVS+krFeaQn4AvYZE2LL9tTwA+XXa9lYJU4AhS+Qheb7fhgo+D+hfa0v+ykU1BVvVo7NpCfgOYQqmYDyYF27Q/p4hB7IoqZLhJUE+hTG45VNoa9ASaKG79Hg+eGz4YTIHFGMFm1ljyg4fd5lGJixCqn38/gCfwm5x6vDOMVkFpqbUdR7klQwReGoG7iSlEpr4gZPqzItcBHiuXidMToKZTX1Lol1Lx52DHk0blcdh1CMRhv+wxQzF0lJMy/WtVyjKuB8daDbLJKTEwDx5KfkTZGHmGiaJnWY0qFX03sXsufvfB0Wj6Z37+nJnV16fplPmdr1/KEHamLw==", 46 "id_card_national" => "F8O5MNAOlYZyxZcLnWXkyvcmQrkBXCIo2vZGUoM6ER-skL5k6IOhzeJ34tNNUggQIPfJbM_pzdg9jM4pQbkIm84_bKfi2JKNn99xIurNgwI", 47 "id_card_number" => "V0quwnIu/PLbdQQ3/nzMqjvHtChDqed4Jpc3Iy2lgnFoWVNXguRWBHMYKHaLgLvnxLvO6TciMnrSw13QzUJD4ZnEIiks8gGTd+OCzl5Jl3F+sneQ+Js4akBnCSBQso/SERvi6vUqCeRhX1vtiFsmKtqlL8r/ssrFev4FoJEka5gGME1osTgcpMMTIR8rolIO1oXbl3e8z5RDics5xKH2Ogjzis73yq9M18ap0uRRdLWoX/cxeG3tbU1bi5jZsAU9hGHXs4BKTaHfrslsKIkqXR0f2Jpk7H5qtwAyP8glcALN7gB5DIOmBEIZ5zx2PrDm38CsZHstu0hF8beXV/PG2w==", 48 ], 49 ], 50 ], 51 "business_code" => "20201126100507000003", 52 "contact_info" => [ 53 "contact_name" => "AD2jwe8eYFYfeoSmBpyRYUawyQgQkUoAajOlHnQM/JzproDF7hikLDouMr5Mb1W5otvdJZYEipG0HzwLpG9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9W6Ok6iS4zcerfKfIQkKs+3JXIMo0bu+GyI5O0fzRrPg1Mek2okfIjVK9wiTNJTzoGyz9twMXEaqqrOTbysyhnkqfrol5dad/TPg8qNWaBO3+Ma/hr1Tr0xeHWkKX3mBySC3NW49HM51x0PvFAwnStHr/8hiGzGpqAA3yJuYdlEwey3Lv+/bMmbTq+AyrYq9xX3q+n0VHuiSnzgICPwQiP4zXsoivA0bm7DSgcP1Oa6MjpGqMOS7AU1dHyak2GQ==", 57 ], 58 "bank_account_info" => [ 59 "account_number" => "Bfu6CzrRWlVTLZwjEK2CCXG0KRfGoIsbYs9IYmtFcV9FTEVLCcVCRGW6DVE2hMMr7U9tSdo7QqsptXZ7Zhciandyx9kRkY/VmPywurySvCbqpOLbx3AgmQY7H6/Ye542R0uloi6Pdp5FjqY/TdnlDcTS4cqv9iqU0DqKAUt7q+L6jZ8lrSlGFPI/1RkXCGAhlTSZ/iAJYDWzcN/E0cno9BQPYCmEIWldzj7W3Tmhi1eaZYX5mlLWnTOuVmMsRXIehb4y6LCi6T0kS7/c3GOFwlTzHVaaUgFqZhOL00h2G4Cl94uZfuVNO7KTiFaWtV61muEN6JfaSnFwRDSHxhtsRg==", 60 "bank_address_code" => "310101", 61 "account_name" => "RVBRWZKlmzrjkDmz4uEkaLQLU5q5xErXGoWhzDNdnQjRlfn1NVHL2EtIE+B0BULFNOHrX61q13lcgo9CDal9YJ/LjZkzAAsivwJZpNSRZbAsNNjqbYiiVhdnxYpwMqtukVgZAFgx0XMovOeSGX1+Dosc2vKJSsxtUw6wJXcZbMjvsX5/xamFTvRIx1J2a/q3ODBJ9URO5O2FDhGwLx8LQnFIv7xUDM3JXw7c6+eNy1OYTVwlj3/MIDQVw2eiPjpG1vC6K6PRwCI4wFZk1QwH99Xa3Wwvf+ek54j7FQTh0N703dK6jjonL5L6Lh9ZsckLx45InkARlPnU0KQpoK5g9w==", 62 "bank_account_type" => "BANK_ACCOUNT_TYPE_CORPORATE", 63 "account_bank" => "招商银行", 64 ], 65 "settlement_info" => [ 66 "settlement_id" => "716", 67 "qualification_type" => "零售批发/生活娱乐/网上商城/其他", 68 ] 69 ], 70 'headers' => [ 71 'Accept' => 'application/json', 72 'Wechatpay-Serial' => 'xxxxxxxxxxxxxxxxxxxxxxxxxx', 73 ] 74 ] 75 ); 76 $statusCode = $resp->getStatusCode(); 77 if ($statusCode == 200) { //处理成功 78 echo "success,return body = " . $resp->getBody()->getContents()."\n"; 79 } else if ($statusCode == 204) { //处理成功,无返回Body 80 echo "success"; 81 } 82} catch (RequestException $e) { 83 // 进行错误处理 84 echo $e->getMessage()."\n"; 85 if ($e->hasResponse()) { 86 echo "failed,resp code = " . $e->getResponse()->getStatusCode() . " return body = " . $e->getResponse()->getBody() . "\n"; 87 } 88 return; 89}
重要入参说明:
business_code 业务申请编号。
服务商自定义的唯一编号。
每个编号对应一个申请单,每个申请单审核通过后会生成一个微信支付商户号。
若申请单被驳回,可填写相同的“业务申请编号”,即可覆盖修改原申请单信息
mobile_phone: 联系手机。
11位数字。
用于接收微信支付的重要管理信息及日常操作验证码。
该字段需进行加密处理,加密方法详见敏感信息加密说明。(提醒:必须在HTTP头中上送Wechatpay-Serial)
bank_account_type: 账户类型。
若主体为企业/党政、机关及事业单位/其他组织,可填写:对公银行账户。
若主体为个体户,可选择填写:对公银行账户或经营者个人银行卡。
枚举值:BANK_ACCOUNT_TYPE_CORPORATE:对公银行账户
BANK_ACCOUNT_TYPE_PERSONAL:经营者个人银行卡
account_name: 开户名称。
选择“经营者个人银行卡”时,开户名称必须与“经营者证件姓名”一致。
选择“对公银行账户”时,开户名称必须与营业执照/登记证书的“商户名称”一致。
该字段需进行加密处理,加密方法详见敏感信息加密说明。(提醒:必须在HTTP头中上送Wechatpay-Serial)
更多参数、响应详情及错误码请参见提交申请单接口文档。
3.2.2.【服务端】查询申请单状态
步骤说明:创建申请单后,可通过查询申请单状态接口,获取特约商户签约链接,让商户扫码确认联系信息,后续申请单进度可通过公众号自动通知超级管理员(简称超管)。
JAVA
1public void QueryApplymentInfo() throws Exception { 2 //请求URL 3 HttpGet httpGet = new HttpGet("https://api.mch.weixin.qq.com/v3/applyment4sub/applyment/business_code/1900013511_10000"); 4 httpGet.setHeader("Accept", "application/json"); 5 //完成签名并执行请求 6 CloseableHttpResponse response = httpClient.execute(httpGet); 7 try { 8 int statusCode = response.getStatusLine().getStatusCode(); 9 if (statusCode == 200) { //处理成功 10 System.out.println("success,return body = " + EntityUtils.toString(response.getEntity())); 11 } else if (statusCode == 204) { //处理成功,无返回Body 12 System.out.println("success"); 13 } else { 14 System.out.println("failed,resp code = " + statusCode+ ",return body = " + EntityUtils.toString(response.getEntity())); 15 throw new IOException("request failed"); 16 } 17 } finally { 18 response.close(); 19 } 20}
PHP
1try { 2 $resp = $client->request( 3 'GET', 4 'https://api.mch.weixin.qq.com/v3/applyment4sub/applyment/business_code/1900013511_10000', //请求URL 5 [ 6 'headers' => [ 'Accept' => 'application/json'] 7 ] 8 ); 9 $statusCode = $resp->getStatusCode(); 10 if ($statusCode == 200) { //处理成功 11 echo "success,return body = " . $resp->getBody()->getContents()."\n"; 12 } else if ($statusCode == 204) { //处理成功,无返回Body 13 echo "success"; 14 } 15} catch (RequestException $e) { 16 // 进行错误处理 17 echo $e->getMessage()."\n"; 18 if ($e->hasResponse()) { 19 echo "failed,resp code = " . $e->getResponse()->getStatusCode() . " return body = " . $e->getResponse()->getBody() . "\n"; 20 } 21 return; 22}
重要入参说明:
business_code: 业务申请编号。
只能由数字、字母或下划线组成,建议前缀为服务商商户号。
服务商自定义的唯一编号。
每个编号对应一个申请单,每个申请单审核通过后生成一个微信支付商户号。
若申请单被驳回,可填写相同的“业务申请编号”,即可覆盖修改原申请单信息。
applyment_id: 申请单号, 微信支付分配的申请单号。
更多参数、响应详情及错误码请参见查询申请单状态接口文档
3.2.3. 【服务端】修改结算账号
步骤说明: 进件成功后,若特约商户需修改结算账号时,服务商可调用修改结算账号接口来帮助特约商户修改结算信息。
JAVA
1public void UpdateSubMchInfo() throws Exception { 2 //请求URL 3 HttpPost httpPost = new HttpPost("https://api.mch.weixin.qq.com/v3/apply4sub/sub_merchants/190000XXX/modify-settlement"); 4 // 请求body参数 5 String reqdata = "{" 6 + "\"account_type\":\"ACCOUNT_TYPE_BUSINESS\"," 7 + "\"account_bank\":\"工商银行\"," 8 + "\"bank_address_code\":\"110000\"," 9 + "\"bank_name\":\"施秉县农村信用合作联社城关信用社\"," 10 + "\"bank_branch_id\":\"402713354941\"," 11 + "\"account_number\":\"d+xT+MQCvrLHUVDWv/8MR/dB7TkXM2YYZlokmXzFsWs35NXUot7C0NcxIrUF5FnxqCJHkNgKtxa6RxEYyba1+VBRLnqKG2fSy/Y5qDN08Ej9zHCwJjq52Wg1VG8MRugli9YMI1fI83KGBxhuXyemgS/hqFKsfYGiOkJqjTUpgY5VqjtL2N4l4z11T0ECB/aSyVXUysOFGLVfSrUxMPZy6jWWYGvT1+4P633f+R+ki1gT4WF/2KxZOYmli385ZgVhcR30mr4/G3HBcxi13zp7FnEeOsLlvBmI1PHN4C7Rsu3WL8sPndjXTd75kPkyjqnoMRrEEaYQE8ZRGYoeorwC+w==\"" 12 + "}"; 13 StringEntity entity = new StringEntity(reqdata,"utf-8"); 14 entity.setContentType("application/json"); 15 httpPost.setEntity(entity); 16 httpPost.setHeader("Accept", "application/json"); 17 httpPost.setHeader("Wechatpay-Serial", "XXXXXXXXXXXX"); 18 //完成签名并执行请求 19 CloseableHttpResponse response = httpClient.execute(httpPost); 20 try { 21 int statusCode = response.getStatusLine().getStatusCode(); 22 if (statusCode == 200) { //处理成功 23 System.out.println("success,return body = " + EntityUtils.toString(response.getEntity())); 24 } else if (statusCode == 204) { //处理成功,无返回Body 25 System.out.println("success"); 26 } else { 27 System.out.println("failed,resp code = " + statusCode+ ",return body = " + EntityUtils.toString(response.getEntity())); 28 throw new IOException("request failed"); 29 } 30 } finally { 31 response.close(); 32 } 33}
PHP
1try { 2 $resp = $client->request( 3 'POST', 4 'https://api.mch.weixin.qq.com/v3/apply4sub/sub_merchants/190000XXX/modify-settlement', //请求URL 5 [ 6 // JSON请求体 7 'json' => [ 8 "account_type" => "ACCOUNT_TYPE_BUSINESS", 9 "account_bank" => "工商银行", 10 "bank_address_code" => "110000", 11 "bank_name" => "施秉县农村信用合作联社城关信用社", 12 "bank_branch_id" => "402713354941", 13 "account_number" => "d+xT+MQCvrLHUVDWv/8MR/dB7TkXM2YYZlokmXzFsWs35NXUot7C0NcxIrUF5FnxqCJHkNgKtxa6RxEYyba1+VBRLnqKG2fSy/Y5qDN08Ej9zHCwJjq52Wg1VG8MRugli9YMI1fI83KGBxhuXyemgS/hqFKsfYGiOkJqjTUpgY5VqjtL2N4l4z11T0ECB/aSyVXUysOFGLVfSrUxMPZy6jWWYGvT1+4P633f+R+ki1gT4WF/2KxZOYmli385ZgVhcR30mr4/G3HBcxi13zp7FnEeOsLlvBmI1PHN4C7Rsu3WL8sPndjXTd75kPkyjqnoMRrEEaYQE8ZRGYoeorwC+w==", 14 ], 15 'headers' => [ 16 'Accept' => 'application/json', 17 'Wechatpay-Serial' => 'xxxxxxxxxxxxxxxxxxxxxxxxxx', 18 ] 19 ] 20 ); 21 $statusCode = $resp->getStatusCode(); 22 if ($statusCode == 200) { //处理成功 23 echo "success,return body = " . $resp->getBody()->getContents()."\n"; 24 } else if ($statusCode == 204) { //处理成功,无返回Body 25 echo "success"; 26 } 27} catch (RequestException $e) { 28 // 进行错误处理 29 echo $e->getMessage()."\n"; 30 if ($e->hasResponse()) { 31 echo "failed,resp code = " . $e->getResponse()->getStatusCode() . " return body = " . $e->getResponse()->getBody() . "\n"; 32 } 33 return; 34}
重要入参说明:
sub_mchid: 投诉单对应的投诉单号,在投诉通知回调中会返回这个参数
account_bank:开户银行,请填写开户银行名称,详细参见开户银行对照表。
account_number:银行账号。
数字,长度遵循系统支持的开户银行对照表中对公/对私卡号长度要求。
该字段需进行加密处理,加密方法详见敏感信息加密说明。(提醒:必须在HTTP头中上送Wechatpay-Serial)
更多参数、响应详情及错误码请参见修改结算账号接口文档。
3.2.4. 【服务端】查询结算账户
步骤说明: 服务商调用修改结算账号接口来帮助特约商户修改结算信息,修改后通过状态码判断是否修改成功。也可通过调用查询结算账号接口来查询核查结算账号信息。
JAVA
1public void QuerySettleMent() throws Exception { 2 //请求URL 3 HttpGet httpGet = new HttpGet("https://api.mch.weixin.qq.com/v3/apply4sub/sub_merchants/190000XXXX/settlement"); 4 httpGet.setHeader("Accept", "application/json"); 5 //完成签名并执行请求 6 CloseableHttpResponse response = httpClient.execute(httpGet); 7 try { 8 int statusCode = response.getStatusLine().getStatusCode(); 9 if (statusCode == 200) { //处理成功 10 System.out.println("success,return body = " + EntityUtils.toString(response.getEntity())); 11 } else if (statusCode == 204) { //处理成功,无返回Body 12 System.out.println("success"); 13 } else { 14 System.out.println("failed,resp code = " + statusCode+ ",return body = " + EntityUtils.toString(response.getEntity())); 15 throw new IOException("request failed"); 16 } 17 } finally { 18 response.close(); 19 } 20}
PHP
1try { 2 $resp = $client->request( 3 'GET', 4 'https://api.mch.weixin.qq.com/v3/apply4sub/sub_merchants/190000XXXX/settlement', //请求URL 5 [ 6 'headers' => [ 'Accept' => 'application/json'] 7 ] 8 ); 9 $statusCode = $resp->getStatusCode(); 10 if ($statusCode == 200) { //处理成功 11 echo "success,return body = " . $resp->getBody()->getContents()."\n"; 12 } else if ($statusCode == 204) { //处理成功,无返回Body 13 echo "success"; 14 } 15} catch (RequestException $e) { 16 // 进行错误处理 17 echo $e->getMessage()."\n"; 18 if ($e->hasResponse()) { 19 echo "failed,resp code = " . $e->getResponse()->getStatusCode() . " return body = " . $e->getResponse()->getBody() . "\n"; 20 } 21 return; 22}
重要入参说明:
sub_mchid: 特约商户号、请输入本服务商进件、已签约的特约商户号。
更多参数、响应详情及错误码请参见查询结算账户接口文档。
4. 常见问题
Q1:调用特约商户进件“提交申请单接口”返回“暂无权限”?
A1:请按照以下几点检查
服务商商户号被处罚,被限制权限,请登录服务商商户平台查看站内信,按照收到的站内信提示申诉解决
请求头中的参数mchid填写错误,该参数只能填写为普通服务商的商户号,不能填写为其他类型的商户号
特约商户进件接口不允许进件小微商户
Q2:调用特约商户进件“提交申请单接口”返回“身份证号码,与营业执照不匹配,请核对修改”?
A2:请按照以下几点检查
身份证号码字段(id_card_number)取值错误,请填写个体户经营者/法定代表人对应身份证的号码
身份证号码字段(id_card_number)取值错误,身份证号码的规则是15位数字或17位数字+1位数字|X,该字段需进行加密处理
请使用办理营业执照的身份证号码
Q3:调用特约商户进件“提交申请单接口”返回:"参数“组织机构代码证照片”是必填项
A3:请仔细检查上传的参数是否有问题,如果传入组织机构代码证的结构(organization_info),将进行真实校验,请去掉组织机构代码证的结构(organization_info)
Q4:调用特约商户进件“提交申请单接口”返回“系统繁忙,请稍后重试”
A4:请按照以下几点检查
系统繁忙,可以稍后重试
请求头中的参数mchid填写错误,该参数只能填写为普通服务商的商户号
在请求参数中,不需要的参数不要上传,不能传空值,空的字段也不能上传
Q5:查询结算账户API不返回verify_result字段,是什么原因?
A5:入驻后若没有修改过银行卡,除非是汇款失败,否则不返回verify_result字段