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

微信支付沙箱模式下,回调验签错误 #998

Closed
mugennsou opened this issue Nov 2, 2017 · 0 comments · Fixed by #1001
Closed

微信支付沙箱模式下,回调验签错误 #998

mugennsou opened this issue Nov 2, 2017 · 0 comments · Fixed by #1001

Comments

@mugennsou
Copy link

mugennsou commented Nov 2, 2017

我用的环境

PHP 版本:7.1
overtrue/wechat 版本:4.0 (3.0下同理)
是否使用了框架?框架名称:Laravel 5.5

问题及现象

使用微信支付沙箱模式进行调试,正确触发微信的回调,但是回调接口抛出异常

"exception":"[object] (EasyWeChat\\Payment\\Kernel\\Exceptions\\InvalidSignException(code: 0): at /vendor/overtrue/wechat/src/Payment/Notify/Handler.php:183)

翻阅源码发现验签时使用的是 $this->app['config']->key

    /**
     * Validate the request params.
     *
     * @param array $message
     *
     * @throws \EasyWeChat\Payment\Kernel\Exceptions\InvalidSignException
     */
    protected function validate(array $message)
    {
        $sign = $message['sign'];
        unset($message['sign']);

        if (Support\generate_sign($message, $this->app['config']->key) !== $sign) {
            throw new InvalidSignException();
        }
    }

在沙箱模式下,此处应当使用 https://api.mch.weixin.qq.com/sandboxnew/pay/getsignkey 请求所获取到的“验收仿真测试系统的API验签密钥”

微信文档:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=23_1

Thx.

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

Successfully merging a pull request may close this issue.

1 participant