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

我的签名验证失败,找了半天都没找到哪儿的问题。。。 #5

Closed
wojiaowuqi opened this issue Aug 31, 2017 · 10 comments

Comments

@wojiaowuqi
Copy link

wojiaowuqi commented Aug 31, 2017

我的签名验证失败,找了半天都没找到哪儿的问题。。。

@yansongda
Copy link
Owner

  1. 请查看公钥是否填写正确

  2. 请检查 verify() 方法有无正确传递参数。

麻烦请贴出相关代码并说明问题,不然这样丝毫没有帮助的。

@wojiaowuqi
Copy link
Author

wojiaowuqi commented Aug 31, 2017

兄弟 感谢你回我信息~ 支付宝这边我大概是这样做的:

1:

            //支付宝支付
            $config_biz = [
                'subject' => $pay_info['order_info']['serve_name'],
                'out_trade_no' => $pay_info['order_info']['ordersum_no'],
                'timeout_express' => $pay_info['order_info']['timeout_express'],
                'total_amount' => '0.01',     //暂时写死
                'quit_url' => U('Mobile/Order/index', '', true, true)
            ];
            $pay = new Pay($this->alipay_config);
            $html = $pay->driver('alipay')->gateway('wap')->pay($config_biz);

2:

    /**
     * 同步接收消息
     */
    public function ReceiveReturnInfo()
    {
        $pay = new Pay($this->alipay_config);
        unset($_GET['_URL_']);
        $data = I('get.');
        var_dump($data);
        file_put_contents('./return.txt', json_encode($data), FILE_APPEND);
        if ($pay->driver('alipay')->gateway('wap')->verify($data)) {
            echo '正在等待支付宝返回结果';
        } else {
            echo '签名验证失败';
        }
    }
    /**
     * 支付异步返回信息接收
     */
    public function ReceiveNotifyInfo()
    {
        $data = I('post.');
        file_put_contents('./notify.txt', json_encode($data), FILE_APPEND);
        $pay = new Pay($this->alipay_config);
        if ($pay->driver('alipay')->gateway('wap')->verify($data)) {
            file_put_contents('./notify.txt', "收到来自支付宝的异步通知\r\n", FILE_APPEND);
            file_put_contents('./notify.txt', '订单号:' . $data['out_trade_no'] . "\r\n", FILE_APPEND);
            file_put_contents('./notify.txt', '订单金额:' . $data['total_amount'] . "\r\n\r\n", FILE_APPEND);
        } else {
            file_put_contents('./notify.txt', "收到异步通知\r\n", FILE_APPEND);
        }
        echo "success";
    }

同步返回信息(有信息返回,就是签名失败)
array(12) { ["total_amount"]=> string(4) "0.01" ["timestamp"]=> string(19) "2017-08-31 16:53:14" ["sign"]=> string(344) "DVQPFAEKG TKjQThXHuIZXltRuNLEWSNpNn181V22tMG8or XyL2tgPAUKN5aiKZY4LAqMhoBgsLcrZJ4TmXKchWWaT/YL/QVCbBhYAhZLdCsY5nLt2WFwF mhVbgMRm8ZwQYA/syHJHZu50ya6GX1aYaoUNv6veb76uXdnOF7G65CS73YUNzTKfb4m2RWnqjOAJyY GQFEGq6Ff/9cKbMOeg87u9ZLtiyF0ug7KruO/WB2qXCJnt6iaLEvfR8Or7V5MGw4fCLblHA7ZsyqHznGPkmZlfNK/aWXnHrHTMvNB//r91oMukmJ6HSQ7j9tkr3gPUrQqoSvcgJcYS83XLA==" ["trade_no"]=> string(28) "2017083121001004080222071369" ["sign_type"]=> string(4) "RSA2" ["auth_app_id"]=> string(16) "2017022405855451" ["charset"]=> string(5) "utf-8" ["seller_id"]=> string(16) "2088621295872532" ["method"]=> string(27) "alipay.trade.wap.pay.return" ["app_id"]=> string(16) "2017022405855451" ["out_trade_no"]=> string(19) "2017083116393449636" ["version"]=> string(3) "1.0" }

签名验证失败

@yansongda
Copy link
Owner

yansongda commented Aug 31, 2017

框架为 ThinkPHP

  1. 沙箱环境下测试是否都 ok,可以直接使用 readme 文档中的 APPID 、公钥、密钥。
  2. 打印出 I('get.'),排查是否 TP 增加了 其它参数;
  3. 查看支付宝公钥是否设置正确(这一步很重要,绝大多数情况就是这个问题)

@wojiaowuqi
Copy link
Author

找到问题了 返回信息的引号“被转义了 我也是醉了 。。。总之还是得谢谢你

@leupom
Copy link

leupom commented Dec 22, 2017

@wojiaowuqi 哪个字段被转义了?我也是死活验签失败,公钥、私钥都是对的。

@Tinywan
Copy link

Tinywan commented Jun 23, 2018

@wojiaowuqi 请问你可以接收到异步消息吗?

@wojiaowuqi
Copy link
Author

@ @Tinywan 可以的

@Tinywan
Copy link

Tinywan commented Jun 23, 2018

@wojiaowuqi 你好!我用的是沙箱模式,死活就是收不到异步通知呀!
请看这里:#125

@hi2210331918
Copy link

公钥设置没问题 可还是验签失败

@hi2210331918
Copy link

找到原因了 回调时候不知道为什么多了个字段s

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

5 participants