• 请不要在回答技术问题时复制粘贴 AI 生成的内容
rivercherdeeeeee
V2EX  ›  程序员

paypal 支付问题

  •  
  •   rivercherdeeeeee · Jun 20, 2023 · 1257 views
    This topic created in 1056 days ago, the information mentioned may be changed or developed.

    这是封装的方法:

    private function _connectByCURL($url, $body, $http_header = false, $identify = false) {

        $ch = @curl_init();
    
        if (!$ch) {
            $this->_logs[] = $this->paypal->l('Connect failed with CURL method');
        } else {
            $this->_logs[] = $this->paypal->l('Connect with CURL method successful');
            $this->_logs[] = '<b>'.$this->paypal->l('Sending this params:').'</b>';
            $this->_logs[] = $body;
            for ($attempt = 0; $attempt < 3; $attempt++) {
                @curl_setopt($ch, CURLOPT_URL, 'https://' . $url);
    
                if ($identify) {
                    @curl_setopt($ch, CURLOPT_USERPWD, Configuration::get('PAYPAL_LOGIN_CLIENT_ID') . ':' . Configuration::get('PAYPAL_LOGIN_SECRET'));
                }
    
                @curl_setopt($ch, CURLOPT_POST, true);
                if ($body) {
                    @curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
                }
    
                @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                @curl_setopt($ch, CURLOPT_HEADER, false);
                @curl_setopt($ch, CURLOPT_TIMEOUT, 30);
                curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
                @curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
                @curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
                //@curl_setopt($ch, CURLOPT_SSLVERSION, Configuration::get('PAYPAL_VERSION_TLS_CHECKED') == '1.2' ? 6 : 1);
    
                @curl_setopt($ch, CURLOPT_VERBOSE, false);
                if ($http_header) {
                    @curl_setopt($ch, CURLOPT_HTTPHEADER, $http_header);
                }
    
                $result = @curl_exec($ch);
    
                if (!$result) {
                    $this->_logs[] = $this->paypal->l('Send with CURL method failed ! Error:').' '.curl_error($ch);
                    if (curl_errno($ch)) {
                        die(var_dump(curl_error($ch)));
                        $this->_logPaypal(curl_error($ch));
                    }
                    sleep(1);
                } else {
                    $this->_logs[] = $this->paypal->l('Send with CURL method successful');
                    break;
                }
            }
    
    
    
            @curl_close($ch);
        }
        return $result ? $result : false;
    }
    

    调用这个 paypal nvp 接口时不时就报这个错误 OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to api-3t.paypal.com:443 ,或者 SSL connection timeout ,或者 OpenSSL/1.1.1u: error:14094438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error ,是什么原因导致的啊,导致网站支付经常跳转失败

    3 replies    2023-06-20 17:23:38 +08:00
    weijancc
        1
    weijancc  
       Jun 20, 2023
    换境外服务器, 目前最快的是阿里云香港, 轻量服务器才 34/月
    rivercherdeeeeee
        2
    rivercherdeeeeee  
    OP
       Jun 20, 2023
    @weijancc 就是境外服务器啊
    yinmin
        3
    yinmin  
       Jun 20, 2023
    curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1014 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 22:16 · PVG 06:16 · LAX 15:16 · JFK 18:16
    ♥ Do have faith in what you're doing.