Updates to Sample Code

- Updated UI Presentation on samples
- Fixed Bugs
This commit is contained in:
japatel
2014-11-02 17:06:58 -06:00
parent 4d481ad104
commit 3c02790138
97 changed files with 904 additions and 1249 deletions

View File

@@ -3,8 +3,8 @@
// This sample code demonstrates how you can reauthorize a PayPal
// account payment.
// API used: v1/payments/authorization/{authorization_id}/reauthorize
require __DIR__ . '/../bootstrap.php';
/** @var Authorization $authorization */
$authorization = require 'AuthorizePayment.php';
use PayPal\Api\Authorization;
use PayPal\Api\Amount;
@@ -17,35 +17,18 @@ use PayPal\Api\Amount;
// has expired.
try {
// ### Lookup authorization using the authorization id
$authorization = Authorization::get('7GH53639GA425732B', $apiContext);
$amount = new Amount();
$amount->setCurrency("USD");
$amount->setTotal("1.00");
$amount = new Amount();
$amount->setCurrency("USD");
$amount->setTotal("1.00");
// ### Reauthorize with amount being reauthorized
$authorization->setAmount($amount);
$reauthorization = $authorization->reauthorize($apiContext);
} catch (PayPal\Exception\PPConnectionException $ex) {
echo "Exception: " . $ex->getMessage() . PHP_EOL;
var_dump($ex->getData());
exit(1);
// ### Reauthorize with amount being reauthorized
$authorization->setAmount($amount);
$reAuthorization = $authorization->reauthorize($apiContext);
} catch (Exception $ex) {
ResultPrinter::printError("Reauthorize Payment", "Payment", null, null, $ex);
exit(1);
}
?>
<html>
<head>
<title>Reauthorize a payment</title>
</head>
<body>
<div>
Reauthorization Id:
<?php echo $reauthorization->getId();?>
</div>
<pre>
<?php echo $reauthorization->toJSON(128);?>
</pre>
<a href='../index.html'>Back</a>
</body>
</html>
ResultPrinter::printResult("Reauthorize Payment", "Payment", $authorization->getId(), null, $reAuthorization);