问题描述
我在Symfony2 + KMJPayPalBridgeBundle的应用程序中使用了此代码段
I used this snippet in my application in Symfony2 + KMJPayPalBridgeBundle
http://paypal.github.io/PayPal-PHP-SDK/sample/doc/payments/CreatePaymentUsingPayPal.html
几个月前一切都很好,但是现在我收到不支持的SSL协议版本"错误.
Few months ago it was all good but now I'm getting "Unsupported SSL protocol version" error.
控制器代码
public function testAction()
{
$paypal = $this->get('paypal');
$apiContext = $paypal->getApiContext();
$payer = new Payer();
$payer->setPaymentMethod("paypal");
$item1 = new Item();
$item1->setName('Ground Coffee 40 oz')
->setCurrency('USD')
->setQuantity(1)
->setSku("123123"); // Similar to `item_number` in Classic API ->setPrice(7.5);
$item2 = new Item();
$item2->setName('Granola bars')
->setCurrency('USD')
->setQuantity(5)
->setSku("321321"); // Similar to `item_number` in Classic API ->setPrice(2);
$itemList = new ItemList();
$itemList->setItems(array($item1, $item2));
$details = new Details();
$details->setShipping(1.2)
->setTax(1.3)
->setSubtotal(17.50);
$amount = new Amount();
$amount->setCurrency("USD")
->setTotal(20)
->setDetails($details);
$transaction = new Transaction();
$transaction->setAmount($amount)
->setItemList($itemList)
->setDescription("Payment description")
->setInvoiceNumber(uniqid());
$baseUrl = "http://development.local";
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl("$baseUrl/ExecutePayment.php?success=true")
->setCancelUrl("$baseUrl/ExecutePayment.php?success=false");
$payment = new Payment();
$payment->setIntent("sale")
->setPayer($payer)
->setRedirectUrls($redirectUrls)
->setTransactions(array($transaction));
$request = clone $payment;
try { $payment->create($apiContext); } catch (Exception $ex) {
ResultPrinter::printError("Created Payment Using PayPal. Please visit the URL to Approve.",
"Payment", null, $request, $ex); exit(1);
}
$approvalUrl = $payment->getApprovalLink();
ResultPrinter::printResult("Created Payment Using PayPal. Please visit the URL to Approve.",
"Payment", "<a href='$approvalUrl' >$approvalUrl</a>", $request, $payment);
return array();
}
推荐答案
您是否正在针对PayPal Sandbox API端点进行测试?
PayPal昨晚升级了其Sandbox API端点,以要求TLS 1.2并(仅)提供SHA256签名的证书.
Are you testing against the PayPal Sandbox API endpoints?
PayPal upgraded their Sandbox API endpoints last night to require TLS 1.2 and offering (only) a SHA256-signed certificate.
听起来,您要么尝试强制执行TLS 1.2以外的其他功能,要么您的openssl库太旧了,不支持TLS 1.2(低于OpenSSL 1.0.1c的任何东西,所以可能性不大) ).
By the sounds of it, you're either trying to enforce something other than TLS 1.2 (likely), or your openssl libs are so old, they don't support TLS 1.2 (anything below OpenSSL 1.0.1c, so unlikely).
您可能想尝试运行 TlsCheck. PHP (来自SDK)
You may want to try running TlsCheck.php from the SDK
这篇关于PayPal-PHP-SDK中不支持的SSL协议版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!