修正支付配置错误
This commit is contained in:
parent
fe62ed8614
commit
45357f8028
@ -76,7 +76,7 @@ class UserController extends AbstractController
|
|||||||
|
|
||||||
// 获取预支付交易会话标识
|
// 获取预支付交易会话标识
|
||||||
$total = 0.01 * 100;
|
$total = 0.01 * 100;
|
||||||
$prepay = $WechatPay->getJsapiPrepayId("123456",$total,"o9gYG441zEAHuYoNX7lwFKiQBzKE");
|
$prepay = $WechatPay->getJsapiPrepayId("123457",$total,"o9gYG441zEAHuYoNX7lwFKiQBzKE");
|
||||||
if (empty($prepay)){
|
if (empty($prepay)){
|
||||||
return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败");
|
return fail(HttpEnumCode::SERVER_ERROR, "订单创建失败");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,14 +46,14 @@ class WechatPay
|
|||||||
public function createApp(): Application
|
public function createApp(): Application
|
||||||
{
|
{
|
||||||
$config = [
|
$config = [
|
||||||
'mch_id' => config("we_chat.pay.mch_id"),
|
'mch_id' => $this->pay_config['mch_id'],
|
||||||
|
|
||||||
// 商户证书
|
// 商户证书
|
||||||
'private_key' => __DIR__ . '/certs/1636644248/apiclient_key.pem',
|
'private_key' => __DIR__ . '/certs/1636644248/apiclient_key.pem',
|
||||||
'certificate' => __DIR__ . '/certs/1636644248/apiclient_cert.pem',
|
'certificate' => __DIR__ . '/certs/1636644248/apiclient_cert.pem',
|
||||||
|
|
||||||
// v3 API 秘钥
|
// v3 API 秘钥
|
||||||
'secret_key' => config("we_chat.pay.v3_api_secret"),
|
'secret_key' => $this->pay_config['v3_api_secret'],
|
||||||
|
|
||||||
// v2 API 秘钥
|
// v2 API 秘钥
|
||||||
'v2_secret_key' => '',
|
'v2_secret_key' => '',
|
||||||
@ -62,7 +62,7 @@ class WechatPay
|
|||||||
// 下载工具:https://github.com/wechatpay-apiv3/CertificateDownloader
|
// 下载工具:https://github.com/wechatpay-apiv3/CertificateDownloader
|
||||||
'platform_certs' => [
|
'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 {
|
try {
|
||||||
$response = $app->getClient()->postJson("v3/pay/transactions/jsapi", $options);
|
$response = $app->getClient()->postJson("v3/pay/transactions/jsapi", $options);
|
||||||
dump($response->toArray(false));
|
|
||||||
if ($response->isFailed()) {
|
if ($response->isFailed()) {
|
||||||
// 出错了,处理异常
|
// 出错了,处理异常
|
||||||
$result = $response->toArray(false);
|
$result = $response->toArray(false);
|
||||||
@ -150,6 +149,7 @@ class WechatPay
|
|||||||
if (empty($config)){
|
if (empty($config)){
|
||||||
throw new BusinessException("发起支付失败");
|
throw new BusinessException("发起支付失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $config;
|
return $config;
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
throw new BusinessException($e->getMessage(), HttpEnumCode::SERVER_ERROR);
|
throw new BusinessException($e->getMessage(), HttpEnumCode::SERVER_ERROR);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user