V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
rivercherdeeeeee
V2EX  ›  程序员

paypal 支付问题

  •  
  •   rivercherdeeeeee · 2023-06-20 16:52:31 +08:00 · 791 次点击
    这是一个创建于 522 天前的主题,其中的信息可能已经有所发展或是发生改变。

    这是封装的方法:

    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 条回复    2023-06-20 17:23:38 +08:00
    weijancc
        1
    weijancc  
       2023-06-20 17:17:39 +08:00
    换境外服务器, 目前最快的是阿里云香港, 轻量服务器才 34/月
    rivercherdeeeeee
        2
    rivercherdeeeeee  
    OP
       2023-06-20 17:18:26 +08:00
    @weijancc 就是境外服务器啊
    yinmin
        3
    yinmin  
       2023-06-20 17:23:38 +08:00
    curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2726 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 20ms · UTC 15:09 · PVG 23:09 · LAX 07:09 · JFK 10:09
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.