easypay 是3.x
easywechat 是6.x
引入:
use Yansongda\Pay\Pay;//easypayuse EasyWeChat\MiniApp\Application as MiniApp;//easywechat
use EasyWeChat\Pay\Application as Payapp;//easywechat
public function suborder(){$order = ['out_trade_no' => time().mt_rand(10000,99999),'description' => '商品购买','amount' => ['total' => 1,'currency' => 'CNY',],'payer' => ['openid' => input('openid'),]];$result = Pay::wechat(PayLib::getConfig())->mini($order);$this->success('',$result);var_dump($result);die;$result = Pay::wechat()->mini($order);}public function suborder_easywechat(){$config = ['app_id' => 'wx6ce683f16052b51b','secret' => 'b5d5bcb937101b7d36a99425ebd044fb','mch_id' => 1631350029,// 商户证书'private_key' => '/www/wwwroot/h5dev.qfhl.com/cert/apiclient_key.pem','certificate' => '/www/wwwroot/h5dev.qfhl.com/cert/apiclient_cert.pem',// v3 API 秘钥'secret_key' => '876FA8733AF9E2E6FE2015C0113B7322',];$app = new Payapp($config);$response = $app->getClient()->postJson("v3/pay/transactions/jsapi", ["mchid" => "1631350029", // <---- 请修改为您的商户号"out_trade_no" => time().mt_rand(10000,99999),"appid" => "wx6ce683f16052b51b", // <---- 请修改为服务号的 appid"description" => "商品购买","notify_url" => "https://crm.xiniuai.com/index.php/api/PayNotify/easy_wechat","amount" => ["total" => 1,"currency" => "CNY"],"payer" => ["openid" => input('openid') // <---- 请修改为服务号下单用户的 openid]]);// var_dump($response->getContent());die;$prepay=$response->toArray();$appId = 'wx6ce683f16052b51b';$signType = 'RSA'; // 默认RSA,v2要传MD5$config = $app->getUtils()->buildSdkConfig($prepay['prepay_id'], $appId, $signType); // var_dump($config);die;//$config的timestamp小写了!!!!!$this->success('',$config);}