diff --git a/lib/PayPal/Api/Payment.php b/lib/PayPal/Api/Payment.php index 1217a6c..b290a8d 100644 --- a/lib/PayPal/Api/Payment.php +++ b/lib/PayPal/Api/Payment.php @@ -247,7 +247,7 @@ class Payment extends ResourceModel * A payment can have more than one transaction, with each transaction establishing a contract between the payer and a payee * * - * @param \PayPal\Api\Transaction $transactions + * @param \PayPal\Api\Transaction[] $transactions * * @return $this */ diff --git a/lib/PayPal/Validation/JsonValidator.php b/lib/PayPal/Validation/JsonValidator.php index 9bba938..831c11f 100644 --- a/lib/PayPal/Validation/JsonValidator.php +++ b/lib/PayPal/Validation/JsonValidator.php @@ -14,14 +14,18 @@ class JsonValidator * Helper method for validating if string provided is a valid json. * * @param string $string String representation of Json object + * @param bool $silent Flag to not throw \InvalidArgumentException * @return bool */ - public static function validate($string) + public static function validate($string, $silent = false) { json_decode($string); if (json_last_error() != JSON_ERROR_NONE) { - //Throw an Exception for string or array - throw new \InvalidArgumentException("Invalid JSON String"); + if ($silent == false) { + //Throw an Exception for string or array + throw new \InvalidArgumentException("Invalid JSON String"); + } + return false; } return true; } diff --git a/lib/PayPal/Validation/ModelAccessorValidator.php b/lib/PayPal/Validation/ModelAccessorValidator.php index 6ae2dc9..2810e17 100644 --- a/lib/PayPal/Validation/ModelAccessorValidator.php +++ b/lib/PayPal/Validation/ModelAccessorValidator.php @@ -30,7 +30,7 @@ class ModelAccessorValidator if (!method_exists($class, $methodName)) { //Delegate the error based on the choice $className = is_object($class) ? get_class($class) : (string)$class; - $errorMessage = "Missing Accessor: $className:$methodName. Please let us know by creating an issue at https://github.com/paypal/rest-api-sdk-php/issues"; + $errorMessage = "Missing Accessor: $className:$methodName. Please let us know by creating an issue at https://github.com/paypal/PayPal-PHP-SDK/issues"; PPLoggingManager::getInstance(__CLASS__)->warning($errorMessage); if ($mode == 'strict') { trigger_error($errorMessage, E_USER_NOTICE); @@ -41,4 +41,4 @@ class ModelAccessorValidator } return true; } -} \ No newline at end of file +} diff --git a/sample/billing/CreateBillingAgreementWithCreditCard.php b/sample/billing/CreateBillingAgreementWithCreditCard.php index faab2b4..f60dde9 100644 --- a/sample/billing/CreateBillingAgreementWithCreditCard.php +++ b/sample/billing/CreateBillingAgreementWithCreditCard.php @@ -100,9 +100,8 @@ try { // Please note that as the agreement has not yet activated, we wont be receiving the ID just yet. $agreement = $agreement->create($apiContext); -} catch (PayPal\Exception\PPConnectionException $ex) { - echo "Exception: " . $ex->getMessage() . PHP_EOL; - var_dump($ex->getData()); +} catch (Exception $ex) { + ResultPrinter::printError("Created Billing Agreement.", "Agreement", $agreement->getId(), $request, $ex); exit(1); } diff --git a/sample/billing/CreateBillingAgreementWithPayPal.php b/sample/billing/CreateBillingAgreementWithPayPal.php index 8363df1..6119d2e 100644 --- a/sample/billing/CreateBillingAgreementWithPayPal.php +++ b/sample/billing/CreateBillingAgreementWithPayPal.php @@ -80,9 +80,8 @@ try { } } -} catch (PayPal\Exception\PPConnectionException $ex) { - echo "Exception: " . $ex->getMessage() . PHP_EOL; - var_dump($ex->getData()); +} catch (Exception $ex) { + ResultPrinter::printError("Created Billing Agreement.", "Agreement", null, $request, $ex); exit(1); } diff --git a/sample/billing/CreatePlan.php b/sample/billing/CreatePlan.php index 4248874..f6df53b 100644 --- a/sample/billing/CreatePlan.php +++ b/sample/billing/CreatePlan.php @@ -46,7 +46,7 @@ $merchantPreferences = new MerchantPreferences(); $baseUrl = getBaseUrl(); $merchantPreferences->setReturnUrl("$baseUrl/ExecuteAgreement.php?success=true") ->setCancelUrl("$baseUrl/ExecuteAgreement.php?success=false") - ->setAutoBillAmount("YES") + ->setAutoBillAmount("yes") ->setInitialFailAmountAction("CONTINUE") ->setMaxFailAttempts("0") ->setSetupFee(new Currency(['value' => '1', 'currency' => 'USD'])); @@ -61,9 +61,8 @@ $request = clone $plan; // ### Create Plan try { $output = $plan->create($apiContext); -} catch (PayPal\Exception\PPConnectionException $ex) { - echo "Exception: " . $ex->getMessage() . PHP_EOL; - var_dump($ex->getData()); +} catch (Exception $ex) { + ResultPrinter::printError("Created Plan", "Plan", null, $request, $ex); exit(1); } diff --git a/sample/billing/ExecuteAgreement.php b/sample/billing/ExecuteAgreement.php index 1f3cc71..351e97b 100644 --- a/sample/billing/ExecuteAgreement.php +++ b/sample/billing/ExecuteAgreement.php @@ -10,9 +10,8 @@ if (isset($_GET['success']) && $_GET['success'] == 'true') { try { $agreement->execute($token, $apiContext); - } catch (PayPal\Exception\PPConnectionException $ex) { - echo "Exception: " . $ex->getMessage() . PHP_EOL; - var_dump($ex->getData()); + } catch (Exception $ex) { + ResultPrinter::printError("Executed an Agreement", "Agreement", $agreement->getId(), $_GET['token'], $ex); exit(1); } ResultPrinter::printResult("Executed an Agreement", "Agreement", $agreement->getId(), $_GET['token'], $agreement); diff --git a/sample/billing/GetBillingAgreement.php b/sample/billing/GetBillingAgreement.php index 336678f..f62ef15 100644 --- a/sample/billing/GetBillingAgreement.php +++ b/sample/billing/GetBillingAgreement.php @@ -14,9 +14,8 @@ use PayPal\Api\Agreement; try { $agreement = Agreement::get($createdAgreement->getId(), $apiContext); -} catch (PayPal\Exception\PPConnectionException $ex) { - echo "Exception: " . $ex->getMessage() . PHP_EOL; - var_dump($ex->getData()); +} catch (Exception $ex) { + ResultPrinter::printError("Retrieved an Agreement", "Agreement", $agreement->getId(), $createdAgreement->getId(), $ex); exit(1); } diff --git a/sample/billing/GetPlan.php b/sample/billing/GetPlan.php index ceeec77..3395461 100644 --- a/sample/billing/GetPlan.php +++ b/sample/billing/GetPlan.php @@ -14,9 +14,8 @@ use PayPal\Api\Plan; try { $plan = Plan::get($createdPlan->getId(), $apiContext); -} catch (PayPal\Exception\PPConnectionException $ex) { - echo "Exception: " . $ex->getMessage() . PHP_EOL; - var_dump($ex->getData()); +} catch (Exception $ex) { + ResultPrinter::printError("Retrieved a Plan", "Plan", $plan->getId(), null, $ex); exit(1); } diff --git a/sample/billing/ListPlans.php b/sample/billing/ListPlans.php index 972ff7f..83d8c75 100644 --- a/sample/billing/ListPlans.php +++ b/sample/billing/ListPlans.php @@ -19,9 +19,8 @@ try { // at https://developer.paypal.com/webapps/developer/docs/api/#list-plans $params = array('page_size' => '2'); $planList = Plan::all($params, $apiContext); -} catch (PayPal\Exception\PPConnectionException $ex) { - echo "Exception: " . $ex->getMessage() . PHP_EOL; - var_dump($ex->getData()); +} catch (Exception $ex) { + ResultPrinter::printError("List of Plans", "Plan", null, $params, $ex); exit(1); } diff --git a/sample/billing/ReactivateBillingAgreement.php b/sample/billing/ReactivateBillingAgreement.php index d56ad35..a5c511d 100644 --- a/sample/billing/ReactivateBillingAgreement.php +++ b/sample/billing/ReactivateBillingAgreement.php @@ -24,9 +24,8 @@ try { // Lets get the updated Agreement Object $agreement = Agreement::get($suspendedAgreement->getId(), $apiContext); -} catch (PayPal\Exception\PPConnectionException $ex) { - echo "Exception: " . $ex->getMessage() . PHP_EOL; - var_dump($ex->getData()); +} catch (Exception $ex) { + ResultPrinter::printResult("Reactivate the Agreement", "Agreement", $agreement->getId(), $suspendedAgreement, $ex); exit(1); } diff --git a/sample/billing/SuspendBillingAgreement.php b/sample/billing/SuspendBillingAgreement.php index e56f289..3d5cef0 100644 --- a/sample/billing/SuspendBillingAgreement.php +++ b/sample/billing/SuspendBillingAgreement.php @@ -24,9 +24,8 @@ try { // Lets get the updated Agreement Object $agreement = Agreement::get($createdAgreement->getId(), $apiContext); -} catch (PayPal\Exception\PPConnectionException $ex) { - echo "Exception: " . $ex->getMessage() . PHP_EOL; - var_dump($ex->getData()); +} catch (Exception $ex) { + ResultPrinter::printError("Suspended the Agreement", "Agreement", null, $agreementStateDescriptor, $ex); exit(1); } diff --git a/sample/billing/UpdateBillingAgreement.php b/sample/billing/UpdateBillingAgreement.php index 7c28fe2..bc8144d 100644 --- a/sample/billing/UpdateBillingAgreement.php +++ b/sample/billing/UpdateBillingAgreement.php @@ -36,9 +36,8 @@ try { // Lets get the updated Agreement Object $agreement = Agreement::get($createdAgreement->getId(), $apiContext); -} catch (PayPal\Exception\PPConnectionException $ex) { - echo "Exception: " . $ex->getMessage() . PHP_EOL; - var_dump($ex->getData()); +} catch (Exception $ex) { + ResultPrinter::printError("Updated the Agreement with new Description and Updated Shipping Address", "Agreement", null, $patchRequest, $ex); exit(1); } diff --git a/sample/billing/UpdatePlan.php b/sample/billing/UpdatePlan.php index 9e2364e..90712db 100644 --- a/sample/billing/UpdatePlan.php +++ b/sample/billing/UpdatePlan.php @@ -34,9 +34,8 @@ try { $plan = Plan::get($createdPlan->getId(), $apiContext); -} catch (PayPal\Exception\PPConnectionException $ex) { - echo "Exception: " . $ex->getMessage() . PHP_EOL; - var_dump($ex->getData()); +} catch (Exception $ex) { + ResultPrinter::printError("Updated the Plan to Active State", "Plan", null, $patchRequest, $ex); exit(1); } diff --git a/sample/common.php b/sample/common.php index ae7db11..0b26849 100644 --- a/sample/common.php +++ b/sample/common.php @@ -17,11 +17,22 @@ use PayPal\Api\FundingInstrument; * * Class ResultPrinter */ -class ResultPrinter { +class ResultPrinter +{ private static $printResultCounter = 0; - public static function printResult($title, $objectName, $objectId = null, $request = null, $response = null) + /** + * Prints HTML Output to web page. + * + * @param string $title + * @param string $objectName + * @param string $objectId + * @param mixed $request + * @param mixed $response + * @param string $error + */ + public static function printOutput($title, $objectName, $objectId = null, $request = null, $response = null, $errorMessage = null) { if (self::$printResultCounter == 0) { include "header.html"; @@ -33,10 +44,10 @@ class ResultPrinter { self::$printResultCounter++; echo '
'. $error . ''; + } if ($object) { if (is_a($object, 'PayPal\Common\PPModel')) { /** @var $object \PayPal\Common\PPModel */ - echo '
' . $object->toJSON(128) . ""; + echo '
' . $object->toJSON(128) . ""; + } elseif (\PayPal\Validation\JsonValidator::validate($object, true)) { + echo '
'. str_replace('\\/', '/', json_encode(json_decode($object), 128)) . "";
} elseif (is_string($object)) {
- echo "$object"; + echo '
' . $object . ''; } else { echo "
";
print_r($object);
@@ -111,59 +159,3 @@ function getBaseUrl()
$request = $_SERVER['PHP_SELF'];
return dirname($protocol . '://' . $host . ($port == $protocol_port ? '' : ':' . $port) . $request);
}
-
-/**
- * Creates a new mock 'payment authorization'
- *
- * @param PayPal\Api\ApiContext apiContext
- * @return PayPal\Api\Authorization
- */
-function createAuthorization($apiContext)
-{
- $addr = new Address();
- $addr->setLine1("3909 Witmer Road")
- ->setLine2("Niagara Falls")
- ->setCity("Niagara Falls")
- ->setState("NY")
- ->setPostalCode("14305")
- ->setCountryCode("US")
- ->setPhone("716-298-1822");
-
- $card = new CreditCard();
- $card->setType("visa")
- ->setNumber("4417119669820331")
- ->setExpireMonth("11")
- ->setExpireYear("2019")
- ->setCvv2("012")
- ->setFirstName("Joe")
- ->setLastName("Shopper")
- ->setBillingAddress($addr);
-
- $fi = new FundingInstrument();
- $fi->setCreditCard($card);
-
- $payer = new Payer();
- $payer->setPaymentMethod("credit_card")
- ->setFundingInstruments(array($fi));
-
- $amount = new Amount();
- $amount->setCurrency("USD")
- ->setTotal("1.00");
-
- $transaction = new Transaction();
- $transaction->setAmount($amount)
- ->setDescription("Payment description.");
-
- $payment = new Payment();
-
-// Setting intent to authorize creates a payment
-// authorization. Setting it to sale creates actual payment
- $payment->setIntent("authorize")
- ->setPayer($payer)
- ->setTransactions(array($transaction));
-
- $paymnt = $payment->create($apiContext);
- $resArray = $paymnt->toArray();
-
- return $authId = $resArray['transactions'][0]['related_resources'][0]['authorization']['id'];
-}
diff --git a/sample/doc/assets/behavior.js b/sample/doc/assets/behavior.js
index 9cc263e..542f56f 100644
--- a/sample/doc/assets/behavior.js
+++ b/sample/doc/assets/behavior.js
@@ -1107,6 +1107,46 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3
]
}
]
+ }, {
+ "type": "file",
+ "data": {
+ "language": {
+ "nameMatchers": [{}, ".fbp"],
+ "pygmentsLexer": "php",
+ "singleLineComment": ["//"],
+ "ignorePrefix": "}",
+ "foldPrefix": "^",
+ "name": "PHP"
+ },
+ "sourcePath": "/Users/japatel/Documents/workspace/Server-SDK/rest-api-sdk-php/sample/payments/AuthorizePayment.php",
+ "projectPath": "payments/AuthorizePayment.php",
+ "targetPath": "payments/AuthorizePayment",
+ "pageTitle": "payments/AuthorizePayment",
+ "title": "AuthorizePayment"
+ },
+ "depth": 2,
+ "outline": [
+ {
+ "type": "heading",
+ "data": {
+ "level": 1,
+ "title": "Authorize Payment",
+ "slug": "authorize-payment"
+ },
+ "depth": 1,
+ "children": [
+ {
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Create Payment",
+ "slug": "create-payment"
+ },
+ "depth": 3
+ }
+ ]
+ }
+ ]
}, {
"type": "file",
"data": {
@@ -1399,14 +1439,6 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3
"slug": "get-redirect-url"
},
"depth": 3
- }, {
- "type": "heading",
- "data": {
- "level": 3,
- "title": "Redirect buyer to PayPal website",
- "slug": "redirect-buyer-to-paypal-website"
- },
- "depth": 3
}
]
}
@@ -1613,14 +1645,6 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3
"depth": 1,
"children": [
{
- "type": "heading",
- "data": {
- "level": 3,
- "title": "Create a mock Capture",
- "slug": "create-a-mock-capture"
- },
- "depth": 3
- }, {
"type": "heading",
"data": {
"level": 3,
@@ -1748,14 +1772,6 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3
"slug": "reauthorization"
},
"depth": 3
- }, {
- "type": "heading",
- "data": {
- "level": 3,
- "title": "Lookup authorization using the authorization id",
- "slug": "lookup-authorization-using-the-authorization-id"
- },
- "depth": 3
}, {
"type": "heading",
"data": {
@@ -1797,14 +1813,6 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3
"depth": 1,
"children": [
{
- "type": "heading",
- "data": {
- "level": 3,
- "title": "Capture",
- "slug": "capture"
- },
- "depth": 3
- }, {
"type": "heading",
"data": {
"level": 3,
@@ -1895,6 +1903,14 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3
"depth": 1,
"children": [
{
+ "type": "heading",
+ "data": {
+ "level": 3,
+ "title": "Get Sale From Created Payment",
+ "slug": "get-sale-from-created-payment"
+ },
+ "depth": 3
+ }, {
"type": "heading",
"data": {
"level": 3,
@@ -2049,22 +2065,6 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3
"depth": 1,
"children": [
{
- "type": "heading",
- "data": {
- "level": 3,
- "title": "CreditCard",
- "slug": "creditcard"
- },
- "depth": 3
- }, {
- "type": "heading",
- "data": {
- "level": 3,
- "title": "Save card",
- "slug": "save-card"
- },
- "depth": 3
- }, {
"type": "heading",
"data": {
"level": 3,
diff --git a/sample/doc/billing/CreateBillingAgreementWithCreditCard.html b/sample/doc/billing/CreateBillingAgreementWithCreditCard.html
index dae828c..d6786a3 100644
--- a/sample/doc/billing/CreateBillingAgreementWithCreditCard.html
+++ b/sample/doc/billing/CreateBillingAgreementWithCreditCard.html
@@ -74,9 +74,8 @@ Please note that the plan Id should be only set in this case.'US');
$agreement->setShippingAddress($shippingAddress);$request = clone $agreement;Create Agreement
try {Please note that as the agreement has not yet activated, we wont be receiving the ID just yet.
$agreement = $agreement->create($apiContext);
-} catch (PayPal\Exception\PPConnectionException $ex) {
- echo "Exception: " . $ex->getMessage() . PHP_EOL;
- var_dump($ex->getData());
+} catch (Exception $ex) {
+ ResultPrinter::printError("Created Billing Agreement.", "Agreement", $agreement->getId(), $request, $ex);
exit(1);
}
diff --git a/sample/doc/billing/CreateBillingAgreementWithPayPal.html b/sample/doc/billing/CreateBillingAgreementWithPayPal.html
index a5c4334..765aadd 100644
--- a/sample/doc/billing/CreateBillingAgreementWithPayPal.html
+++ b/sample/doc/billing/CreateBillingAgreementWithPayPal.html
@@ -54,9 +54,8 @@ method catch (PayPal\Exception\PPConnectionException $ex) {
- echo "Exception: " . $ex->getMessage() . PHP_EOL;
- var_dump($ex->getData());
+} catch (Exception $ex) {
+ ResultPrinter::printError("Created Billing Agreement.", "Agreement", null, $request, $ex);
exit(1);
}
diff --git a/sample/doc/billing/CreatePlan.html b/sample/doc/billing/CreatePlan.html
index e22e688..802c519 100644
--- a/sample/doc/billing/CreatePlan.html
+++ b/sample/doc/billing/CreatePlan.html
@@ -26,7 +26,7 @@ You should be able to see the acceptable values in the comments.
$baseUrl = getBaseUrl();
$merchantPreferences->setReturnUrl("$baseUrl/ExecuteAgreement.php?success=true")
->setCancelUrl("$baseUrl/ExecuteAgreement.php?success=false")
- ->setAutoBillAmount("YES")
+ ->setAutoBillAmount("yes")
->setInitialFailAmountAction("CONTINUE")
->setMaxFailAttempts("0")
->setSetupFee(new Currency(['value' => '1', 'currency' => 'USD']));
@@ -35,9 +35,8 @@ You should be able to see the acceptable values in the comments.
$plan->setPaymentDefinitions(array($paymentDefinition));
$plan->setMerchantPreferences($merchantPreferences);For Sample Purposes Only.
$request = clone $plan;Create Plan
try {
$output = $plan->create($apiContext);
-} catch (PayPal\Exception\PPConnectionException $ex) {
- echo "Exception: " . $ex->getMessage() . PHP_EOL;
- var_dump($ex->getData());
+} catch (Exception $ex) {
+ ResultPrinter::printError("Created Plan", "Plan", null, $request, $ex);
exit(1);
}
diff --git a/sample/doc/billing/ExecuteAgreement.html b/sample/doc/billing/ExecuteAgreement.html
index c0bf4df..3a0bc3d 100644
--- a/sample/doc/billing/ExecuteAgreement.html
+++ b/sample/doc/billing/ExecuteAgreement.html
@@ -10,9 +10,8 @@ session_start();
try {
$agreement->execute($token, $apiContext);
- } catch (PayPal\Exception\PPConnectionException $ex) {
- echo "Exception: " . $ex->getMessage() . PHP_EOL;
- var_dump($ex->getData());
+ } catch (Exception $ex) {
+ ResultPrinter::printError("Executed an Agreement", "Agreement", $agreement->getId(), $_GET['token'], $ex);
exit(1);
}
ResultPrinter::printResult("Executed an Agreement", "Agreement", $agreement->getId(), $_GET['token'], $agreement);
diff --git a/sample/doc/billing/GetBillingAgreement.html b/sample/doc/billing/GetBillingAgreement.html
index 778c5f7..b456c1a 100644
--- a/sample/doc/billing/GetBillingAgreement.html
+++ b/sample/doc/billing/GetBillingAgreement.html
@@ -8,9 +8,8 @@ API used: /v1/payments/billing-agreements/try {
$agreement = Agreement::get($createdAgreement->getId(), $apiContext);
-} catch (PayPal\Exception\PPConnectionException $ex) {
- echo "Exception: " . $ex->getMessage() . PHP_EOL;
- var_dump($ex->getData());
+} catch (Exception $ex) {
+ ResultPrinter::printError("Retrieved an Agreement", "Agreement", $agreement->getId(), $createdAgreement->getId(), $ex);
exit(1);
}
diff --git a/sample/doc/billing/GetPlan.html b/sample/doc/billing/GetPlan.html
index 68d3460..fefab87 100644
--- a/sample/doc/billing/GetPlan.html
+++ b/sample/doc/billing/GetPlan.html
@@ -8,9 +8,8 @@ API used: /v1/payments/billing-plans<
try {
$plan = Plan::get($createdPlan->getId(), $apiContext);
-} catch (PayPal\Exception\PPConnectionException $ex) {
- echo "Exception: " . $ex->getMessage() . PHP_EOL;
- var_dump($ex->getData());
+} catch (Exception $ex) {
+ ResultPrinter::printError("Retrieved a Plan", "Plan", $plan->getId(), null, $ex);
exit(1);
}
diff --git a/sample/doc/billing/ListPlans.html b/sample/doc/billing/ListPlans.html
index 02c24c3..46901e0 100644
--- a/sample/doc/billing/ListPlans.html
+++ b/sample/doc/billing/ListPlans.html
@@ -11,9 +11,8 @@ You can modify different params to change the return list.
The explanation about each pagination information could be found here
at https://developer.paypal.com/webapps/developer/docs/api/#list-plans $params = array('page_size' => '2');
$planList = Plan::all($params, $apiContext);
-} catch (PayPal\Exception\PPConnectionException $ex) {
- echo "Exception: " . $ex->getMessage() . PHP_EOL;
- var_dump($ex->getData());
+} catch (Exception $ex) {
+ ResultPrinter::printError("List of Plans", "Plan", null, $params, $ex);
exit(1);
}
diff --git a/sample/doc/billing/ReactivateBillingAgreement.html b/sample/doc/billing/ReactivateBillingAgreement.html
index c0753f2..e3895a2 100644
--- a/sample/doc/billing/ReactivateBillingAgreement.html
+++ b/sample/doc/billing/ReactivateBillingAgreement.html
@@ -15,9 +15,8 @@ API used: /v1/payments/billing-agreements//suspend
$suspendedAgreement->reActivate($agreementStateDescriptor, $apiContext);Lets get the updated Agreement Object
$agreement = Agreement::get($suspendedAgreement->getId(), $apiContext);
-} catch (PayPal\Exception\PPConnectionException $ex) {
- echo "Exception: " . $ex->getMessage() . PHP_EOL;
- var_dump($ex->getData());
+} catch (Exception $ex) {
+ ResultPrinter::printResult("Reactivate the Agreement", "Agreement", $agreement->getId(), $suspendedAgreement, $ex);
exit(1);
}
diff --git a/sample/doc/billing/SuspendBillingAgreement.html b/sample/doc/billing/SuspendBillingAgreement.html
index 9d6101b..ce39717 100644
--- a/sample/doc/billing/SuspendBillingAgreement.html
+++ b/sample/doc/billing/SuspendBillingAgreement.html
@@ -15,9 +15,8 @@ API used: /v1/payments/billing-agreements//suspend
$createdAgreement->suspend($agreementStateDescriptor, $apiContext);Lets get the updated Agreement Object
$agreement = Agreement::get($createdAgreement->getId(), $apiContext);
-} catch (PayPal\Exception\PPConnectionException $ex) {
- echo "Exception: " . $ex->getMessage() . PHP_EOL;
- var_dump($ex->getData());
+} catch (Exception $ex) {
+ ResultPrinter::printError("Suspended the Agreement", "Agreement", null, $agreementStateDescriptor, $ex);
exit(1);
}
diff --git a/sample/doc/billing/UpdateBillingAgreement.html b/sample/doc/billing/UpdateBillingAgreement.html
index 602f0de..cd79371 100644
--- a/sample/doc/billing/UpdateBillingAgreement.html
+++ b/sample/doc/billing/UpdateBillingAgreement.html
@@ -27,9 +27,8 @@ API used: /v1/payments/billing-agreements/try {
$createdAgreement->update($patchRequest, $apiContext);Lets get the updated Agreement Object
$agreement = Agreement::get($createdAgreement->getId(), $apiContext);
-} catch (PayPal\Exception\PPConnectionException $ex) {
- echo "Exception: " . $ex->getMessage() . PHP_EOL;
- var_dump($ex->getData());
+} catch (Exception $ex) {
+ ResultPrinter::printError("Updated the Agreement with new Description and Updated Shipping Address", "Agreement", null, $patchRequest, $ex);
exit(1);
}
diff --git a/sample/doc/billing/UpdatePlan.html b/sample/doc/billing/UpdatePlan.html
index be2dff4..6158cfc 100644
--- a/sample/doc/billing/UpdatePlan.html
+++ b/sample/doc/billing/UpdatePlan.html
@@ -26,9 +26,8 @@ API used: /v1/payments/billing-plans/ $plan = Plan::get($createdPlan->getId(), $apiContext);
-} catch (PayPal\Exception\PPConnectionException $ex) {
- echo "Exception: " . $ex->getMessage() . PHP_EOL;
- var_dump($ex->getData());
+} catch (Exception $ex) {
+ ResultPrinter::printError("Updated the Plan to Active State", "Plan", null, $patchRequest, $ex);
exit(1);
}
diff --git a/sample/doc/invoice/CancelInvoice.html b/sample/doc/invoice/CancelInvoice.html
index 286a67e..1174ee8 100644
--- a/sample/doc/invoice/CancelInvoice.html
+++ b/sample/doc/invoice/CancelInvoice.html
@@ -24,9 +24,8 @@ static cancel method
on the Invoice class by passing a valid
notification object
(See bootstrap.php for more on ApiContext) $cancelStatus = $invoice->cancel($notify, $apiContext);
-} catch (PayPal\Exception\PPConnectionException $ex) {
- echo "Exception: " . $ex->getMessage() . PHP_EOL;
- var_dump($ex->getData());
+} catch (Exception $ex) {
+ ResultPrinter::printError("Cancel Invoice", "Invoice", null, $notify, $ex);
exit(1);
}
diff --git a/sample/doc/invoice/CreateInvoice.html b/sample/doc/invoice/CreateInvoice.html
index b6aee93..d94ad31 100644
--- a/sample/doc/invoice/CreateInvoice.html
+++ b/sample/doc/invoice/CreateInvoice.html
@@ -74,9 +74,8 @@ detailed breakdown of invoicetry {Create Invoice
Create an invoice by calling the invoice->create() method
with a valid ApiContext (See bootstrap.php for more on ApiContext)
$invoice->create($apiContext);
-} catch (PayPal\Exception\PPConnectionException $ex) {
- echo "Exception: " . $ex->getMessage() . PHP_EOL;
- var_dump($ex->getData());
+} catch (Exception $ex) {
+ ResultPrinter::printError("Invoice Creation", "Invoice", null, $request, $ex);
exit(1);
}
diff --git a/sample/doc/invoice/GetInvoice.html b/sample/doc/invoice/GetInvoice.html
index 19e0be0..c2f9f5f 100644
--- a/sample/doc/invoice/GetInvoice.html
+++ b/sample/doc/invoice/GetInvoice.html
@@ -10,9 +10,8 @@ on the Invoice class by passing a valid
Invoice ID
(See bootstrap.php for more on ApiContext)try {
$invoice = Invoice::get($invoiceId, $apiContext);
-} catch (PayPal\Exception\PPConnectionException $ex) {
- echo "Exception:" . $ex->getMessage() . PHP_EOL;
- var_dump($ex->getData());
+} catch (Exception $ex) {
+ ResultPrinter::printError("Get Invoice", "Invoice", $invoice->getId(), $invoiceId, $ex);
exit(1);
}
diff --git a/sample/doc/invoice/ListInvoice.html b/sample/doc/invoice/ListInvoice.html
index 4fe074f..2628fa5 100644
--- a/sample/doc/invoice/ListInvoice.html
+++ b/sample/doc/invoice/ListInvoice.html
@@ -8,9 +8,8 @@ all invoice from history.
static get_all method on the Invoice class.
Refer the method doc for valid values for keys
(See bootstrap.php for more on ApiContext) $invoices = Invoice::get_all($apiContext);
-} catch (PayPal\Exception\PPConnectionException $ex) {
- echo "Exception:" . $ex->getMessage() . PHP_EOL;
- var_dump($ex->getData());
+} catch (Exception $ex) {
+ ResultPrinter::printError("Lookup Invoice History", "Invoice", null, null, $ex);
exit(1);
}
ResultPrinter::printResult("Lookup Invoice History", "Invoice", null, null, $invoices);
For Sample Purposes Only.