src/Common/Cmb/CmbBaseStrategy.php
protected function sendReq($json)
    {
        $client = new Client([
            'timeout' => '10.0'
        ]);
        // @note: 微信部分接口并不需要证书支持。这里为了统一，全部携带证书进行请求
        $options = [
            'headers' => [
                'content-type' => 'multipart/form-data',
            ],
            'body' => $json,
            'http_errors' => false
        ];
        $response = $client->request('POST', $this->config->getewayUrl, $options);
        if ($response->getStatusCode() != '200') {
            throw new PayException('网络发生错误，请稍后再试curl返回码：' . $response->getReasonPhrase());
        }

        $body = $response->getBody()->getContents();
        $data = json_decode($body, true);
        // TODO 检查返回的数据是否被篡改
        $flag = $this->verifySign($data);
        if (!$flag) {
            throw new PayException('微信返回数据被篡改。请检查网络是否安全！');
        }

        $rspData = $data['rspData'];
        if ($rspData['rspCode'] !== CmbConfig::SUCC_TAG) {
            throw new PayException('招商返回错误提示：' . $rspData['rspMsg']);
        }

        return $rspData;
    }
protected function sendReq($json)
    {
        $client = new Client([
            'timeout' => '10.0'
        ]);
        // @note: 微信部分接口并不需要证书支持。这里为了统一，全部携带证书进行请求
        $options = [
            'headers' => [
                'content-type' => 'multipart/form-data',
            ],
            'body' => $json,
            'http_errors' => false
        ];
        $response = $client->request('POST', $this->config->getewayUrl, $options);
        if ($response->getStatusCode() != '200') {
            throw new PayException('网络发生错误，请稍后再试curl返回码：' . $response->getReasonPhrase());
        }

        $body = $response->getBody()->getContents();
        $data = json_decode($body, true);
        // TODO 检查返回的数据是否被篡改
        $flag = $this->verifySign($data);
        if (!$flag) {
            throw new PayException('微信返回数据被篡改。请检查网络是否安全！');
        }

        $rspData = $data['rspData'];
        if ($rspData['rspCode'] !== CmbConfig::SUCC_TAG) {
            throw new PayException('招商返回错误提示：' . $rspData['rspMsg']);
        }

        return $rspData;
    }
protected function sendReq ( $ json ) { $ client = new Client ( [ 'timeout' => '10.0' ] ) ; // @note: 微信部分接口并不需要证书支持。这里为了统一，全部携带证书进行请求 $ options = [ 'headers' => [ 'content-type' => 'multipart/form-data' , ] , 'body' => $ json , 'http_errors' => false ] ; $ response = $ client -> request ( 'POST' , $ this -> config -> getewayUrl , $ options ) ; if ( $ response -> getStatusCode ( ) != '200' ) { throw new PayException ( '网络发生错误，请稍后再试curl返回码：' . $response->getReasonPhrase()) } $ body = $ response -> getBody ( ) -> getContents ( ) ; $ data = json_decode ( $ body , true ) ; // TODO 检查返回的数据是否被篡改 $ flag = $ this -> verifySign ( $ data ) ; if ( ! $ flag ) { throw new PayException ( '微信返回数据被篡改。请检查网络是否安全！'); } $ rspData = $ data [ 'rspData' ] ; if ( $ rspData [ 'rspCode' ] !== CmbConfig :: SUCC_TAG ) { throw new PayException ( '招商返回错误提示：' . $rspData['rspMs ' ) ; } return $ rspData ; }
发送完了请求
@param string $json
@return mixed
@throws PayException
@author helei
发送完了请求