醉梦人间三千年 5 months ago
parent
commit
914057f78b

+ 4 - 4
.env

@@ -65,7 +65,7 @@ AWS_USE_PATH_STYLE_ENDPOINT=false
 
 VITE_APP_NAME="${APP_NAME}"
 
-WECHAT_PAY_APPID=your_app_id
-WECHAT_PAY_MCH_ID=your_mch_id
-WECHAT_API_KEY=your_api_key
-WECHAT_PAYMENT_NOTIFY_URL=http://yourdomain.com/api/wechat/notify
+WECHAT_PAY_APPID=wxd9f14d5e42a56563
+WECHAT_PAY_MCH_ID=1695688939
+WECHAT_API_KEY=niusenyunXiaodingkeji666Liuzong6
+WECHAT_PAYMENT_NOTIFY_URL=/frontend/client/wechat/payment/notify

+ 43 - 0
app/Http/Controllers/Frontend/Client/Wechat/PaymentController.php

@@ -0,0 +1,43 @@
+<?php
+/**
+ * @Name
+ * @Description
+ * @Author 刘学玺
+ * @Date 2024/10/18 10:11
+ */
+
+namespace App\Http\Controllers\Frontend\Client\Wechat;
+
+use App\Http\Controllers\Controller;
+use App\Http\Requests\Request;
+use App\Http\Services\Frontend\Client\Wechat\PaymentService;
+use Illuminate\Http\JsonResponse;
+use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
+
+class PaymentController extends Controller
+{
+    protected PaymentService $service;
+
+    public function __construct(PaymentService $service)
+    {
+        $this->service = $service;
+    }
+
+    /**
+     * @throws TransportExceptionInterface
+     */
+    public function payment(Request $request): JsonResponse
+    {
+        $params = $request->all();
+        return self::success($this->service->payment($params));
+    }
+
+    /**
+     * @throws \Throwable
+     */
+    public function notify(): false|\Psr\Http\Message\ResponseInterface
+    {
+        $result = $this->service->notify();
+        return $result;
+    }
+}

+ 84 - 40
app/Http/Services/Frontend/Client/Service/OrderService.php

@@ -217,52 +217,96 @@ class OrderService extends Service
     /**
      * @throws ApiException
      */
