0
私はPayPal-PHP-SDKのPayPalConnectionExceptionをキャッチできないようです。私はPayPalの-PHP-SDK GithubのWikiページからの例を使用し、私のコードは次のようになります。それはまだキャッチされない例外エラーを出力し、いくつかの理由でPayPalConnectionExceptionをキャッチする方法は?
<?php
require 'start.php';
use PayPal\Api\Payment;
use PayPal\Api\PaymentExecution;
$serverName = "http://" . $_SERVER['SERVER_NAME'];
if(!isset($_GET['success'], $_GET['paymentId'], $_GET['PayerID'])){
header("Location: $serverName/cancel");
exit();
}
if((bool)$_GET['success'] === false){
header("Location: $serverName/cancel");
exit();
}
$paymentId = $_GET['paymentId'];
$payerID = $_GET['PayerID'];
$payment = Payment::get($paymentId, $paypal);
$execute = new PaymentExecution();
$execute->setPayerId($payerID);
try{
$payment->execute($execute, $paypal);
header("Location: $serverName/payments/success");
//exit();
} catch (PayPal\Exception\PayPalConnectionException $ex) {
echo $ex->getCode(); // Prints the Error Code
echo $ex->getData(); // Prints the detailed error message
die($ex);
} catch(Execption $e){
$data = json_decode($e->getData());
header("Location: $serverName/payments/failed.php?err=" . $data->message);
//echo $data->message;
die($e);
}
。ここに私のログがあります:
[Sat May 13 18:57:24.143454 2017] [fcgid:warn] [pid 29736:tid 139778838230784] mod_fcgid: stderr: PHP Fatal error: Uncaught exception 'PayPal\\Exception\\PayPalConnectionException' with message 'Got Http response code 404 when accessing https://api.paypal.com/v1/payments/payment/PAY-19837119W5913913TLEJMYYQ.' in /home/root/domains/mywebsite.com/public_html/payments/PayPal/vendor/paypal/rest-api-sdk-php/lib/PayPal/Core/PayPalHttpConnection.php:177
[Sat May 13 18:57:24.143805 2017] [fcgid:warn] [pid 29736:tid 139778838230784] mod_fcgid: stderr: Stack trace:
[Sat May 13 18:57:24.143819 2017] [fcgid:warn] [pid 29736:tid 139778838230784] mod_fcgid: stderr: #0 /home/root/domains/mywebsite.com/public_html/payments/PayPal/vendor/paypal/rest-api-sdk-php/lib/PayPal/Transport/PayPalRestCall.php(73): PayPal\\Core\\PayPalHttpConnection->execute('')
[Sat May 13 18:57:24.143831 2017] [fcgid:warn] [pid 29736:tid 139778838230784] mod_fcgid: stderr: #1 /home/root/domains/mywebsite.com/public_html/payments/PayPal/vendor/paypal/rest-api-sdk-php/lib/PayPal/Common/PayPalResourceModel.php(102): PayPal\\Transport\\PayPalRestCall->execute(Array, '/v1/payments/pa...', 'GET', '', NULL)
[Sat May 13 18:57:24.143841 2017] [fcgid:warn] [pid 29736:tid 139778838230784] mod_fcgid: stderr: #2 /home/root/domains/mywebsite.com/public_html/payments/PayPal/vendor/paypal/rest-api-sdk-php/lib/PayPal/Api/Payment.php(603): PayPal\\Common\\PayPalResourceModel::executeCall('/v1/payments/pa...', 'GET', '', NULL, Object(PayPal\\Rest\\ApiContext), NULL)
[Sat May 13 18:57:24.143853 2017] [fcgid:warn] [pid 29736:tid 139778838230784] mod_fcgid: stderr: #3 /home/root/domains/ in /home/root/domains/mywebsite.com/public_html/payments/PayPal/vendor/paypal/rest-api-sdk-php/lib/PayPal/Core/PayPalHttpConnection.php on line 177
助けていただければ幸いです。
これは何をしますか? – user3757605