Merge remote-tracking branch 'origin/main'
This commit is contained in:
@@ -127,13 +127,6 @@ class AuthController extends Controller
|
||||
$user = $request->user('api');
|
||||
$vip = VipPackage::query()->findOrFail($request->input('vip_id'));
|
||||
|
||||
if (SystemConfig::get('wechat_pay_app_id') == null ||
|
||||
SystemConfig::get('wechat_pay_mch_id') == null ||
|
||||
SystemConfig::get('wechat_pay_secret_key') == null ||
|
||||
SystemConfig::get('wechat_pay_secret_key') == null ||
|
||||
SystemConfig::get('wechat_pay_certificate') == null) {
|
||||
return $this->failed('清设置支付信息');
|
||||
}
|
||||
try {
|
||||
$res = Payment::pay(
|
||||
channel: WeChatPayNative::class,
|
||||
@@ -151,7 +144,7 @@ class AuthController extends Controller
|
||||
} catch (\Exception $e) {
|
||||
info($e->getMessage());
|
||||
|
||||
return $this->failed('支付失败!');
|
||||
return $this->failed('支付失败!'.$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,11 +16,18 @@ class WeChatPayNative
|
||||
|
||||
private Application $payApp;
|
||||
|
||||
private $appid;
|
||||
private $mchid;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->appid = SystemConfig::get('wechat_pay_app_id');
|
||||
$this->mchid = SystemConfig::get('wechat_pay_mch_id');
|
||||
|
||||
if (!empty($this->appid) && !empty(!$this->mchid)) {
|
||||
$config = [
|
||||
'appid' => SystemConfig::get('wechat_pay_app_id'),
|
||||
'mch_id' => SystemConfig::get('wechat_pay_mch_id'),
|
||||
'appid' => $this->appid,
|
||||
'mch_id' => $this->mchid,
|
||||
'secret_key' => SystemConfig::get('wechat_pay_secret_key'),
|
||||
// 商户证书
|
||||
'private_key' => SystemConfig::get('wechat_pay_secret_key'),
|
||||
@@ -32,6 +39,17 @@ class WeChatPayNative
|
||||
'throw' => false,
|
||||
],
|
||||
];
|
||||
} else {
|
||||
$config = config('services.wechat_pay');
|
||||
unset($config['platform_certs']);
|
||||
$this->appid = $config['appid'];
|
||||
$this->mchid = $config['mch_id'];
|
||||
}
|
||||
|
||||
if (empty($this->appid) || empty($this->mchid)) {
|
||||
throw new ApiCustomError('请完善支付配置信息!');
|
||||
}
|
||||
|
||||
$this->payApp = new Application($config);
|
||||
}
|
||||
|
||||
@@ -39,8 +57,8 @@ class WeChatPayNative
|
||||
public function pay($payment, array $data = []): array
|
||||
{
|
||||
$payInfo = $this->payApp->getClient()->postJson('v3/pay/transactions/native', [
|
||||
'appid' => config('services.wechat_pay.appid'),
|
||||
'mchid' => config('services.wechat_pay.mch_id'),
|
||||
'appid' => $this->appid,
|
||||
'mchid' => $this->mchid,
|
||||
'description' => data_get($data, 'description', ''),
|
||||
'out_trade_no' => $payment->no,
|
||||
'notify_url' => config('app.url').'/api/wechat/payment_notify',
|
||||
|
||||
Reference in New Issue
Block a user