-    public function updateOrder(array $data,int $id): void
+    public function updateOrder(array $data, int $id): void
     {
         $user_id = Auth::id();
         $order_id = $id;
         $order = Order::query()->find($order_id);
-        if ($order->status === 0) {
-
-            // 用户地址
-            if (isset($data['addressId'])) {
-                $address = Address::query()->where('user_id', $user_id)->find($data['addressId']);
-                !$address && self::error('地址信息错误!');
-                $order['address'] = $address['address'];
-                $order['real_address'] = $address['addressInfo'];
-                $order['address_lat'] = $address['lat'];
-                $order['address_lng'] = $address['lng'];
-                $order['mobile'] = $address['mobile'];
-                $order['adcode'] = $address['adcode'];
-                $order['user_name'] = $address['user_name'];
-            }
-            $orderModel = new Order();
-            $orderPayInfo = $orderModel->buildPayInfo($user_id, $order['project_id'], $data['useBalance'] ?? 0, $data['coachId'], $data['carType'] ?? 0, $data['couponId'] ?? 0);
-            $order->service_price = $orderPayInfo['service_price'] * 100;
-            $order->coupon_price = $orderPayInfo['coupon_price'] * 100;
-            $order->discount_price = $orderPayInfo['discount_price'] * 100;
-            $order->material_price = $orderPayInfo['material_price'] * 100;
-            $order->car_price = $orderPayInfo['car_price'] * 100;
-            $order->pay_price = $orderPayInfo['pay_price'] * 100;
-            $order->balance_price = $orderPayInfo['balance_price'] * 100;
-        } else {
-            $status = $data['status'];
-            switch ($status) {
-                // 结束订单
-                case 6:
-                    $order->status !== 5 && self::error('订单状态有误');
-                    // 查询是否存在加钟订单
-                    // 判断加钟服务是否完成
-                    $order->user_end = 1;
-                    $order->end_time = time();
-                    break;
-                case 9:
-                    !in_array($order->status, [0, 1, 2, 3]) && self::error('订单状态有误');
-                    break;
+
+        DB::beginTransaction();
+        try {
+            if ($order->status === 0) {
+                $useBalance = $data['useBalance'] ?? 0;
+                // 用户地址
+                if (isset($data['addressId'])) {
+                    $address = Address::query()->where('user_id', $user_id)->find($data['addressId']);
+                    !$address && self::error('地址信息错误!');
+                    $order['address'] = $address['address'];
+                    $order['real_address'] = $address['addressInfo'];
+                    $order['address_lat'] = $address['lat'];
+                    $order['address_lng'] = $address['lng'];
+                    $order['mobile'] = $address['mobile'];
+                    $order['adcode'] = $address['adcode'];
+                    $order['user_name'] = $address['user_name'];
+                }
+                $orderModel = new Order();
+                $orderPayInfo = $orderModel->buildPayInfo($user_id, $order['project_id'], $useBalance, $data['coachId'], $data['carType'] ?? 0, $data['couponId'] ?? 0);
+                $order->service_price = $orderPayInfo['service_price'] * 100;
+                $order->coupon_price = $orderPayInfo['coupon_price'] * 100;
+                $order->discount_price = $orderPayInfo['discount_price'] * 100;
+                $order->material_price = $orderPayInfo['material_price'] * 100;
+                $order->car_price = $orderPayInfo['car_price'] * 100;
+                $order->pay_price = $orderPayInfo['pay_price'] * 100;
+                $order->balance_price = $orderPayInfo['balance_price'] * 100;
+                // 技师
+                $order->coach_id = $orderPayInfo['coach_id'];
+
+                // 优惠卷ID
+                $order->coupon_id = $orderPayInfo['coupon_id'];
+
+                // 使用余额
+//            $order->use_balance = $useBalance;
+
+                // 变更用户余额
+                if ($useBalance && round($orderPayInfo['balance_price'], 2) > 0) {
+                    $memberQuery = \App\Models\Member\User::query();
+                    $member = $memberQuery->lockForUpdate()->find($user_id);
+
+                    Benefit::query()->create([
+                        'user_id' => $user_id,
+                        'order_id' => $order_id,
+                        'type' => 1,
+                        'benefit' => round($orderPayInfo['balance_price'], 2) * -100,
+                        'balance' => round($member['balance'], 2) * 100
+                    ]);
+                    $member->decrement('balance', round($orderPayInfo['balance_price'], 2) * 100);
+                }
+
+                //默认微信
+                $order->pay_type = $order['payType'] ?? 1;
+
+                // 订单状态
+                if ($useBalance && !round($orderPayInfo['pay_price'], 2)) {
+                    $order->status = 1;
+                    $order->pay_time = time();
+                    $order->pay_type = 0;
+                }
+
+            } else {
+                $status = $data['status'];
+                switch ($status) {
+                    // 结束订单
+                    case 6:
+                        $order->status !== 5 && self::error('订单状态有误');
+                        // 查询是否存在加钟订单
+                        // 判断加钟服务是否完成
+                        $order->user_end = 1;
+                        $order->end_time = time();
+                        break;
+                    case 9:
+                        !in_array($order->status, [0, 1, 2, 3]) && self::error('订单状态有误');
+                        break;
+                }
+                $order->status = $status;
             }
-            $order->status = $status;
+            $order->save();
+            DB::commit();
+        }
+        catch (\Exception $e){
+            DB::rollBack();
+            Log::error($e->getMessage());
+            self::error($e->getMessage());
         }
-        $order->save();
     }
 
     public function delOrder(int $order_id): void

+ 88 - 3
app/Http/Services/Frontend/Client/Wechat/PaymentService.php

@@ -9,21 +9,80 @@
 namespace App\Http\Services\Frontend\Client\Wechat;
 
 use App\Http\Services\Service;
+use App\Models\Member\User;
 use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
 use EasyWeChat\Kernel\Exceptions\InvalidConfigException;
 use EasyWeChat\Kernel\Exceptions\RuntimeException;
 use EasyWeChat\Pay\Message;
 use Exception;
+use Faker\Provider\Payment;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Log;
 use Overtrue\LaravelWeChat\EasyWeChat;
+use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
+use Throwable;
+use EasyWeChat\Pay\Application;
 
 class PaymentService extends Service
 {
     /**
-     * @throws InvalidArgumentException
-     * @throws InvalidConfigException
+     * @throws TransportExceptionInterface
      */
-    public function pay()
+    public function payment(array $params)
     {
+        try {
+
+            $openid = User::query()->where('id', Auth::id())->value('openid');
+            $pay = EasyWeChat::pay();
+            $merchant = $pay->getMerchant();
+
+//            $app = EasyWeChat::officialAccount();
+//            $client = $app->getClient();
+
+            $config = EasyWeChat::pay()->getConfig();
+            $app = new Application($config);
+
+            $response = $app->getClient()->postJson("https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi", [
+                "mchid" => (string)$merchant->getMerchantId(), // <---- 请修改为您的商户号
+                "out_trade_no" => uniqid('native') . rand(1, 1000), // "native12177525012012070352333'.rand(1,1000).'",
+                "appid" => $app->getConfig()->get('app_id'), // <---- 请修改为服务号的 appid
+                "description" => "Image形象店-深圳腾大-QQ公仔",
+                "notify_url" => env('BACKEND_URL') . env('WECHAT_PAYMENT_NOTIFY_URL'),
+                "amount" => [
+                    "total" => 1,
+                    "currency" => "CNY"
+                ],
+                "payer" => [
+                    "openid" => $openid // <---- 请修改为服务号下单用户的 openid
+                ]
+            ]);
+
+            $app->getValidator()->validate($response->toPsrResponse());
+            // 验证通过
+//            dd($response->toArray(false));
+            $prepayId = $response['prepay_id'];
+            $sign = [
+                'appId' => $config['app_id'], // 公众号 appid
+                'timeStamp' => (string)time(), // 时间戳
+                'nonceStr' => uniqid(), // 随机字符串
+                'package' => 'prepay_id=' . $prepayId, // prepay_id
+                'signType' => 'RSA', // 签名类型,默认为 MD5
+            ];
+            // 对参数进行排序并拼接成字符串
+            ksort($sign);
+            $stringA = urldecode(http_build_query($sign));
+            $privateKey  =file_get_contents( $config['private_key']); // 拼接 key
+
+
+            // 使用 OpenSSL 生成签名
+            openssl_sign($stringA, $signature, $privateKey, OPENSSL_ALGO_SHA256);
+
+            $sign['paySign'] = base64_encode($signature); // 生成签名
+            return $sign;
+
+        } catch (\Exception $e) {
+            return response()->json(['error' => $e->getMessage()], 500);
+        }
 //        $app = EasyWeChat::pay();
 //
 //        $server = $app->getServer();
@@ -39,4 +98,30 @@ class PaymentService extends Service
 //        });
 //        return $server->serve();
     }
+
+    /**
+     * @throws Throwable
+     */
+    public function notify(): false|\Psr\Http\Message\ResponseInterface
+    {
+        try {
+            $pay = EasyWeChat::pay();
+            $server = $pay->getServer();
+            $server->handlePaid(function (Message $message, \Closure $next) {
+                // $message->out_trade_no 获取商户订单号
+                // $message->payer['openid'] 获取支付者 openid
+                // 🚨🚨🚨 注意:推送信息不一定靠谱哈,请务必验证
+                // 建议是拿订单号调用微信支付查询接口,以查询到的订单状态为准
+                Log::log('success', 'payNotify', (array)$message);
+                return $next($message);
+            });
+
+// 默认返回 ['code' => 'SUCCESS', 'message' => '成功']
+            return $server->serve();
+        } catch (Exception $e) {
+            Log::log('error', $e->getMessage());
+            return false;
+        }
+
+    }
 }

+ 1 - 1
app/Models/Service/Order.php

@@ -37,7 +37,7 @@ class Order extends Model
 
             $project_id = $order['project_id'];
 
-            $use_balance = +$order['balance_price'] > 0 ? 1 : 0;
+//            $use_balance =  +$order['balance_price'] > 0 ? 1 : 0;
         }
 
         $data['project_id'] = $project_id;

+ 2 - 1
composer.json

@@ -13,7 +13,8 @@
         "laravel/tinker": "^2.9",
         "overtrue/laravel-wechat": "^7.3",
         "simplesoftwareio/simple-qrcode": "^4.2",
-        "spatie/laravel-permission": "^6.9"
+        "spatie/laravel-permission": "^6.9",
+        "ext-openssl": "*"
     },
     "require-dev": {
         "fakerphp/faker": "^1.23",

+ 55 - 55
composer.lock

@@ -4,7 +4,7 @@
         "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
         "This file is @generated automatically"
     ],
