$params = [
'appid' => $appConfig['wx_app_id'],
'sp_mchid' => $appConfig['wx_pay_mchid'],
'description' => '现场扫码支付',
'out_trade_no' => $order['order_no'],
'notify_url' => $GLOBALS['config']['notify_url'] . '/native',
'amount' => [
'total' => intval($amount * 100),
'currency' => 'CNY'
]
];
$resp = $instance->chain('/v3/pay/transactions/native')->post(['json' => $params]);

现在是支付处理失败:Cannot load privateKey from(string), please take care about the \$thing input. 应该是初始化的问题
private function getWxPayInstance($appConfig) {
// 引入微信支付SDK
require_once __DIR__ . '/wechatpay-php-main/src/Builder.php';
require_once __DIR__ . '/wechatpay-php-main/src/Crypto/Rsa.php';
// 商户号
$merchantId = $appConfig['sp_mchid'];
// 从本地文件中加载「商户API私钥」
$merchantPrivateKeyFilePath = '/data/wwwroot/aasaas/user/Controllers/apiclient_key.pem';
if (!file_exists($merchantPrivateKeyFilePath)) {
throw new \Exception('商户API私钥文件不存在: ' . $merchantPrivateKeyFilePath);
}
$merchantPrivateKeyInstance = Rsa::from($merchantPrivateKeyFilePath, Rsa::KEY_TYPE_PRIVATE);
// 「商户API证书」的「证书序列号」
$merchantCertificateSerial = '479BBB1B94CFA0D3EB34D6D523E882F698AXXXXX';
if (empty($merchantCertificateSerial)) {
throw new \Exception('商户API证书序列号未配置');
}
// 从本地文件中加载「微信支付公钥」
$platformPublicKeyFilePath = '/data/wwwroot/aasaas/user/Controllers/apiclient_cert.pem';
if (!file_exists($platformPublicKeyFilePath)) {
throw new \Exception('微信支付公钥文件不存在: ' . $platformPublicKeyFilePath);
}
$platformPublicKeyInstance = Rsa::from($platformPublicKeyFilePath, Rsa::KEY_TYPE_PUBLIC);
// 「微信支付公钥」的「微信支付公钥ID」
$platformPublicKeyId = 'PUB_KEY_ID_011717961263202510150019XXXXXX'; // 需要从商户平台获取
// 构造一个 APIv3 客户端实例
$instance = Builder::factory([
'mchid' => $merchantId,
'serial' => $merchantCertificateSerial,
'privateKey' => $merchantPrivateKeyInstance,
'certs' => [
$platformPublicKeyId => $platformPublicKeyInstance,
],
]);
return $instance;
}
现在是[16-Oct-2025 22:40:28] WARNING: [pool www] child 760 said into stderr: "PHP message: Autoloader: Class file not found: /data/wwwroot/aasaas/user/Core/../WeChatPay/BuilderTrait.php"
[16-Oct-2025 22:40:28] WARNING: [pool www] child 760 said into stderr: "PHP message: PHP Fatal error: Trait "WeChatPay\BuilderTrait" not found in /data/wwwroot/aasaas/user/Controllers/wechatpay-php-main/src/Builder.php on line 43"
一大堆错误 这是什么SDK