Closed WuRongzong closed 6 years ago
我也遇到同样问题
同遇到..
这个是一个被询问得非常频繁的问题,经验告诉我们这很可能是配置错误,例如公钥,私钥配置错误(格式错误,不匹配,失效等),具体请见FAQ自查一下。
https://github.com/lokielse/omnipay-alipay/wiki/FAQs
解决了的同志请跟帖回复一下具体的问题点和解决办法,以帮助后人。。。
和 @WuRongzong 遇到的问题一样,同步通知验证成功。在反复确认了各种钥都没错的情况下,异步通知一直出现 “The signature is not match” 的错误。后来在支付宝官方论坛里面找到了问题。
支付宝发出的通知里面有一个 fund_bill_list 参数,这个参数的值是一个 JSON 数组,有些 PHP 环境或框架会自动转义 JSON 数组,于是,通过 $request->setParams(array_merge($_POST, $_GET));
获取到的参数就是这个样子的:
[fund_bill_list] => [{\"amount\":\"0.01\",\"fundChannel\":\"ALIPAYACCOUNT\"}]
其实支付宝异步通知发出的参数是这个样子的:
[fund_bill_list] => [{"amount":"0.01","fundChannel":"ALIPAYACCOUNT"}]
设置请求参数的时候,把这个转义字符去掉就可以通过验证了。参考下面的代码:
$request->setParams(array_map('stripslashes', array_merge($_POST, $_GET)));
@lokielse 是否有必要把取消转义的功能添加到$request->setParameter
方法里?以避免这种意外的发生?
支付宝同步通知签名验证成功 支付宝异步通知 异常:“The signature is not match”
怎么回事?