-    "content-hash": "859ff6b848c8bd9da31fd1a530ba2379",
+    "content-hash": "e0924246d3b2b98e5029e3ea4f06c23b",
     "packages": [
         {
             "name": "bacon/bacon-qr-code",
@@ -1194,16 +1194,16 @@
         },
         {
             "name": "guzzlehttp/promises",
-            "version": "2.0.3",
+            "version": "2.0.4",
             "source": {
                 "type": "git",
                 "url": "https://github.com/guzzle/promises.git",
-                "reference": "6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8"
+                "reference": "f9c436286ab2892c7db7be8c8da4ef61ccf7b455"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/guzzle/promises/zipball/6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8",
-                "reference": "6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8",
+                "url": "https://api.github.com/repos/guzzle/promises/zipball/f9c436286ab2892c7db7be8c8da4ef61ccf7b455",
+                "reference": "f9c436286ab2892c7db7be8c8da4ef61ccf7b455",
                 "shasum": ""
             },
             "require": {
@@ -1257,7 +1257,7 @@
             ],
             "support": {
                 "issues": "https://github.com/guzzle/promises/issues",
-                "source": "https://github.com/guzzle/promises/tree/2.0.3"
+                "source": "https://github.com/guzzle/promises/tree/2.0.4"
             },
             "funding": [
                 {
@@ -1273,7 +1273,7 @@
                     "type": "tidelift"
                 }
             ],
-            "time": "2024-07-18T10:29:17+00:00"
+            "time": "2024-10-17T10:06:22+00:00"
         },
         {
             "name": "guzzlehttp/psr7",
@@ -1542,16 +1542,16 @@
         },
         {
             "name": "laravel/framework",
-            "version": "v11.27.2",
+            "version": "v11.28.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/laravel/framework.git",
-                "reference": "a51d1f2b771c542324a3d9b76a98b1bbc75c0ee9"
+                "reference": "3ef5c8a85b4c598d5ffaf98afd72f6a5d6a0be2c"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/laravel/framework/zipball/a51d1f2b771c542324a3d9b76a98b1bbc75c0ee9",
-                "reference": "a51d1f2b771c542324a3d9b76a98b1bbc75c0ee9",
+                "url": "https://api.github.com/repos/laravel/framework/zipball/3ef5c8a85b4c598d5ffaf98afd72f6a5d6a0be2c",
+                "reference": "3ef5c8a85b4c598d5ffaf98afd72f6a5d6a0be2c",
                 "shasum": ""
             },
             "require": {
@@ -1747,20 +1747,20 @@
                 "issues": "https://github.com/laravel/framework/issues",
                 "source": "https://github.com/laravel/framework"
             },
-            "time": "2024-10-09T04:17:35+00:00"
+            "time": "2024-10-16T16:32:21+00:00"
         },
         {
             "name": "laravel/prompts",
-            "version": "v0.3.0",
+            "version": "v0.3.1",
             "source": {
                 "type": "git",
                 "url": "https://github.com/laravel/prompts.git",
-                "reference": "ea57a2261093986721d4a5f4f9524d76f21f9fa0"
+                "reference": "0f3848a445562dac376b27968f753c65e7e1036e"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/laravel/prompts/zipball/ea57a2261093986721d4a5f4f9524d76f21f9fa0",
-                "reference": "ea57a2261093986721d4a5f4f9524d76f21f9fa0",
+                "url": "https://api.github.com/repos/laravel/prompts/zipball/0f3848a445562dac376b27968f753c65e7e1036e",
+                "reference": "0f3848a445562dac376b27968f753c65e7e1036e",
                 "shasum": ""
             },
             "require": {
@@ -1804,9 +1804,9 @@
             "description": "Add beautiful and user-friendly forms to your command-line applications.",
             "support": {
                 "issues": "https://github.com/laravel/prompts/issues",
-                "source": "https://github.com/laravel/prompts/tree/v0.3.0"
+                "source": "https://github.com/laravel/prompts/tree/v0.3.1"
             },
-            "time": "2024-09-30T14:27:51+00:00"
+            "time": "2024-10-09T19:42:26+00:00"
         },
         {
             "name": "laravel/sanctum",
@@ -2790,32 +2790,31 @@
         },
         {
             "name": "nunomaduro/termwind",
-            "version": "v2.1.0",
+            "version": "v2.2.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/nunomaduro/termwind.git",
-                "reference": "e5f21eade88689536c0cdad4c3cd75f3ed26e01a"
+                "reference": "42c84e4e8090766bbd6445d06cd6e57650626ea3"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/nunomaduro/termwind/zipball/e5f21eade88689536c0cdad4c3cd75f3ed26e01a",
-                "reference": "e5f21eade88689536c0cdad4c3cd75f3ed26e01a",
+                "url": "https://api.github.com/repos/nunomaduro/termwind/zipball/42c84e4e8090766bbd6445d06cd6e57650626ea3",
+                "reference": "42c84e4e8090766bbd6445d06cd6e57650626ea3",
                 "shasum": ""
             },
             "require": {
                 "ext-mbstring": "*",
                 "php": "^8.2",
-                "symfony/console": "^7.0.4"
+                "symfony/console": "^7.1.5"
             },
             "require-dev": {
-                "ergebnis/phpstan-rules": "^2.2.0",
-                "illuminate/console": "^11.1.1",
-                "laravel/pint": "^1.15.0",
-                "mockery/mockery": "^1.6.11",
-                "pestphp/pest": "^2.34.6",
-                "phpstan/phpstan": "^1.10.66",
-                "phpstan/phpstan-strict-rules": "^1.5.2",
-                "symfony/var-dumper": "^7.0.4",
+                "illuminate/console": "^11.28.0",
+                "laravel/pint": "^1.18.1",
+                "mockery/mockery": "^1.6.12",
+                "pestphp/pest": "^2.36.0",
+                "phpstan/phpstan": "^1.12.6",
+                "phpstan/phpstan-strict-rules": "^1.6.1",
+                "symfony/var-dumper": "^7.1.5",
                 "thecodingmachine/phpstan-strict-rules": "^1.0.0"
             },
             "type": "library",
@@ -2858,7 +2857,7 @@
             ],
             "support": {
                 "issues": "https://github.com/nunomaduro/termwind/issues",
-                "source": "https://github.com/nunomaduro/termwind/tree/v2.1.0"
+                "source": "https://github.com/nunomaduro/termwind/tree/v2.2.0"
             },
             "funding": [
                 {
@@ -2874,7 +2873,7 @@
                     "type": "github"
                 }
             ],
