Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

异步通知接口地址会被重置为请求域名 #1066

Open
RenLoong opened this issue Feb 21, 2025 · 1 comment
Open

异步通知接口地址会被重置为请求域名 #1066

RenLoong opened this issue Feb 21, 2025 · 1 comment

Comments

@RenLoong
Copy link

包版本号

v3.7.10

问题描述

异步通知接口地址会被重置为请求域名

你的代码

框架为webman

使用方法为插件内的控制器调用app目录下的公共库

$notify_url=$Payment['notify_url'];
        # 判断是否为“/”结尾
        if(substr($notify_url,-1)=='/'){
            $notify_url=substr($notify_url,0,-1);
        }
        $notify_url.='/notify/wechat/'.$model->plugin.'/'.$PaymentTemplate->id;
        $config = [
            'wechat' => [
                'default' => [
                    // 必填-商户号
                    'mch_id' => $Payment['mch_id'],
                    // 选填-v2商户私钥
                    'mch_secret_key_v2' => '',
                    // 必填-v3商户秘钥
                    'mch_secret_key' => $Payment['mch_key'],
                    // 必填-商户私钥 字符串或路径
                    'mch_secret_cert' => base_path(Uploads::path($Payment['ssl_key'])),
                    // 必填-商户公钥证书路径
                    'mch_public_cert_path' => base_path(Uploads::path($Payment['ssl_cert'])),
                    // 必填
                    'notify_url' => $notify_url,
                    // 选填-公众号 的 app_id
                    'mp_app_id' => $Payment['appid'],
                    // 选填-默认为正常模式。可选为: MODE_NORMAL, MODE_SERVICE
                    'mode' => Pay::MODE_NORMAL,
                ]
            ],
            'logger' => [
                'enable' => true,
                'file' => runtime_path('logs/wechat-pay-'.date('Y-m-d').'.log'),
                'level' => 'info', // 建议生产环境等级调整为 info,开发环境为 debug
                'type' => 'single', // optional, 可选 daily.
                'max_file' => 30, // optional, 当 type 为 daily 时有效,默认 30 天
            ],
            'http' => [
                'timeout' => 5.0,
                'connect_timeout' => 5.0,
            ],
        ];
        $order = [
            'out_trade_no' => $model->trade,
            'amount' => [
                'total' => getenv('DEV')==='true'?1:$model->price*100,
            ],
            'description' => $model->title,
            'time_expire'=>date('c', strtotime($model->expire_time)),
        ];
        Log::info('wxPayPc',['order'=>$order,'config'=>$config]);
        $Pay = Pay::wechat($config)->scan($order);

报错详情

sdk 日志

[2025-02-21 15:52:41] default.INFO: wxPayPc {"order":{"out_trade_no":"20250221155241336357","amount":{"total":49800.0},"description":"充值到账50000点套餐","time_expire":"2025-02-21T16:07:41+08:00"},"config":{"wechat":{"default":{"mch_id":"","mch_secret_key_v2":"","mch_secret_key":"","mch_secret_cert":"","","notify_url":"https://api.yidevs.com/notify/wechat/apistore/2","mp_app_id":"","mode":0}},"logger":{"enable":true,"file":"/www/wwwroot/api.yidevs.com/runtime/logs/wechat-pay-2025-02-21.log","level":"info","type":"single","max_file":30},"http":{"timeout":5.0,"connect_timeout":5.0}}} []

只有我自己打印的日志,sdk并未输出日志

nginx/apache 日志

涉及到 异步通知、同步通知 的问题,请贴出来

121.51.58.173 - - [21/Feb/2025:15:53:06 +0800] "POST / HTTP/1.1" 200 24289 "-" "Mozilla/4.0"

Image

@RenLoong
Copy link
Author

这个问题是偶尔现,并不是必现,目前还没有找到必现的规律

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant