Paypal接口问题

这里用的是PayPal NVP API Basics提供的接口开发的一个PayPal支付
下面是是一个paypal验证的代码

   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;

            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_SSL_VERIFYPEER, false);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
            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)) {
                    $this->_logPaypal(curl_error($ch));
                }
            } else {
                $this->_logs[] = $this->paypal->l('Send with CURL method successful');
            }

            curl_close($ch);
        }

        return $result ? $result : false;
    }

这里面的$result 有时候会返回数据

array(6) { [0]=> string(28) "TOKEN=EC%2d8YS4********0C57*2105H" [1]=> string(38) "TIMESTAMP=2023%2d06%2620T06%3a54%3a19Z" [2]=> string(27) "CORRELATIONID=f3e7875ce5ab03" [3]=> string(11) "ACK=Success" [4]=> string(11) "VERSION=106" [5]=> string(14) "BUILD=580550908" }

根据接口文档paypal就算失败也会返回数据回来,但有时候会什么也不返回,连报错信息都看不见,10次测试有2次左右是不返回任何数据,大家有遇到过的吗

《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 1

你打了不少日志,应该能从日志判断吧?

1年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!