Fixing handling of PPConnectionException in sample code

This commit is contained in:
aydiv
2013-08-20 15:49:40 +05:30
parent 975afcda1b
commit 6126997abf
29 changed files with 612 additions and 601 deletions

View File

@@ -14,28 +14,29 @@ use PayPal\Api\Payment;
use PayPal\Api\FundingInstrument;
use PayPal\Api\Transaction;
// create payment to get authorization Id
$authId = createAuthorization($apiContext);
$amt = new Amount();
$amt->setCurrency("USD");
$amt->setTotal("1.00");
### Capture
$capture = new Capture();
$capture->setId($authId);
$capture->setAmount($amt);
// get the authorization
$authorization = Authorization::get($authId, $apiContext);
// ### Capture Payment
// Capture Payment by posting to the APIService
// 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);
$amt = new Amount();
$amt->setCurrency("USD");
$amt->setTotal("1.00");
### Capture
$capture = new Capture();
$capture->setId($authId);
$capture->setAmount($amt);
// get the authorization
$authorization = Authorization::get($authId, $apiContext);
$getCapture = $authorization->capture($capture, $apiContext);
} catch (\PPConnectionException $ex) {
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
@@ -99,4 +100,4 @@ function createAuthorization($apiContext)
$resArray = $paymnt->toArray();
return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id'];
}
}