forked from LiveCarta/PayPal-PHP-SDK
Fixing handling of PPConnectionException in sample code
This commit is contained in:
@@ -14,10 +14,6 @@ use PayPal\Api\Payment;
|
||||
use PayPal\Api\FundingInstrument;
|
||||
use PayPal\Api\Transaction;
|
||||
|
||||
// create payment to get authorization Id
|
||||
$authId = createAuthorization($apiContext);
|
||||
|
||||
$authorization = Authorization::get($authId, $apiContext);
|
||||
|
||||
|
||||
// ### VoidAuthorization
|
||||
@@ -25,8 +21,12 @@ $authorization = Authorization::get($authId, $apiContext);
|
||||
// using a valid ApiContext (See bootstrap.php for more on `ApiContext`)
|
||||
// The return object contains the status;
|
||||
try {
|
||||
// create payment to get authorization Id
|
||||
$authId = createAuthorization($apiContext);
|
||||
$authorization = Authorization::get($authId, $apiContext);
|
||||
|
||||
$void = $authorization->void($apiContext);
|
||||
} catch (\PPConnectionException $ex) {
|
||||
} catch (PayPal\Exception\PPConnectionException $ex) {
|
||||
echo "Exception: " . $ex->getMessage() . PHP_EOL;
|
||||
var_dump($ex->getData());
|
||||
exit(1);
|
||||
@@ -87,4 +87,4 @@ function createAuthorization($apiContext)
|
||||
$resArray = $paymnt->toArray();
|
||||
|
||||
return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id'];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user