首先可以确定的是,不是证书问题,调用图片上传接口是没问题的。
直接上代码,这是我的请求逻辑。
self::$wechatpayCertificate // 这个是微信支付平台证书
self::$wechatpaySerialNumber // 这个是微信支付平台证书序列号
$client = self::getInstance();
$encryptor = new SensitiveInfoCrypto(PemUtil::loadCertificate(self::$wechatpayCertificate));
try {
// 数据上传加密处理
foreach ($data as $key => &$item)
{
if($key === 'business_license_info')
{
$item['business_license_copy'] = self::uploadImage($item['business_license_copy'])['media_id'];
}
if($key === 'id_card_info')
{
$item['id_card_copy'] = self::uploadImage($item['id_card_copy'])['media_id'];
$item['id_card_national'] = self::uploadImage($item['id_card_national'])['media_id'];
$item['id_card_name'] = $encryptor($item['id_card_name']);
$item['id_card_number'] = $encryptor($item['id_card_number']);
}
if($key === 'account_info')
{
$item['account_name'] = $encryptor($item['account_name']);
$item['account_number'] = $encryptor($item['account_number']);
}
if($key === 'contact_info')
{
$item['contact_name'] = $encryptor($item['contact_name']);
$item['contact_id_card_number'] = $encryptor($item['contact_id_card_number']);
$item['mobile_phone'] = $encryptor($item['mobile_phone']);
$item['contact_email'] = $encryptor($item['contact_email']);
}
if($key === 'sales_scene_info')
{
if(!empty($item['store_qr_code']))
{
$item['store_qr_code'] = self::uploadImage($item['store_qr_code'])['media_id'];
}
}
if($key === 'business_addition_pics')
{
$newItem = [];
foreach ($item as $pic)
{
$newItem[] = self::uploadImage($pic)['media_id'];
}
$item = $newItem;
unset($newItem);
}
}
// POST 语法糖
$resp = $client->post('https://api.mch.weixin.qq.com/v3/ecommerce/applyments/', [
'json' => $data,
'headers' => [
'Wechatpay-Serial' => self::$wechatpaySerialNumber,
'Accept' => 'application/json',
],
]);
return json_decode($resp->getBody()->getContents(), true);
} catch (RequestException $e) {
throw $e;
}
// 具体提交的数据
Array
(
[out_request_no] => APPLYMENT_20200622155632
[organization_type] => 2401
[id_doc_type] => IDENTIFICATION_TYPE_MAINLAND_IDCARD
[id_card_info] => Array
(
[id_card_copy] => Fqpm9Ut8nPMuPcQdlYCJh2vp9QYuyfE3c1Rs0yTpc9VziSngdP4kzPooMylk2p4gHKxV1lKrfVFPMjTjvjYMYqdx1AQGldpvRx8p8acrKNo
[id_card_national] => Fqpm9Ut8nPMuPcQdlYCJh7A1xTQQK-QQCJZpEnYpkv9j-AHa4SBpQrTriytPU0pjFsgmQtL0Oj44ANtrbIf3bDzTpOlATPZosijRN0u3AG4
[id_card_name] => K+izWgpqyzMba8iEUhN5gkxikiA2rcDV+6S8Y9OPeVulgDga5NmKs3XfSCCW39AxyDOMnARNpTJzDPK+OUzZcETEca4qlO7VqZA+HX0HekHW8ZEqH7gpQBXCMbjawT2Q2J6MILiOyagDOh016f62nDeQmQbBmRKkK6MIEOzxo6N51Q1fp7qZhOSb4202nRfkI1zz8DYODEEFhvlJQbG62tZ995Eku1Mm/djmtRLPxESdZPS+HD+OMz4eu9UKoYzXKc+JkoI8X3SsBcSa/INF65/sBvCrubUn9v8iCockiOrPtCGStTKL6v44n983oyFHIEZ9svH3CkoAjKTdBQz9cg==
[id_card_number] => LpkeW1yi40lABa9kXSXMb2g5k+ZpH8tqoQoRP9ECWJAyUMd8W+Xkh8Y+h04ckVyRxJkOoUb1IyuIiybgLXjAN1TQLnhbskd90Bx3eBOoDo2yi1m6MBKU+tFU2cW88SaYRDgO1OB9btmE7zx9wiACpXSiKlWrfqEvi0RHfgRxzzsqHuujAN3wXn9jlRBuYGJLUNEuDmRGI02FqVSKsTvyx0iqTU0vhRcD5zrPcpX6ecxh23pvrDHwCVnwiLiSeRz7MO/z9ccNFUSFN5TFyIERWiG2IwX+va9JeTAl2MhbQd1Ut42bSYYIVZsfHW453MU1ULdrfiC4wLg6aNQzBF5AFw==
[id_card_valid_time] => 长期
)
[need_account_info] => true
[account_info] => Array
(
[bank_account_type] => 75
[account_bank] => 工商银行
[account_name] => gOTc2+jjakKbsBGct6loNatbO4q1HLE1Xz+TyrnJX3JNgp+WmQ44ajajsArmuYcMe4j66O7ByZaPmIg7//bd7LTgtBW/VL+6k3YQPdA8psd9vYruAyODYzUDa0td0BGk2/qTOx2wjUjUuGyNE//Ux6xweAxxKc1297yVO8OqufVOtuPl1kpImx8qc+V0Ckj7K4ny929O9H4p5nGB/QUvxGzKiWONW969xHGSWHwshWxJ8h8JJE6vE2uvv9X8AJ5VunyOnOAUWC3Fk3wVjqlZPawkszEVGvREePiXAwFgDhJBlhEEpkPtdS4suVem7X+JVQAEfRMgJ38pt+XF6qqX6w==
[bank_address_code] => 110000
[account_number] => tMMzpkDjxiAh3+lQBH5B4hXcIaMVxVdC/WAi4ILS5QNmLJ2OmKd1B84JKKJur4t6G3VVpjSiD1ssHX365WrD2u6fYLzqq3M3rF0aQte/QDDQFmer2sveBT9J1q8rgz90TgG75gpjrtMl3Pxo7xldRQNMVVu0kHn5QBxZ2Mux7pI7G5fgJgCFiHCxGoVZtZ3M2wgFuZJVUC8swhKJQ8KQVxAb+R3dibZ8qI5kA26oB8X3J+kOrBPNfBeqZcjEs9uZCR7ec8fMlDxO3kHsFtUhpcQ9cMs/aY5Rn+7EIIvbih8KrtpL55rUkX+S78BKS39j70KaJ7uhEuGu0ZInQU9+ug==
)
[contact_info] => Array
(
[mobile_phone] => gdPKSWWVNmtdGROT+PUoRVNie5J+x6TcQP5KPcfv6mWgqe6kXcV6JhTaMq6b/lszRZuL6DdQDhHEnpDiU+IhuK0qrzWqO4Zwj5rFo818agaEIodo+wQRGFnu538Owih1YL+vH56kt5DIsWsr5QXjMzM0nVVjtOS+Q0Twe5GAPbkvwFW5b1zlK4pgF8DQGCKIBjxZ5oKEveYapKo33rgM85NeAAHV9qLx23a/4Z668TvkXQdcs6VqZi14zvHpW9zGQIzdZWbiqsf6MGLH4CwgUzQ7pJ5ico7aDmcRqs8dx3V+SGQhJDUmpq4J7SyHt4CUeRH7IS0Vj3Rp7p8s+tiJ/Q==
[contact_email] => EaOuPB8qJstbnUVSC0TfcAOoqo6bYkJU1CvwOOMioqarIG+CgpnsHThDzAqE8M3xNk9mZd0tnkyQmnhH5wagESdUIz0eBwfqHIWA0ChjRaXWQbFkhuksQR3nN0/jJqyT5lXctEBJaroq2YPVWx0tLACD1yf5WGVXl3DmCBsKMSJHhovROddCWHbxtztiVEAK2w5M/s5p2fcpZVNy8zDmZso7GzW/0Axzg9mu1R/fPM0+HSKhiwN1XnjliSKvGQFS5CBLlWWLnVsnqDDk/G1lnnJerZOjARMs4nHxv0ZL/yk3WoLHmFoZ0LN4XtDscDFDGkWlSs7LiGkAr/UrsBsDFg==
[contact_type] => 65
[contact_name] => w3oAHa3C2e60bzeU17n7dq5XOmv2fD3FdizKyx2HU107NaEPpNKyRBUJAEgDRP7nq5Xa656nZOjcJTQH24ZJiWS9qes4zO5Un4J3YCBXIyMO8q/tceY6y5yiWnceUv0+3QeqA3xuaj0/qKcXAO/+o6eiQgEKSipZHry6qPR5sYsWYDBqViK2LBQuS3zmqfrII7RTgXe2t5FAkWhqZOmQiRjbWgPY3EgVvTnHCJJeIPpyZR/q8xpg4NOtpSqcRLKKdo0hAV9NCNZC3pOzvAkjwq3qYPf14dXpoqQ1gfBx6rfVX1BC7YOFe/ONVpYN4Yq1D+atLQNelA0K0YvQQ5oNpA==
[contact_id_card_number] => LsE1G7AIEGqo1vHzo8qTRMEttWuGuYGVxXjQBUi1i98z+yf0W9alK/BD/hcQAPLLG98gyxobCjzVeEnhgyfheSgLAud3r0wUDGQY/a4liQ7/TO1RvgC1rfLzbwmR9pmPrECfuqcgfqX5Jomqfa+Y5lRPVZcTHJP4yV+OX8Sf2oQRSLEA2X3xACDYzbeMxzKB1T2TsUuQP6+EU7SXbbo3OYpFBfuiyO3FpQLMSFyHHTRyw6AhEGEyrdv4yyT3DcxFPe+c29rutE+GNSp32PmeCD2Ru+6zMQdJrIfiWgAg5MKHOWQxSBT2t+wCqwVdp6SmdrekfTBEwC7pUyH30eWIag==
)
[sales_scene_info] => Array
(
[store_name] => 啊啊的店铺
[store_qr_code] => Fqpm9Ut8nPMuPcQdlYCJhydyTZSJahV0yiExD3pi1Yq0S79GKcZIsuf2MXxOZA1l9ZHRinEb-00dQWxmSnyRX7r94ZYqvqsKbD__GjLB_Ws
)
[merchant_shortname] => 啊啊的店铺
)
终于走通了,妈蛋,因为 need_account_info 是 bool 类型,我传递的是 "true" 字符串true,。。要直接传 true 。。
正在测试这个true 和false 的问题
你好,头部添加Wechatpay-Serial 平台证书序列号,并使用平台证书加密敏感数据。重新请求,看看是否海报错。谢谢。