2017-05-13 4 views
0

Ich kann nicht scheinen, um die PayPalConnectionException in PayPal-PHP-SDK zu fangen. Ich habe ein Beispiel von PayPal-PHP-SDK Github Wiki-Seite und mein Code sieht wie folgt aus:So fangen Sie 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); 
} 

Aus irgendeinem Grund ist es immer noch eine nicht abgefangene Ausnahmefehler ausgibt. Hier sind meine Protokolle:

[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 

Jede Hilfe wäre willkommen.

Antwort

0
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->getMessage(); // 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); 
} 
+0

Was macht das? – user3757605

Verwandte Themen