【发布时间】:2014-12-10 19:21:46
【问题描述】:
我在我的一个 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 版本号即可解决问题。但是,我仍然担心版本号1 和4 中哪个是正确的并且将来会起作用。
另外,将值从3 更改为其他值时是否存在任何安全问题?
如果有人能澄清这一点,那就太好了。再次感谢。
【问题讨论】:
-
这个答案可能对你有帮助:stackoverflow.com/questions/26379773/…
-
感谢 Eshan,我尝试按照此链接中的建议设置
CURLOPT_SSLVERSION => 4,它正在工作。
标签: php wordpress paypal openssl paypal-adaptive-payments