src/Gateways/Alipay.php
public function verify($data, $sign = null, $sync = false)
    {
        if (is_null($this->userConfig->get('public_key'))) {
            throw new InvalidArgumentException('Missing Config -- [public_key]');
        }
        $sign = is_null($sign) ? $data['sign'] : $sign;
        $res = "-----BEGIN PUBLIC KEY-----\n" . wordwrap($this->userConfig->get('public_key'), 64, "\n", true) . "\n-----END PUBLIC KEY-----";
        $toVerify = $sync ? json_encode($data) : $this->getSignContent($data, true);
        return openssl_verify($toVerify, base64_decode($sign), $res, OPENSSL_ALGO_SHA256) === 1 ? $data : false;
    }
public function verify($data, $sign = null, $sync = false)
    {
        if (is_null($this->userConfig->get('public_key'))) {
            throw new InvalidArgumentException('Missing Config -- [public_key]');
        }
        $sign = is_null($sign) ? $data['sign'] : $sign;
        $res = "-----BEGIN PUBLIC KEY-----\n" . wordwrap($this->userConfig->get('public_key'), 64, "\n", true) . "\n-----END PUBLIC KEY-----";
        $toVerify = $sync ? json_encode($data) : $this->getSignContent($data, true);
        return openssl_verify($toVerify, base64_decode($sign), $res, OPENSSL_ALGO_SHA256) === 1 ? $data : false;
    }
public function verify ( $ data , $ sign = null , $ sync = false ) { if ( is_null ( $ this -> userConfig -> get ( 'public_key' ) ) ) { throw new InvalidArgumentException ( 'Missing Config -- [public_key]' ) ; } $ sign = is_null ( $ sign ) ? $ data [ 'sign' ] : $ sign ; $ res = "-----BEGIN PUBLIC KEY-----\n" . wordwrap ( $ this -> userConfig -> get ( 'public_key' ) , 64 , "\n" , true ) . "\n-----END PUBLIC KEY-----" ; $ toVerify = $ sync ? json_encode ( $ data ) : $ this -> getSignContent ( $ data , true ) ; return openssl_verify ( $ toVerify , base64_decode ( $ sign ) , $ res , OPENSSL_ALGO_SHA256 ) === 1 ? $ data : false ; }
验证支付宝支付宝通知
@param array $data 通知数据
@param null $sign 数据签名
@param bool $sync
@return array|bool
验证支付宝支付宝通知