require_once('vendor/autoload.php');
use WeChatPay\Builder;
use WeChatPay\Crypto\Rsa;
use WeChatPay\Util\PemUtil;
// 设置参数
// 商户号
$merchantId = '16375****'; // 实际程序中已填写正确,后面的一样
// 从本地文件中加载「商户API私钥」,「商户API私钥」会用来生成请求的签名
$merchantPrivateKeyFilePath = 'file:///var/www/html/eduxiaoxin/eduplat/payself/cert/apiclient_key.pem'; // 下载并上传了证书
$merchantPrivateKeyInstance = Rsa::from($merchantPrivateKeyFilePath, Rsa::KEY_TYPE_PRIVATE);
// 「商户API证书」的「证书序列号」 ----------- (这个证书序列号到底是什么?我只设置了V2和V3密钥)
$merchantCertificateSerial = 'd89350ecf23854******'; // 这里填写了V3的密钥
// 从本地文件中加载「微信支付平台证书」,用来验证微信支付应答的签名
$platformCertificateFilePath = 'file:///var/www/html/eduxiaoxin/eduplat/payself/cert/apiclient_cert.pem';
$platformPublicKeyInstance = Rsa::from($platformCertificateFilePath, Rsa::KEY_TYPE_PUBLIC);
// 从「微信支付平台证书」中获取「证书序列号」
$platformCertificateSerial = PemUtil::parseCertificateSerialNo($platformCertificateFilePath);
$out_order_no = ‘这里我填了自己生成的32位’;
$receivers = array();
$r = array();
$r['type'] = 'PERSONAL_OPENID';
$r['account'] = 'oZ_jm5uNnNQ7HEUuag5f****';
$r['name'] = '陈*';
$r['amount'] = 2;
//$r['relation_type'] = 'PARTNER';
$r['description'] = '分配';
$receivers[] = $r;
//print_r(json_encode($receivers,JSON_UNESCAPED_UNICODE));
$d = array(
'appid' => 'wx4bcfe6bd92fb1f7d',
'transaction_id' => '4200001924202308217643494859',
'out_order_no' => $out_order_no,
'receivers' => json_encode($receivers,JSON_UNESCAPED_UNICODE),
'unfreeze_unsplit' => true,
);
// 构造一个 APIv3 客户端实例
$instance = Builder::factory(array(
'mchid' => $merchantId,
'serial' => $merchantCertificateSerial,
'privateKey' => $merchantPrivateKeyInstance,
'certs' => array(
$platformCertificateSerial => $platformPublicKeyInstance,
),
));
$resp = $instance->chain('v3/profitsharing/orders')->post($d);
echo $resp->getBody(), PHP_EOL;
执行出了内部错误,麻烦哪位大神解答一下。
报错是什么?