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

微信支付异步通知,报错 #217

Closed
johnyegen opened this issue Jan 18, 2019 · 4 comments
Closed

微信支付异步通知,报错 #217

johnyegen opened this issue Jan 18, 2019 · 4 comments

Comments

@johnyegen
Copy link

johnyegen commented Jan 18, 2019

public function actionWechatNotify()
{
    $pay = Pay::wechat($this->payConfig);
    try
    {
        $data = $pay->verify();
        Log::debug('Wechat notify:', $data->toArray());
        $result = $data->all();
        // 根据数据,处理业务逻辑
        if($result->return_code == 'SUCCESS' || $result->return_msg == 'OK')
        {
            
        }
        return $pay->success();
    }
    catch (\Exception $e)
    {
        return $this->wxFail();
    }
}

以上是代码,日志报错:
2019-01-18 15:25:29 [140.207.54.75][-][-][error][TypeError] TypeError: Argument 2 passed to Symfony\Component\HttpFoundation\Request::createRequestFromFactory() must be of the type array, null given, called in /home/wwwroot/app.mildland.cn/web/vendor/symfony/http-foundation/Request.php on line 281 and defined in /home/wwwroot/app/web/vendor/symfony/http-foundation/Request.php:1916

@yansongda
Copy link
Owner

尝试下 composer update

同时,麻烦请按照 issue 模板提

感谢支持

@johnyegen
Copy link
Author

johnyegen commented Jan 18, 2019

包版本号
v 2.6.1

问题描述
composer 已经更新到最新的版本

用的是php yii2的框架,
use Symfony\Component\HttpFoundation\Response;
Response 用的是Symfony
数据格式是:'CONTENT_TYPE' => 'text/xml'

//接收异步的代码
public function actionWechatNotify()
{
    $payConfig = Json::decode( $this->_mconf['wechat_pay']);
    $pay = Pay::wechat($payConfig);
    try
    {
        $data = $pay->verify();
        $result = $data->all();
        // 根据数据,处理业务逻辑
        @XString::writeLog('wechat_pay/'.$this->_appKey.'/success', 'wx-pay:'. var_export(ArrayHelper::toArray($result),true));
        if($result->return_code == 'SUCCESS' || $result->return_msg == 'OK')
        {
            // 处理业务
        }
        return $pay->success();
    }
    catch (\Exception $e)
    {
        @XString::writeLog('wechat_pay/'.$this->_appKey.'/error', 'wx-pay:'. var_export($e->getMessage(),true));
        return $this->wxFail();
    }
}

$this->wxFail();是我自定义的报错方法,返回的是xml格式:
<return_code></return_code><return_msg></return_msg>

然后报错:
[error][TypeError] TypeError: Argument 2 passed to Symfony\Component\HttpFoundation\Request::createRequestFromFactory() must be of the type array, null given, called in /home/wwwroot/app/web/vendor/symfony/http-foundation/Request.php on line 281 and defined in /home/wwwroot/app/web/vendor/symfony/http-foundation/Request.php:1916

自定义的日志报:
Exec Date:2019-01-18-16:35:54.24418100
wx-pay:'Convert To Array Error! Invalid Xml!'

@johnyegen
Copy link
Author

我用了一个$_REQUEST,日志里面显示为空

@yansongda
Copy link
Owner

是否方便把整个 sdk 的日志文件贴出来?

This issue was closed.
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

2 participants