商户进件,请求接口https://api.mch.weixin.qq.com/v3/ecommerce/applyments/
提示“商户名称取值有误,若选择对公账户时,开户名称必须与营业执照上的“商户名称”一致”
已经确认商户名、开户名保持一致,且开户名已进行加密处理,网上查了说是utf-8的问题,我在请求头中设置charset=utf-8,还是存在这个问题。
使用的是官方提供的php开发包。
关键代码如下:
$wechatConfig = include APP_PATH . 'wechatpay.php';
$merchantId = $wechatConfig['merchant_id']; // 商户号
$merchantSerialNumber = $wechatConfig['merchant_serial_number']; // 商户API证书序列号
$merchantPrivateKey = PemUtil::loadPrivateKey(APP_PATH . 'apiclient_key.pem'); // 商户私钥
// 微信支付平台配置
$wechatpayCertificate = PemUtil::loadCertificate(APP_PATH . 'wechatpay_cert.pem'); // 微信支付平台证书
$encryptor = new SensitiveInfoCrypto(PemUtil::loadCertificate(APP_PATH . 'wechatpay_cert.pem'));
// 构造一个WechatPayMiddleware
$wechatpayMiddleware = WechatPayMiddleware::builder()
->withMerchant($merchantId, $merchantSerialNumber, $merchantPrivateKey)// 传入商户相关配置
->withWechatPay([$wechatpayCertificate])// 可传入多个微信支付平台证书,参数类型为array
->build();
// 将WechatPayMiddleware添加到Guzzle的HandlerStack中
$stack = HandlerStack::create();
$stack->push($wechatpayMiddleware, 'wechatpay');
// 创建Guzzle HTTP Client时,将HandlerStack传入
$client = new Client(['handler' => $stack]);
// 发送请求
$postContent['business_license_info'] = [
// 省略部分参数
'merchant_name' => $applymentInfo['merchant_name'], // 商户名
];
$postContent['account_info'] = [
// 省略部分参数
'account_name' => $encryptor($applymentInfo['account_name']), // 开户名,同商户名,进行加密
];
$resp = $client->request('POST', 'https://api.mch.weixin.qq.com/v3/ecommerce/applyments/', [
'json' => $postContent,
'headers' => [
'Accept' => 'application/json;charset=utf-8',
'Wechatpay-Serial' => $wechatConfig['wechatpay_serial_number'],
]
]);
已解决,自己代码问题,感谢官方技术支持