我在我的一个 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
更改为其他值时是否存在任何安全问题?
如果有人能澄清这一点,那就太好了。再次感谢。
最佳答案
我遇到了同样的问题。似乎 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/