webman yansongda 支付 一直提示找不到配置文件

默笙

问题描述

按照官方的文档来说 https://www.workerman.net/doc/webman/components/payment.html
截图

配置了 wechatpay 看下方代码 写支付的时候一直提示 "配置异常: 缺少微信配置 -- [mch_public_cert_path]", 为什么配置文件一直读不到呢?

程序代码

<?php

namespace app\index\service;

use app\common\model\SystemConfig;
use Yansongda\Artful\Artful;
use Yansongda\Artful\Contract\ConfigInterface;
use Yansongda\Pay\Pay;
use Yansongda\Pay\Service\WechatServiceProvider;
/**
     * 测试微信支付配置
     */
    public static function testWechatPay(): array
    {

        // 2. 初始化配置
        Pay::config(config('payment'));

        // 3. 测试扫码支付
        $order = [
            'out_trade_no' => time() . '',
            'total_fee' => 1,
            'body' => '测试订单',
            'spbill_create_ip' => '127.0.0.1',
            'notify_url' => 'http://localhost/notify',
        ];

        try {
            $result = Pay::wechat()->scan($order);
            return ['code' => 0, 'msg' => 'success', 'data' => $result];
        } catch (\Exception $e) {
            return ['code' => 1, 'msg' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine()];
        }
    }

报错信息

{
"code": 1,
"msg": "配置异常: 缺少微信配置 -- [mch_public_cert_path]",
"file": "C:\\Users\\Administrator\\Desktop\\ff\\webman\\vendor\\yansongda\\pay\\src\\Plugin\\Wechat\\V3\\AddPayloadSignaturePlugin.php",
"line": 79
}

操作系统及workerman/webman等框架组件具体版本

webman 2.0

"require": {
    "php": ">=8.1",
    "workerman/webman-framework": "^2.1",
    "monolog/monolog": "^2.0",
    "webman/database": "^2.1",
    "illuminate/pagination": "^12.58",
    "illuminate/events": "^12.58",
    "symfony/var-dumper": "^7.4",
    "webman/captcha": "^1.0",
    "topthink/think-template": "^3.0",
    "vlucas/phpdotenv": "^5.6",
    "intervention/image": "^3.11",
    "alibabacloud/dysmsapi-20170525": "^4.5",
    "alibabacloud/darabonba-openapi": "^0.2.17",
    "alibabacloud/darabonba": "^1.0",
    "hyperf/pimple": "~2.2.0",
    "workerman/crontab": "^1.0",
    "yansongda/pay": "~3.0"
  },  

这是所用的包

31 0 0
0个回答

🔝