-            "time": "2024-09-05T15:25:50+00:00"
+            "time": "2024-10-15T16:15:16+00:00"
         },
         {
             "name": "nyholm/psr7",
@@ -7676,16 +7675,16 @@
         },
         {
             "name": "laravel/sail",
-            "version": "v1.35.0",
+            "version": "v1.36.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/laravel/sail.git",
-                "reference": "992bc2d9e52174c79515967f30849d21daa334d8"
+                "reference": "f184d3d687155d06bc8cb9ff6dc48596a138460c"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/laravel/sail/zipball/992bc2d9e52174c79515967f30849d21daa334d8",
-                "reference": "992bc2d9e52174c79515967f30849d21daa334d8",
+                "url": "https://api.github.com/repos/laravel/sail/zipball/f184d3d687155d06bc8cb9ff6dc48596a138460c",
+                "reference": "f184d3d687155d06bc8cb9ff6dc48596a138460c",
                 "shasum": ""
             },
             "require": {
@@ -7735,7 +7734,7 @@
                 "issues": "https://github.com/laravel/sail/issues",
                 "source": "https://github.com/laravel/sail"
             },
-            "time": "2024-10-08T14:45:26+00:00"
+            "time": "2024-10-10T13:26:02+00:00"
         },
         {
             "name": "mockery/mockery",
@@ -7882,23 +7881,23 @@
         },
         {
             "name": "nunomaduro/collision",
-            "version": "v8.4.0",
+            "version": "v8.5.0",
             "source": {
                 "type": "git",
                 "url": "https://github.com/nunomaduro/collision.git",
-                "reference": "e7d1aa8ed753f63fa816932bbc89678238843b4a"
+                "reference": "f5c101b929c958e849a633283adff296ed5f38f5"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/nunomaduro/collision/zipball/e7d1aa8ed753f63fa816932bbc89678238843b4a",
-                "reference": "e7d1aa8ed753f63fa816932bbc89678238843b4a",
+                "url": "https://api.github.com/repos/nunomaduro/collision/zipball/f5c101b929c958e849a633283adff296ed5f38f5",
+                "reference": "f5c101b929c958e849a633283adff296ed5f38f5",
                 "shasum": ""
             },
             "require": {
-                "filp/whoops": "^2.15.4",
-                "nunomaduro/termwind": "^2.0.1",
+                "filp/whoops": "^2.16.0",
+                "nunomaduro/termwind": "^2.1.0",
                 "php": "^8.2.0",
-                "symfony/console": "^7.1.3"
+                "symfony/console": "^7.1.5"
             },
             "conflict": {
                 "laravel/framework": "<11.0.0 || >=12.0.0",
@@ -7906,14 +7905,14 @@
             },
             "require-dev": {
                 "larastan/larastan": "^2.9.8",
-                "laravel/framework": "^11.19.0",
-                "laravel/pint": "^1.17.1",
-                "laravel/sail": "^1.31.0",
-                "laravel/sanctum": "^4.0.2",
-                "laravel/tinker": "^2.9.0",
-                "orchestra/testbench-core": "^9.2.3",
-                "pestphp/pest": "^2.35.0 || ^3.0.0",
-                "sebastian/environment": "^6.1.0 || ^7.0.0"
+                "laravel/framework": "^11.28.0",
+                "laravel/pint": "^1.18.1",
+                "laravel/sail": "^1.36.0",
+                "laravel/sanctum": "^4.0.3",
+                "laravel/tinker": "^2.10.0",
+                "orchestra/testbench-core": "^9.5.3",
+                "pestphp/pest": "^2.36.0 || ^3.4.0",
+                "sebastian/environment": "^6.1.0 || ^7.2.0"
             },
             "type": "library",
             "extra": {
@@ -7975,7 +7974,7 @@
                     "type": "patreon"
                 }
             ],
