php - PayPal 自适应支付 'Pay' 请求中抛出“PPConnectionException”异常

标签 php wordpress paypal openssl paypal-adaptive-payments

我在我的一个 WordPress 插件中集成了 PayPal 自适应支付。我的功能已完全准备就绪,并且直到昨天都运行良好。但是,当我开始进行最终测试时,我遇到了这个异常 -

PPConnectionException Object ( [url:PPConnectionException:private] => https://svcs.sandbox.paypal.com/AdaptivePayments/Pay [data:PPConnectionException:private] => [message:protected] => error:1408F10B:SSL routines:SSL3_GET_RECORD:wrong version number 
........) //I am just pasting necessary piece of error to understand the problem

我用过这个库 - https://github.com/paypal/adaptivepayments-sdk-php

我在沙盒环境下测试。

问题似乎出在 OpenSSL 或 cURL 上。

我搜索了很多解决方案,但没有找到任何有用的答案。

我还在下面粘贴了一个示例代码(这是“并行”支付方式,但这个和其他方法都不起作用)-

require_once('../PPBootStrap.php');
require_once('../Common/Constants.php');
define("DEFAULT_SELECT", "- Select -");

if(isset($_POST['receiverEmail'])) {
    $receiver = array();
    /*
     * A receiver's email address 
     */
    for($i=0; $i<count($_POST['receiverEmail']); $i++) {
        $receiver[$i] = new Receiver();
        $receiver[$i]->email = $_POST['receiverEmail'][$i];
        /*
         *      Amount to be credited to the receiver's account 
         */
        $receiver[$i]->amount = $_POST['receiverAmount'][$i];
        /*
         * Set to true to indicate a chained payment; only one receiver can be a primary receiver. Omit this field, or set it to false for simple and parallel payments. 
         */
        $receiver[$i]->primary = $_POST['primaryReceiver'][$i];

    }
    $receiverList = new ReceiverList($receiver);
}

$payRequest = new PayRequest(new RequestEnvelope("en_US"), $_POST['actionType'], $_POST['cancelUrl'], $_POST['currencyCode'], $receiverList, $_POST['returnUrl']);
// Add optional params

if($_POST["memo"] != "") {
    $payRequest->memo = $_POST["memo"];
}

$service = new AdaptivePaymentsService(Configuration::getAcctAndConfig());
try {
    /* wrap API method calls on the service object with a try catch */
    $response = $service->Pay($payRequest);
} catch(Exception $ex) {
    require_once '../Common/Error.php';
     /*******
    ***************************************************
    PLEASE NOTE: the code is breaking here, an exception is thrown
    ***************************************************
    *******/ 
    exit;
}

$_POST 数据从另一个文件传递过来。

我已将上述代码集成到我的插件中(以 WordPress 方式)。事实上,如果我直接在单独的 PHP 文件中运行上述功能,即使那样也行不通。所以,很明显问题出在其他地方。问题似乎与 PayPal 和我的服务器有关。 我没有得到,直到昨天所有的东西都在工作,但突然停止工作了。此外,我的服务器上没有任何与 openssl、cURL 或 PHP 相关的更新。

如有任何帮助,我们将不胜感激。谢谢 !!!

编辑:

更改 openssl 版本号可以解决问题。但是,我仍然担心版本号 14 中哪个版本是合适的并且将来会起作用。 另外,将值从 3 更改为其他值时是否存在任何安全问题? 如果有人能澄清这一点,那就太好了。再次感谢。

最佳答案

我遇到了同样的问题。似乎 PayPal 昨天针对安全问题进行了一些更改。下载刚刚发布的新版 PayPal PHP SDK 应该可以解决这个问题

https://github.com/paypal/rest-api-sdk-php/releases/tag/v0.13.1

关于php - PayPal 自适应支付 'Pay' 请求中抛出“PPConnectionException”异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26387235/

相关文章:

php - 用于 Paypal 的 curl_setopt cacert.pem

php - Stripe 付款后获取费用 ID 并以 PHP 形式退款

php - 存储在mysql中编码的信息

html - 样式化 Wordpress 插件复选框

php - WordPress Sage 9 - 获取 dist url?

joomla - 我如何将我的 paypal 帐户与 Virtuemart Joomla 连接?

Paypal REST API 自适应/多次付款(更改收款人)

php - 从购物车页面中删除 Woocommerce 购物车数量选择器

php - 使用 PHP 更新时,PostgreSQL 时间戳字段的格式不相同

html - wordpress 帖子标题中 3 个点的 wordpress 奇怪行为