diff --git a/app/Services/WeChatPayService.php b/app/Services/WeChatPayService.php index b4c2ce72..fa382360 100644 --- a/app/Services/WeChatPayService.php +++ b/app/Services/WeChatPayService.php @@ -6,6 +6,7 @@ use App\Exceptions\WeChatPayException; use Closure; use EasyWeChat\Factory; use EasyWeChat\Payment\Application; +use Illuminate\Support\Arr; class WeChatPayService { @@ -83,13 +84,11 @@ class WeChatPayService ); } - $prepayId = $result['prepay_id']; - - if ($params['trade_type'] === static::TRADE_TYPE_APP) { - return $this->app->jssdk->appConfig($prepayId); - } - - return $this->app->jssdk->bridgeConfig($prepayId, false); + return match ($params['trade_type']) { + static::TRADE_TYPE_APP => $this->app->jssdk->appConfig($result['prepay_id']), + static::TRADE_TYPE_H5 => Arr::only($result, ['mweb_url']), + default => $this->app->jssdk->bridgeConfig($result['prepay_id'], false), + }; } /**