forked from LiveCarta/PayPal-PHP-SDK
[PSR] Fixed Tests
- Using `php-cs-fixer` tool.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -66,7 +66,7 @@ try {
|
||||
$output = $plan->create($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Created Plan", "Plan", null, $request, $ex);
|
||||
ResultPrinter::printError("Created Plan", "Plan", null, $request, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ try {
|
||||
$result = $createdPlan->delete($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Deleted a Plan", "Plan", $createdPlan->getId(), null, $ex);
|
||||
ResultPrinter::printError("Deleted a Plan", "Plan", $createdPlan->getId(), null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
@@ -17,7 +16,7 @@ if (isset($_GET['success']) && $_GET['success'] == 'true') {
|
||||
$agreement->execute($token, $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Executed an Agreement", "Agreement", $agreement->getId(), $_GET['token'], $ex);
|
||||
ResultPrinter::printError("Executed an Agreement", "Agreement", $agreement->getId(), $_GET['token'], $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -30,13 +29,12 @@ if (isset($_GET['success']) && $_GET['success'] == 'true') {
|
||||
$agreement = \PayPal\Api\Agreement::get($agreement->getId(), $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Get Agreement", "Agreement", null, null, $ex);
|
||||
ResultPrinter::printError("Get Agreement", "Agreement", null, null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
@@ -16,7 +16,7 @@ try {
|
||||
$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("Retrieved an Agreement", "Agreement", $agreement->getId(), $createdAgreement->getId(), $ex);
|
||||
ResultPrinter::printError("Retrieved an Agreement", "Agreement", $agreement->getId(), $createdAgreement->getId(), $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ try {
|
||||
$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("Retrieved a Plan", "Plan", $plan->getId(), null, $ex);
|
||||
ResultPrinter::printError("Retrieved a Plan", "Plan", $plan->getId(), null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ try {
|
||||
$planList = Plan::all($params, $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("List of Plans", "Plan", null, $params, $ex);
|
||||
ResultPrinter::printError("List of Plans", "Plan", null, $params, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -22,7 +22,7 @@ try {
|
||||
$result = Agreement::searchTransactions($agreementId, $params, $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Search for Transactions", "AgreementTransaction", $agreementId, null, $ex);
|
||||
ResultPrinter::printError("Search for Transactions", "AgreementTransaction", $agreementId, null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,15 +18,13 @@ $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);
|
||||
ResultPrinter::printError("Suspended the Agreement", "Agreement", null, $agreementStateDescriptor, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,10 +35,9 @@ 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);
|
||||
ResultPrinter::printError("Updated the Agreement with new Description and Updated Shipping Address", "Agreement", null, $patchRequest, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,10 +34,9 @@ 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);
|
||||
ResultPrinter::printError("Updated the Plan to Active State", "Plan", null, $patchRequest, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,10 +40,9 @@ 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);
|
||||
ResultPrinter::printError("Updated the Plan Payment Definition", "Plan", null, $patchRequest, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
Common functions used across samples
|
||||
Common functions used across samples
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -41,7 +41,6 @@ class ResultPrinter
|
||||
self::printConsoleObject($response, $errorMessage);
|
||||
printf("\n-------------------------------------------------------------\n\n");
|
||||
} else {
|
||||
|
||||
if (self::$printResultCounter == 0) {
|
||||
include "header.html";
|
||||
echo '
|
||||
|
||||
@@ -33,7 +33,7 @@ try {
|
||||
$cancelStatus = $invoice->cancel($notify, $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Cancel Invoice", "Invoice", null, $notify, $ex);
|
||||
ResultPrinter::printError("Cancel Invoice", "Invoice", null, $notify, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ try {
|
||||
$invoice->create($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Create Invoice", "Invoice", null, $request, $ex);
|
||||
ResultPrinter::printError("Create Invoice", "Invoice", null, $request, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ try {
|
||||
$invoice->create($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Create Invoice", "Invoice", null, $request, $ex);
|
||||
ResultPrinter::printError("Create Invoice", "Invoice", null, $request, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ try {
|
||||
$deleteStatus = $invoice->delete($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Delete Invoice", "Invoice", null, $deleteStatus, $ex);
|
||||
ResultPrinter::printError("Delete Invoice", "Invoice", null, $deleteStatus, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ try {
|
||||
$invoice = Invoice::get($invoiceId, $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Get Invoice", "Invoice", $invoice->getId(), $invoiceId, $ex);
|
||||
ResultPrinter::printError("Get Invoice", "Invoice", $invoice->getId(), $invoiceId, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ try {
|
||||
$number = Invoice::generateNumber($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Get Next Invoice Number", "InvoiceNumber", null, null, $ex);
|
||||
ResultPrinter::printError("Get Next Invoice Number", "InvoiceNumber", null, null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ try {
|
||||
$invoices = Invoice::getAll(array('page' => 0, 'page_size' => 4, 'total_count_required' => "true"), $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Lookup Invoice History", "Invoice", null, null, $ex);
|
||||
ResultPrinter::printError("Lookup Invoice History", "Invoice", null, null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
|
||||
@@ -31,7 +31,7 @@ try {
|
||||
$recordStatus = $invoice->recordPayment($record, $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Payment for Invoice", "Invoice", null, null, $ex);
|
||||
ResultPrinter::printError("Payment for Invoice", "Invoice", null, null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ try {
|
||||
$invoice = Invoice::get($invoice->getId(), $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $ex);
|
||||
ResultPrinter::printError("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ try {
|
||||
$refundStatus = $invoice->recordRefund($refund, $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Refund for Invoice", "Invoice", null, null, $ex);
|
||||
ResultPrinter::printError("Refund for Invoice", "Invoice", null, null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ try {
|
||||
$invoice = Invoice::get($invoice->getId(), $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $ex);
|
||||
ResultPrinter::printError("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ try {
|
||||
$remindStatus = $invoice->remind($notify, $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Remind Invoice", "Invoice", null, $notify, $ex);
|
||||
ResultPrinter::printError("Remind Invoice", "Invoice", null, $notify, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ try {
|
||||
$invoice = Invoice::get($invoice->getId(), $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $ex);
|
||||
ResultPrinter::printError("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,11 +23,9 @@ 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);
|
||||
ResultPrinter::printError("Retrieved QR Code for Invoice", "Invoice", $invoice->getId(), null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -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" />';
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ try {
|
||||
$invoices = Invoice::search($search, $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Search Invoice", "Invoice", null, null, $ex);
|
||||
ResultPrinter::printError("Search Invoice", "Invoice", null, null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
|
||||
@@ -34,7 +34,7 @@ try {
|
||||
$invoice = Invoice::get($invoice->getId(), $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $ex);
|
||||
ResultPrinter::printError("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ try {
|
||||
$invoice->update($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Invoice Updated", "Invoice", null, $request, $ex);
|
||||
ResultPrinter::printError("Invoice Updated", "Invoice", null, $request, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ try {
|
||||
$invoice = Invoice::get($invoice->getId(), $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $ex);
|
||||
ResultPrinter::printError("Get Invoice (Not Required - For Sample Only)", "Invoice", $invoice->getId(), $invoice->getId(), $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,13 +9,11 @@ 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);
|
||||
ResultPrinter::printError("Obtained Access Token From Refresh Token", "Access Token", null, null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -21,16 +21,14 @@ 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);
|
||||
ResultPrinter::printError("User Information", "User Info", null, $params, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
@@ -19,11 +18,10 @@ if (isset($_GET['success']) && $_GET['success'] == 'true') {
|
||||
$accessToken = OpenIdTokeninfo::createFromAuthorizationCode(array('code' => $code), null, null, $apiContext);
|
||||
} catch (PayPalConnectionException $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Obtained Access Token", "Access Token", null, $_GET['code'], $ex);
|
||||
ResultPrinter::printError("Obtained Access Token", "Access Token", null, $_GET['code'], $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ try {
|
||||
$data = $ex->getData();
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Created Webhook Failed. Checking if it is Webhook Number Limit Exceeded. Trying to delete all existing webhooks", "Webhook", "Please Use <a style='color: red;' href='DeleteAllWebhooks.php' >Delete All Webhooks</a> Sample to delete all existing webhooks in sample", $request, $ex);
|
||||
if (strpos($data,'WEBHOOK_NUMBER_LIMIT_EXCEEDED') !== false) {
|
||||
if (strpos($data, 'WEBHOOK_NUMBER_LIMIT_EXCEEDED') !== false) {
|
||||
require 'DeleteAllWebhooks.php';
|
||||
try {
|
||||
$output = $webhook->create($apiContext);
|
||||
@@ -69,7 +69,7 @@ try {
|
||||
}
|
||||
} else {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Created Webhook", "Webhook", null, $request, $ex);
|
||||
ResultPrinter::printError("Created Webhook", "Webhook", null, $request, $ex);
|
||||
exit(1);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -16,7 +16,7 @@ try {
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Deleted all Webhooks", "WebhookList", null, null, $ex);
|
||||
ResultPrinter::printError("Deleted all Webhooks", "WebhookList", null, null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ try {
|
||||
$output = $webhook->delete($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Delete a Webhook", "Webhook", null, $webhookId, $ex);
|
||||
ResultPrinter::printError("Delete a Webhook", "Webhook", null, $webhookId, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ try {
|
||||
$output = \PayPal\Api\Webhook::get($webhookId, $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Get a Webhook", "Webhook", null, $webhookId, $ex);
|
||||
ResultPrinter::printError("Get a Webhook", "Webhook", null, $webhookId, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,11 +18,11 @@ try {
|
||||
$output = \PayPal\Api\WebhookEventType::subscribedEventTypes($webhookId, $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("List subscribed webhook event types", "WebhookEventTypeList", null, $webhookId, $ex);
|
||||
ResultPrinter::printError("List subscribed webhook event types", "WebhookEventTypeList", null, $webhookId, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printResult("List subscribed webhook event types", "WebhookEventTypeList",null, null, $output);
|
||||
ResultPrinter::printResult("List subscribed webhook event types", "WebhookEventTypeList", null, null, $output);
|
||||
|
||||
return $output;
|
||||
|
||||
@@ -19,11 +19,11 @@ try {
|
||||
$output = \PayPal\Api\Webhook::getAll($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("List all webhooks", "WebhookList", null, $webhookId, $ex);
|
||||
ResultPrinter::printError("List all webhooks", "WebhookList", null, $webhookId, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printResult("List all webhooks", "WebhookList",null, null, $output);
|
||||
ResultPrinter::printResult("List all webhooks", "WebhookList", null, null, $output);
|
||||
|
||||
return $output;
|
||||
|
||||
@@ -23,7 +23,7 @@ try {
|
||||
$output = \PayPal\Api\WebhookEvent::all($params, $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Search Webhook events", "WebhookEventList", null, null, $ex);
|
||||
ResultPrinter::printError("Search Webhook events", "WebhookEventList", null, null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ try {
|
||||
$output = $webhook->update($patchRequest, $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Updated a Webhook", "Webhook", null, $patchRequest, $ex);
|
||||
ResultPrinter::printError("Updated a Webhook", "Webhook", null, $patchRequest, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ try {
|
||||
$output = \PayPal\Api\WebhookEventType::availableEventTypes($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Get List of All Webhook Event Types", "WebhookEventTypeList", null, null, $ex);
|
||||
ResultPrinter::printError("Get List of All Webhook Event Types", "WebhookEventTypeList", null, null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ try {
|
||||
$createProfileResponse = $webProfile->create($apiContext);
|
||||
} catch (\PayPal\Exception\PayPalConnectionException $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Created Web Profile", "Web Profile", null, $request, $ex);
|
||||
ResultPrinter::printError("Created Web Profile", "Web Profile", null, $request, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ try {
|
||||
$webProfile->delete($apiContext);
|
||||
} catch (\PayPal\Exception\PayPalConnectionException $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Deleted Web Profile", "Web Profile", $createProfileResponse->getId(), null, $ex);
|
||||
ResultPrinter::printError("Deleted Web Profile", "Web Profile", $createProfileResponse->getId(), null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ try {
|
||||
$webProfile = \PayPal\Api\WebProfile::get($createProfileResponse->getId(), $apiContext);
|
||||
} catch (\PayPal\Exception\PayPalConnectionException $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Get Web Profile", "Web Profile", $webProfile->getId(), null, $ex);
|
||||
ResultPrinter::printError("Get Web Profile", "Web Profile", $webProfile->getId(), null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ try {
|
||||
$list = \PayPal\Api\WebProfile::get_list($apiContext);
|
||||
} catch (\PayPal\Exception\PayPalConnectionException $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Get List of All Web Profiles", "Web Profiles", null, null, $ex);
|
||||
ResultPrinter::printError("Get List of All Web Profiles", "Web Profiles", null, null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
$result = '';
|
||||
|
||||
@@ -38,7 +38,7 @@ try {
|
||||
}
|
||||
} catch (\Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Partially Updated Web Profile", "Web Profile", $webProfile->getId(), $patches, $ex);
|
||||
ResultPrinter::printError("Partially Updated Web Profile", "Web Profile", $webProfile->getId(), $patches, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ try {
|
||||
}
|
||||
} catch (\Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Updated Web Profile", "Web Profile", $webProfile->getId(), $webProfile, $ex);
|
||||
ResultPrinter::printError("Updated Web Profile", "Web Profile", $webProfile->getId(), $webProfile, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -31,7 +30,7 @@ try {
|
||||
$getCapture = $authorization->capture($capture, $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Capture Payment", "Authorization", null, $capture, $ex);
|
||||
ResultPrinter::printError("Capture Payment", "Authorization", null, $capture, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ try {
|
||||
$payment->create($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError('Authorize a Payment', 'Authorized Payment', $payment->getId(), $request, $ex);
|
||||
ResultPrinter::printError('Authorize a Payment', 'Authorized Payment', $payment->getId(), $request, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ try {
|
||||
$payment->create($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Created Payment Authorization Using PayPal. Please visit the URL to Authorize.", "Payment", null, $request, $ex);
|
||||
ResultPrinter::printError("Created Payment Authorization Using PayPal. Please visit the URL to Authorize.", "Payment", null, $request, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -84,10 +84,9 @@ 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);
|
||||
ResultPrinter::printError("Future Payment", "Payment", null, $payment, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -114,7 +114,7 @@ try {
|
||||
$payment->create($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError('Create Payment Using Credit Card. If 500 Exception, try creating a new Credit Card using <a href="https://ppmts.custhelp.com/app/answers/detail/a_id/750">Step 4, on this link</a>, and using it.', 'Payment', null, $request, $ex);
|
||||
ResultPrinter::printError('Create Payment Using Credit Card. If 500 Exception, try creating a new Credit Card using <a href="https://ppmts.custhelp.com/app/answers/detail/a_id/750">Step 4, on this link</a>, and using it.', 'Payment', null, $request, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ try {
|
||||
$payment->create($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Created Payment Using PayPal. Please visit the URL to Approve.", "Payment", null, $request, $ex);
|
||||
ResultPrinter::printError("Created Payment Using PayPal. Please visit the URL to Approve.", "Payment", null, $request, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ try {
|
||||
$payment->create($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Create Payment using Saved Card", "Payment", null, $request, $ex);
|
||||
ResultPrinter::printError("Create Payment using Saved Card", "Payment", null, $request, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -69,12 +69,12 @@ if (isset($_GET['success']) && $_GET['success'] == 'true') {
|
||||
$payment = Payment::get($paymentId, $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Get Payment", "Payment", null, null, $ex);
|
||||
ResultPrinter::printError("Get Payment", "Payment", null, null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Executed Payment", "Payment", null, null, $ex);
|
||||
ResultPrinter::printError("Executed Payment", "Payment", null, null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -20,7 +20,7 @@ try {
|
||||
$result = Authorization::get($authorizationId, $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Get Authorization", "Authorization", null, null, $ex);
|
||||
ResultPrinter::printError("Get Authorization", "Authorization", null, null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ try {
|
||||
$capture = Capture::get($request->getId(), $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Get Captured Payment", "Capture", $request->getId(), null, $ex);
|
||||
ResultPrinter::printError("Get Captured Payment", "Capture", $request->getId(), null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ try {
|
||||
$payment = Payment::get($paymentId, $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Get Payment", "Payment", null, null, $ex);
|
||||
ResultPrinter::printError("Get Payment", "Payment", null, null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -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,13 +20,12 @@ 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);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("List Payments", "Payment", null, $params, $ex);
|
||||
ResultPrinter::printError("List Payments", "Payment", null, $params, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,12 +40,11 @@ if (isset($_GET['success']) && $_GET['success'] == 'true') {
|
||||
ResultPrinter::printResult("Authorized Order", "Authorization", $result->getId(), $authorization, $result);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Authorized Order", "Authorization", null, $authorization, $ex);
|
||||
ResultPrinter::printError("Authorized Order", "Authorization", null, $authorization, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
} else {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printResult("User Cancelled the Approval", null);
|
||||
|
||||
@@ -41,12 +41,11 @@ if (isset($_GET['success']) && $_GET['success'] == 'true') {
|
||||
ResultPrinter::printResult("Captured Order", "Capture", $result->getId(), $capture, $result);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Captured Order", "Capture", null, $capture, $ex);
|
||||
ResultPrinter::printError("Captured Order", "Capture", null, $capture, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
} else {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printResult("User Cancelled the Approval", null);
|
||||
|
||||
@@ -98,7 +98,7 @@ try {
|
||||
$payment->create($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Created Payment Order Using PayPal. Please visit the URL to Approve.", "Payment", null, $request, $ex);
|
||||
ResultPrinter::printError("Created Payment Order Using PayPal. Please visit the URL to Approve.", "Payment", null, $request, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ try {
|
||||
$payment->create($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Created Payment Order Using PayPal. Please visit the URL to Approve.", "Payment", null, $request, $ex);
|
||||
ResultPrinter::printError("Created Payment Order Using PayPal. Please visit the URL to Approve.", "Payment", null, $request, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ try {
|
||||
$payment->create($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Created Payment Order Using PayPal. Please visit the URL to Approve.", "Payment", null, $request, $ex);
|
||||
ResultPrinter::printError("Created Payment Order Using PayPal. Please visit the URL to Approve.", "Payment", null, $request, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ try {
|
||||
$payment->create($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Created Payment Order Using PayPal. Please visit the URL to Approve.", "Payment", null, $request, $ex);
|
||||
ResultPrinter::printError("Created Payment Order Using PayPal. Please visit the URL to Approve.", "Payment", null, $request, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,12 +27,11 @@ if (isset($_GET['success']) && $_GET['success'] == 'true') {
|
||||
ResultPrinter::printResult("Voided Order", "Order", $result->getId(), null, $result);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Voided Order", "Order", null, null, $ex);
|
||||
ResultPrinter::printError("Voided Order", "Order", null, null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
} else {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printResult("User Cancelled the Approval", null);
|
||||
|
||||
@@ -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();
|
||||
@@ -22,12 +21,11 @@ if (isset($_GET['success']) && $_GET['success'] == 'true') {
|
||||
ResultPrinter::printResult("Get Order", "Order", $result->getId(), null, $result);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Get Order", "Order", null, null, $ex);
|
||||
ResultPrinter::printError("Get Order", "Order", null, null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return $result;
|
||||
|
||||
} else {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printResult("User Cancelled the Approval", null);
|
||||
|
||||
@@ -17,7 +17,6 @@ use PayPal\Api\Authorization;
|
||||
// has expired.
|
||||
|
||||
try {
|
||||
|
||||
$amount = new Amount();
|
||||
$amount->setCurrency("USD");
|
||||
$amount->setTotal(1);
|
||||
@@ -28,7 +27,7 @@ try {
|
||||
$reAuthorization = $authorization->reauthorize($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Reauthorize Payment", "Payment", null, null, $ex);
|
||||
ResultPrinter::printError("Reauthorize Payment", "Payment", null, null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ try {
|
||||
$captureRefund = $capture->refund($refund, $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Refund Capture", "Capture", null, $refund, $ex);
|
||||
ResultPrinter::printError("Refund Capture", "Capture", null, $refund, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -81,10 +81,9 @@ $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);
|
||||
ResultPrinter::printError("Update Payment", "PatchRequest", null, $patchRequest, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -24,7 +23,7 @@ try {
|
||||
$voidedAuth = $authorization->void($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Void Authorization", "Authorization", null, null, $ex);
|
||||
ResultPrinter::printError("Void Authorization", "Authorization", null, null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,11 +26,11 @@ try {
|
||||
} else {
|
||||
// The item transaction status is not unclaimed. You can only cancel an unclaimed transaction.
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Cancel Unclaimed Payout Item", "PayoutItem", null, $payoutItemId, new Exception("Payout Item Status is not UNCLAIMED"));
|
||||
ResultPrinter::printError("Cancel Unclaimed Payout Item", "PayoutItem", null, $payoutItemId, new Exception("Payout Item Status is not UNCLAIMED"));
|
||||
}
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Cancel Unclaimed Payout Item", "PayoutItem", null, $payoutItemId, $ex);
|
||||
ResultPrinter::printError("Cancel Unclaimed Payout Item", "PayoutItem", null, $payoutItemId, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -116,7 +116,7 @@ try {
|
||||
$output = $payouts->create(null, $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Created Batch Payout", "Payout", null, $request, $ex);
|
||||
ResultPrinter::printError("Created Batch Payout", "Payout", null, $request, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ try {
|
||||
$output = $payouts->createSynchronous($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Created Single Synchronous Payout", "Payout", null, $request, $ex);
|
||||
ResultPrinter::printError("Created Single Synchronous Payout", "Payout", null, $request, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ try {
|
||||
$output = \PayPal\Api\Payout::get($payoutBatchId, $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Get Payout Batch Status", "PayoutBatch", null, $payoutBatchId, $ex);
|
||||
ResultPrinter::printError("Get Payout Batch Status", "PayoutBatch", null, $payoutBatchId, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ try {
|
||||
$output = \PayPal\Api\PayoutItem::get($payoutItemId, $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Get Payout Item Status", "PayoutItem", null, $payoutItemId, $ex);
|
||||
ResultPrinter::printError("Get Payout Item Status", "PayoutItem", null, $payoutItemId, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ try {
|
||||
$sale = Sale::get($saleId, $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Look Up A Sale", "Sale", $sale->getId(), null, $ex);
|
||||
ResultPrinter::printError("Look Up A Sale", "Sale", $sale->getId(), null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ try {
|
||||
$refundedSale = $sale->refund($refund, $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Refund Sale", "Sale", $refundedSale->getId(), $refund, $ex);
|
||||
ResultPrinter::printError("Refund Sale", "Sale", $refundedSale->getId(), $refund, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ try {
|
||||
$bankAccount->create($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Create Bank Account", "Bank Account", null, $request, $ex);
|
||||
ResultPrinter::printError("Create Bank Account", "Bank Account", null, $request, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ try {
|
||||
$card->create($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Create Credit Card", "Credit Card", null, $request, $ex);
|
||||
ResultPrinter::printError("Create Credit Card", "Credit Card", null, $request, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ try {
|
||||
$bankAccount->delete($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Delete Bank Account", "Bank Account", null, null, $ex);
|
||||
ResultPrinter::printError("Delete Bank Account", "Bank Account", null, null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ try {
|
||||
$card->delete($apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Delete Credit Card", "Credit Card", null, null, $ex);
|
||||
ResultPrinter::printError("Delete Credit Card", "Credit Card", null, null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ try {
|
||||
$bankAccount = \PayPal\Api\BankAccount::get($bankAccount->getId(), $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Get Bank Account", "Bank Account", $bankAccount->getId(), null, $ex);
|
||||
ResultPrinter::printError("Get Bank Account", "Bank Account", $bankAccount->getId(), null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ try {
|
||||
$card = CreditCard::get($card->getId(), $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Get Credit Card", "Credit Card", $card->getId(), null, $ex);
|
||||
ResultPrinter::printError("Get Credit Card", "Credit Card", $card->getId(), null, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ try {
|
||||
$cards = CreditCard::all($params, $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("List All Credit Cards", "CreditCardList", null, $params, $ex);
|
||||
ResultPrinter::printError("List All Credit Cards", "CreditCardList", null, $params, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ try {
|
||||
$card = $card->update($pathRequest, $apiContext);
|
||||
} catch (Exception $ex) {
|
||||
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
|
||||
ResultPrinter::printError("Updated Credit Card", "Credit Card", $card->getId(), $pathRequest, $ex);
|
||||
ResultPrinter::printError("Updated Credit Card", "Credit Card", $card->getId(), $pathRequest, $ex);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user