修正支付配置错误

This commit is contained in:
wucongxing 2023-03-06 17:07:22 +08:00
parent fe62ed8614
commit 45357f8028
2 changed files with 5 additions and 5 deletions

View File

@ -76,7 +76,7 @@ class UserController extends AbstractController
// 获取预支付交易会话标识
$total = 0.01 * 100;
$prepay = $WechatPay->getJsapiPrepayId("123456",$total,"o9gYG441zEAHuYoNX7lwFKiQBzKE");
$prepay = $WechatPay->getJsapiPrepayId("123457",$total,"o9gYG441zEAHuYoNX7lwFKiQBzKE");
if (empty($prepay)){
return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败");
}

View File

@ -46,14 +46,14 @@ class WechatPay
public function createApp(): Application
{
$config = [
'mch_id' => config("we_chat.pay.mch_id"),
'mch_id' => $this->pay_config['mch_id'],
// 商户证书
'private_key' => __DIR__ . '/certs/1636644248/apiclient_key.pem',
'certificate' => __DIR__ . '/certs/1636644248/apiclient_cert.pem',
// v3 API 秘钥
'secret_key' => config("we_chat.pay.v3_api_secret"),
'secret_key' => $this->pay_config['v3_api_secret'],
// v2 API 秘钥
'v2_secret_key' => '',
@ -62,7 +62,7 @@ class WechatPay
// 下载工具https://github.com/wechatpay-apiv3/CertificateDownloader
'platform_certs' => [
// 请使用绝对路径
__DIR__ . '/certs/' . config("we_chat.pay.mch_id") . '/wechatpay_112FCCD1B9ECC8292703AB7363C73D74B6AFDC1A.pem',
__DIR__ . '/certs/' . $this->pay_config['mch_id'] . '/wechatpay_112FCCD1B9ECC8292703AB7363C73D74B6AFDC1A.pem',
],
/**
@ -111,7 +111,6 @@ class WechatPay
try {
$response = $app->getClient()->postJson("v3/pay/transactions/jsapi", $options);
dump($response->toArray(false));
if ($response->isFailed()) {
// 出错了,处理异常
$result = $response->toArray(false);
@ -150,6 +149,7 @@ class WechatPay
if (empty($config)){
throw new BusinessException("发起支付失败");
}
return $config;
} catch (\Exception $e) {
throw new BusinessException($e->getMessage(), HttpEnumCode::SERVER_ERROR);