wechatpay-php 报错
Rsa::from 报错 Cannot load privateKey from(string), please take care about the \$thing input
/**
* 构建一个客户端实例
* wechatpay-php
*/
public static function instanceWeChatPay()
{
// 商户号
$merchantId = WeChat::$merchantId;
// 从本地文件中加载商户API私钥,商户API私钥会用来生成请求的签名
//dd(WeChat::$merchantPrivateKeyFilePath); 路径
//"D:\web\3boat\storage\cert\wechat\4C1BBE189365B735FF1B7AE9A63EDCB7CDA49093\apiclient_key.pem"
$merchantPrivateKeyInstance = Rsa::from(WeChat::$merchantPrivateKeyFilePath, Rsa::KEY_TYPE_PRIVATE);
dd($merchantPrivateKeyInstance);
// 商户API证书序列号
$merchantCertificateSerial = WeChat::$merchantCertificateSerial;
// 从本地文件中加载微信支付平台证书,用来验证微信支付应答的签名
$platformPublicKeyInstance = Rsa::from(WeChat::$platformCertificateFilePath, Rsa::KEY_TYPE_PUBLIC);
// 获取微信支付平台证书序列号
$platformCertificateSerial = PemUtil::parseCertificateSerialNo(WeChat::$platformCertificateFilePath);
// 构造一个 APIv3 客户端实例
WeChat::$instance = Builder::factory([
'mchid' => $merchantId,
'serial' => $merchantCertificateSerial,
'privateKey' => $merchantPrivateKeyInstance,
'certs' => [
$platformCertificateSerial => $platformPublicKeyInstance,
],
]);
}
真是没有对比没有伤害,支付宝简单多了
谢谢,大佬