-            "time": "2024-08-03T15:32:23+00:00"
+            "time": "2024-10-15T16:06:32+00:00"
         },
         {
             "name": "phar-io/manifest",
@@ -9569,7 +9568,8 @@
     "prefer-stable": true,
     "prefer-lowest": false,
     "platform": {
-        "php": "^8.2"
+        "php": "^8.2",
+        "ext-openssl": "*"
     },
     "platform-dev": [],
     "plugin-api-version": "2.6.0"

+ 20 - 20
config/easywechat.php

@@ -94,31 +94,31 @@ return [
      */
      'pay' => [
          'default' => [
-             'app_id'             => env('WECHAT_PAY_APPID', ''),
-             'mch_id'             => env('WECHAT_PAY_MCH_ID', ''),
-             'private_key'        => '/data/private/certs/apiclient_key.pem',
-             'certificate'        => '/data/private/certs/apiclient_cert.pem',
+             'app_id'             => env('WECHAT_PAY_APPID', 'wxd9f14d5e42a56563'),
+             'mch_id'             => env('WECHAT_PAY_MCH_ID', '1695688939'),
+             'private_key'        => storage_path('app/wechat/certs/apiclient_key.pem'),
+             'certificate'        => storage_path('app/wechat/certs/apiclient_cert.pem'),
              'notify_url'         => env('WECHAT_PAYMENT_NOTIFY_URL',''),                           // 默认支付结果通知地址
     //          /**
     //           * 证书序列号,可通过命令从证书获取:
     //           * `openssl x509 -in application_cert.pem -noout -serial`
     //           */
-    //          'certificate_serial_no' => '6F2BADBE1738B07EE45C6A85C5F86EE343CAABC3',
-    //
-    //          'http' => [
-    //              'base_uri' => 'https://api.mch.weixin.qq.com/',
-    //          ],
-    //
-    //          // v2 API 秘钥
-    //          //'v2_secret_key' => '26db3e15cfedb44abfbb5fe94fxxxxx',
-    //
-    //          // v3 API 秘钥
-    //          //'secret_key' => '43A03299A3C3FED3D8CE7B820Fxxxxx',
-    //
-    //          // 注意 此处为微信支付平台证书 https://pay.weixin.qq.com/wiki/doc/apiv3/apis/wechatpay5_1.shtml
-    //          'platform_certs' => [
-    //              '/data/private/certs/platform_key.pem',
-    //          ],
+              'certificate_serial_no' => '6E94BD7A4E8AAE9B35D853A4725C36941ADCA75E',
+
+              'http' => [
+                  'base_uri' => 'https://api.mch.weixin.qq.com/',
+              ],
+
+              // v2 API 秘钥
+              //'v2_secret_key' => '26db3e15cfedb44abfbb5fe94fxxxxx',
+
+              // v3 API 秘钥
+              'secret_key' => 'niusenyunXiaodingkeji666Liuzong6',
+
+              // 注意 此处为微信支付平台证书 https://pay.weixin.qq.com/wiki/doc/apiv3/apis/wechatpay5_1.shtml
+              'platform_certs' => [
+                  storage_path('app/wechat/certs/platform_key.pem'),
+              ],
          ],
      ],
 

+ 3 - 0
routes/api.php

@@ -43,6 +43,9 @@ Route::prefix('client')->group(function () {
         Route::get('/bind', [ClientWechatAuthenticatedController::class, 'bind']);
 
         Route::get('/signature', [ClientWechatAuthenticatedController::class, 'signature']);
+        # 支付
+        Route::get('/payment', [\App\Http\Controllers\Frontend\Client\Wechat\PaymentController::class, 'payment']);
+        Route::post('/payment/notify', [\App\Http\Controllers\Frontend\Client\Wechat\PaymentController::class, 'notify']);
 
     });