[PSR] Fixed Tests

- Using `php-cs-fixer` tool.
This commit is contained in:
Jay Patel
2016-07-14 13:08:18 -05:00
parent 1401d5563d
commit cffa2463b1
88 changed files with 94 additions and 131 deletions

View File

@@ -99,7 +99,6 @@ $request = clone $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 (Exception $ex) {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printError("Created Billing Agreement.", "Agreement", $agreement->getId(), $request, $ex);

View File

@@ -74,7 +74,6 @@ try {
// the buyer to. Retrieve the url from the $agreement->getApprovalLink()
// method
$approvalUrl = $agreement->getApprovalLink();
} catch (Exception $ex) {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printError("Created Billing Agreement.", "Agreement", null, $request, $ex);

View File

@@ -8,7 +8,6 @@ require __DIR__ . '/../bootstrap.php';
// ## Approval Status
// Determine if the user accepted or denied the request
if (isset($_GET['success']) && $_GET['success'] == 'true') {
$token = $_GET['token'];
$agreement = new \PayPal\Api\Agreement();
try {
@@ -36,7 +35,6 @@ if (isset($_GET['success']) && $_GET['success'] == 'true') {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("Get Agreement", "Agreement", $agreement->getId(), null, $agreement);
} else {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("User Cancelled the Approval", null);

View File

@@ -18,12 +18,10 @@ $agreementStateDescriptor = new AgreementStateDescriptor();
$agreementStateDescriptor->setNote("Reactivating the agreement");
try {
$suspendedAgreement->reActivate($agreementStateDescriptor, $apiContext);
// Lets get the updated Agreement Object
$agreement = Agreement::get($suspendedAgreement->getId(), $apiContext);
} catch (Exception $ex) {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("Reactivate the Agreement", "Agreement", $agreement->getId(), $suspendedAgreement, $ex);

View File

@@ -18,12 +18,10 @@ $agreementStateDescriptor = new AgreementStateDescriptor();
$agreementStateDescriptor->setNote("Suspending the agreement");
try {
$createdAgreement->suspend($agreementStateDescriptor, $apiContext);
// Lets get the updated Agreement Object
$agreement = Agreement::get($createdAgreement->getId(), $apiContext);
} catch (Exception $ex) {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printError("Suspended the Agreement", "Agreement", null, $agreementStateDescriptor, $ex);

View File

@@ -35,7 +35,6 @@ try {
// Lets get the updated Agreement Object
$agreement = Agreement::get($createdAgreement->getId(), $apiContext);
} catch (Exception $ex) {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printError("Updated the Agreement with new Description and Updated Shipping Address", "Agreement", null, $patchRequest, $ex);

View File

@@ -34,7 +34,6 @@ try {
$createdPlan->update($patchRequest, $apiContext);
$plan = Plan::get($createdPlan->getId(), $apiContext);
} catch (Exception $ex) {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printError("Updated the Plan to Active State", "Plan", null, $patchRequest, $ex);

View File

@@ -40,7 +40,6 @@ try {
$createdPlan->update($patchRequest, $apiContext);
$plan = Plan::get($createdPlan->getId(), $apiContext);
} catch (Exception $ex) {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printError("Updated the Plan Payment Definition", "Plan", null, $patchRequest, $ex);

View File

@@ -41,7 +41,6 @@ class ResultPrinter
self::printConsoleObject($response, $errorMessage);
printf("\n-------------------------------------------------------------\n\n");
} else {
if (self::$printResultCounter == 0) {
include "header.html";
echo '

View File

@@ -23,8 +23,6 @@ try {
// 'saveToFile' method with proper file name.
// This will save the image as /samples/invoice/images/sample.png
$path = $image->saveToFile("images/sample.png");
} catch (Exception $ex) {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printError("Retrieved QR Code for Invoice", "Invoice", $invoice->getId(), null, $ex);
@@ -39,4 +37,3 @@ try {
// One of the ways, you could directly inject the base64-encoded string
// with proper image information in front of it.
echo '<img src="data:image/png;base64,'. $image->getImage() . '" alt="Invoice QR Code" />';

View File

@@ -9,10 +9,8 @@ use PayPal\Api\OpenIdTokeninfo;
$refreshToken = 'yzX4AkmMyBKR4on7vB5he-tDu38s24Zy-kTibhSuqA8kTdy0Yinxj7NpAyULx0bxqC5G8dbXOt0aVMlMmtpiVmSzhcjVZhYDM7WUQLC9KpaXGBHyltJPkLLQkXE';
try {
$tokenInfo = new OpenIdTokeninfo();
$tokenInfo = $tokenInfo->createFromRefreshToken(array('refresh_token' => $refreshToken), $apiContext);
} catch (Exception $ex) {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printError("Obtained Access Token From Refresh Token", "Access Token", null, null, $ex);

View File

@@ -21,13 +21,11 @@ use PayPal\Api\OpenIdUserinfo;
$refreshToken = 'W1JmxG-Cogm-4aSc5Vlen37XaQTj74aQcQiTtXax5UgY7M_AJ--kLX8xNVk8LtCpmueFfcYlRK6UgQLJ-XHsxpw6kZzPpKKccRQeC4z2ldTMfXdIWajZ6CHuebs';
try {
$tokenInfo = new OpenIdTokeninfo();
$tokenInfo = $tokenInfo->createFromRefreshToken(array('refresh_token' => $refreshToken), $apiContext);
$params = array('access_token' => $tokenInfo->getAccessToken());
$userInfo = OpenIdUserinfo::getUserinfo($params, $apiContext);
} catch (Exception $ex) {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printError("User Information", "User Info", null, $params, $ex);

View File

@@ -11,7 +11,6 @@ session_start();
// PayPal would redirect the user to the redirect_uri mentioned when creating the consent URL.
// The user would then able to retrieve the access token by getting the code, which is returned as a GET parameter.
if (isset($_GET['success']) && $_GET['success'] == 'true') {
$code = $_GET['code'];
try {
@@ -25,5 +24,4 @@ if (isset($_GET['success']) && $_GET['success'] == 'true') {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("Obtained Access Token", "Access Token", $accessToken->getAccessToken(), $_GET['code'], $accessToken);
}

View File

@@ -32,5 +32,3 @@ try {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("Validate Received Webhook Event", "WebhookEvent", $output->getId(), $bodyReceived, $output);

View File

@@ -11,7 +11,6 @@ use PayPal\Api\Amount;
use PayPal\Api\Authorization;
use PayPal\Api\Capture;
// ### Capture Payment
// You can capture and process a previously created authorization
// by invoking the $authorization->capture method

View File

@@ -84,7 +84,6 @@ try {
// for payment approval
// Please note that currently future payments works only with PayPal as a funding instrument.
$payment->create($apiContext, $clientMetadataId);
} catch (Exception $ex) {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printError("Future Payment", "Payment", null, $payment, $ex);

View File

@@ -82,8 +82,6 @@ if (isset($_GET['success']) && $_GET['success'] == 'true') {
ResultPrinter::printResult("Get Payment", "Payment", $payment->getId(), null, $payment);
return $payment;
} else {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("User Cancelled the Approval", null);

View File

@@ -12,7 +12,6 @@
require 'CreatePayment.php';
use PayPal\Api\Payment;
// ### Retrieve payment
// Retrieve the PaymentHistory object by calling the
// static `get` method on the Payment class,
@@ -21,7 +20,6 @@ use PayPal\Api\Payment;
// Refer the method doc for valid values for keys
// (See bootstrap.php for more on `ApiContext`)
try {
$params = array('count' => 10, 'start_index' => 5);
$payments = Payment::all($params, $apiContext);

View File

@@ -45,7 +45,6 @@ if (isset($_GET['success']) && $_GET['success'] == 'true') {
}
return $result;
} else {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("User Cancelled the Approval", null);

View File

@@ -46,7 +46,6 @@ if (isset($_GET['success']) && $_GET['success'] == 'true') {
}
return $result;
} else {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("User Cancelled the Approval", null);

View File

@@ -32,7 +32,6 @@ if (isset($_GET['success']) && $_GET['success'] == 'true') {
}
return $result;
} else {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("User Cancelled the Approval", null);

View File

@@ -9,7 +9,6 @@ $payment = require __DIR__ . '/ExecutePayment.php';
// ### Approval Status
// Determine if the user approved the payment or not
if (isset($_GET['success']) && $_GET['success'] == 'true') {
$transactions = $payment->getTransactions();
$transaction = $transactions[0];
$relatedResources = $transaction->getRelatedResources();
@@ -27,7 +26,6 @@ if (isset($_GET['success']) && $_GET['success'] == 'true') {
}
return $result;
} else {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("User Cancelled the Approval", null);

View File

@@ -17,7 +17,6 @@ use PayPal\Api\Authorization;
// has expired.
try {
$amount = new Amount();
$amount->setCurrency("USD");
$amount->setTotal(1);

View File

@@ -81,7 +81,6 @@ $patchRequest->setPatches(array($patchReplace, $patchAdd));
// (See bootstrap.php for more on `ApiContext`)
try {
$result = $createdPayment->update($patchRequest, $apiContext);
} catch (Exception $ex) {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printError("Update Payment", "PatchRequest", null, $patchRequest, $ex);

View File

@@ -10,7 +10,6 @@ $authorization = require 'AuthorizePayment.php';
$authorizationId = '1BF65516U6866543H'; // $authorization->getId();
use PayPal\Api\Authorization;
// ### VoidAuthorization
// You can void a previously authorized payment
// by invoking the $authorization->void method