$merchantId = $_ENV["MCHID"];
$merchantPrivateKeyFilePath = 'file://../../apiclient_key.pem';
$merchantPrivateKeyInstance = Rsa::from($merchantPrivateKeyFilePath, Rsa::KEY_TYPE_PRIVATE);
$merchantCertificateSerial = $_ENV["APIV3"];
$platformCertificateFilePath = 'file://../../apiclient_cert.pem';
$platformPublicKeyInstance = Rsa::from($platformCertificateFilePath, Rsa::KEY_TYPE_PUBLIC);
$platformCertificateSerial = PemUtil::parseCertificateSerialNo($platformCertificateFilePath);
$instance = Builder::factory([
'mchid' => $merchantId,
'serial' => $merchantCertificateSerial,
'privateKey' => $merchantPrivateKeyInstance,
'certs' => [
$platformCertificateSerial => $platformPublicKeyInstance,
],
]);
$resp = $instance
->chain('v3/pay/transactions/native')
->post(['json' => [
'mchid' => $merchantId ,
'out_trade_no' => md5("服务器订单id".date("Y-m-d H:m:s")),
'appid' => $_ENV["APPID"],
'description' => 'Image形象店-深圳腾大-QQ公仔',
'notify_url' => 'https://demo.pc-webtech.com/v1/user/login',
'amount' => [
'total' => 1,
'currency' => 'CNY'
],
"payer" => [
'openid' =>"oTS2g61i8m1VNjtcfDOHCbeD84bs"
]
]]);
return $resp->getBody();
签名错误,这两个确定文件加载路径正确?
证书的引入方式用绝对路径试试