Merge pull request #607 from paypal/psr

Fixed PSR code style errors
This commit is contained in:
Jay
2016-07-14 13:54:37 -05:00
committed by GitHub
242 changed files with 144 additions and 406 deletions

View File

@@ -20,7 +20,9 @@ abstract class AuthorizationCache
public static function pull($config = null, $clientId = null)
{
// Return if not enabled
if (!self::isEnabled($config)) { return null; }
if (!self::isEnabled($config)) {
return null;
}
$tokens = null;
$cachePath = self::cachePath($config);
@@ -32,7 +34,7 @@ abstract class AuthorizationCache
if ($clientId && is_array($tokens) && array_key_exists($clientId, $tokens)) {
// If client Id is found, just send in that data only
return $tokens[$clientId];
} else if ($clientId) {
} elseif ($clientId) {
// If client Id is provided, but no key in persisted data found matching it.
return null;
}
@@ -54,7 +56,9 @@ abstract class AuthorizationCache
public static function push($config = null, $clientId, $accessToken, $tokenCreateTime, $tokenExpiresIn)
{
// Return if not enabled
if (!self::isEnabled($config)) { return; }
if (!self::isEnabled($config)) {
return;
}
$cachePath = self::cachePath($config);
if (!is_dir(dirname($cachePath))) {
@@ -74,7 +78,7 @@ abstract class AuthorizationCache
'tokenExpiresIn' => $tokenExpiresIn
);
}
if(!file_put_contents($cachePath, json_encode($tokens))) {
if (!file_put_contents($cachePath, json_encode($tokens))) {
throw new \Exception("Failed to write cache");
};
}
@@ -116,6 +120,4 @@ abstract class AuthorizationCache
$config = ($config && is_array($config)) ? $config : PayPalConfigManager::getInstance()->getConfigHashmap();
return (array_key_exists($key, $config)) ? trim($config[$key]) : null;
}
}

View File

@@ -1,6 +1,7 @@
<?php
namespace PayPal\Common;
use PayPal\Validation\JsonValidator;
use PayPal\Validation\ModelAccessorValidator;
@@ -67,7 +68,9 @@ class PayPalModel
public static function getList($data)
{
// Return Null if Null
if ($data === null) { return null; }
if ($data === null) {
return null;
}
if (is_a($data, get_class(new \stdClass()))) {
//This means, root element is object
@@ -173,9 +176,9 @@ class PayPalModel
foreach ($param as $k => $v) {
if ($v instanceof PayPalModel) {
$ret[$k] = $v->toArray();
} else if (sizeof($v) <= 0 && is_array($v)) {
} elseif (sizeof($v) <= 0 && is_array($v)) {
$ret[$k] = array();
} else if (is_array($v)) {
} elseif (is_array($v)) {
$ret[$k] = $this->_convertToArray($v);
} else {
$ret[$k] = $v;
@@ -204,9 +207,9 @@ class PayPalModel
// If the value is an array, it means, it is an object after conversion
if (is_array($v)) {
// Determine the class of the object
if (($clazz = ReflectionUtil::getPropertyClass(get_class($this), $k)) != null){
if (($clazz = ReflectionUtil::getPropertyClass(get_class($this), $k)) != null) {
// If the value is an associative array, it means, its an object. Just make recursive call to it.
if (empty($v)){
if (empty($v)) {
if (ReflectionUtil::isPropertyClassArray(get_class($this), $k)) {
// It means, it is an array of objects.
$this->assignValue($k, array());

View File

@@ -115,4 +115,4 @@ class PayPalResourceModel extends PayPalModel implements IResource
$apiContext = $apiContext ? $apiContext : new ApiContext(self::$credential);
$apiContext->getCredential()->updateAccessToken($apiContext->getConfig(), $refreshToken);
}
}
}

View File

@@ -21,7 +21,6 @@ class PayPalUserAgent
*/
public static function getValue($sdkName, $sdkVersion)
{
$featureList = array(
'platform-ver=' . PHP_VERSION,
'bit=' . self::_getPHPBit(),

View File

@@ -1,6 +1,7 @@
<?php
namespace PayPal\Common;
use PayPal\Exception\PayPalConfigurationException;
/**
@@ -112,7 +113,7 @@ class ReflectionUtil
}
// todo: smarter regexp
if ( !preg_match_all(
if (!preg_match_all(
'~\@([^\s@\(]+)[\t ]*(?:\(?([^\n@]+)\)?)?~i',
$refl->getDocComment(),
$annots,
@@ -120,7 +121,7 @@ class ReflectionUtil
return null;
}
foreach ($annots[1] as $i => $annot) {
$annotations[strtolower($annot)] = empty($annots[2][$i]) ? TRUE : rtrim($annots[2][$i], " \t\n\r)");
$annotations[strtolower($annot)] = empty($annots[2][$i]) ? true : rtrim($annots[2][$i], " \t\n\r)");
}
return $annotations;

View File

@@ -53,7 +53,7 @@ class FormatConverter
throw new \InvalidArgumentException("value cannot have decimals for $currency currency");
}
$decimals = $currencyDecimals[$currency];
} else if (strpos($value, ".") === false) {
} elseif (strpos($value, ".") === false) {
// Check if value has decimal values. If not no need to assign 2 decimals with .00 at the end
$decimals = 0;
}

View File

@@ -95,7 +95,6 @@ class PayPalConfigManager
*/
public function get($searchKey)
{
if (array_key_exists($searchKey, $this->configs)) {
return $this->configs[$searchKey];
} else {
@@ -108,7 +107,6 @@ class PayPalConfigManager
return $arr;
}
}
/**
@@ -123,7 +121,6 @@ class PayPalConfigManager
*/
public function getIniPrefix($userId = null)
{
if ($userId == null) {
$arr = array();
foreach ($this->configs as $key => $value) {
@@ -157,7 +154,4 @@ class PayPalConfigManager
{
trigger_error('Clone is not allowed.', E_USER_ERROR);
}
}

View File

@@ -113,7 +113,6 @@ class PayPalCredentialManager
$suffix++;
$key = $prefix . $suffix;
}
}
/**
@@ -146,7 +145,7 @@ class PayPalCredentialManager
{
if ($userId == null && array_key_exists($this->defaultAccountName, $this->credentialHashmap)) {
$credObj = $this->credentialHashmap[$this->defaultAccountName];
} else if (array_key_exists($userId, $this->credentialHashmap)) {
} elseif (array_key_exists($userId, $this->credentialHashmap)) {
$credObj = $this->credentialHashmap[$userId];
}
@@ -164,5 +163,4 @@ class PayPalCredentialManager
{
trigger_error('Clone is not allowed.', E_USER_ERROR);
}
}

View File

@@ -21,7 +21,7 @@ class PayPalHttpConfig
public static $defaultCurlOptions = array(
CURLOPT_SSLVERSION => 6,
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 60, // maximum number of seconds to allow cURL functions to execute
CURLOPT_USERAGENT => 'PayPal-PHP-SDK',
CURLOPT_HTTPHEADER => array(),

View File

@@ -55,7 +55,6 @@ class PayPalHttpConnection
*/
private function getHttpHeaders()
{
$ret = array();
foreach ($this->httpConfig->getHeaders() as $k => $v) {
$ret[] = "$k: $v";
@@ -78,8 +77,8 @@ class PayPalHttpConnection
//Initialize Curl Options
$ch = curl_init($this->httpConfig->getUrl());
$options = $this->httpConfig->getCurlOptions();
if(empty($options[CURLOPT_HTTPHEADER])) {
unset ($options[CURLOPT_HTTPHEADER]);
if (empty($options[CURLOPT_HTTPHEADER])) {
unset($options[CURLOPT_HTTPHEADER]);
}
curl_setopt_array($ch, $options);
curl_setopt($ch, CURLOPT_URL, $this->httpConfig->getUrl());
@@ -101,7 +100,7 @@ class PayPalHttpConnection
}
//Default Option if Method not of given types in switch case
if ($this->httpConfig->getMethod() != NULL) {
if ($this->httpConfig->getMethod() != null) {
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $this->httpConfig->getMethod());
}
@@ -174,14 +173,14 @@ class PayPalHttpConnection
"Retried $retries times." . $result);
$this->logger->debug("\n\n" . str_repeat('=', 128) . "\n");
throw $ex;
} else if ($httpStatus < 200 || $httpStatus >= 300) {
} elseif ($httpStatus < 200 || $httpStatus >= 300) {
$ex = new PayPalConnectionException(
$this->httpConfig->getUrl(),
"Got Http response code $httpStatus when accessing {$this->httpConfig->getUrl()}.",
$httpStatus
);
$ex->setData($result);
$this->logger->error("Got Http response code $httpStatus when accessing {$this->httpConfig->getUrl()}. " . $result );
$this->logger->error("Got Http response code $httpStatus when accessing {$this->httpConfig->getUrl()}. " . $result);
$this->logger->debug("\n\n" . str_repeat('=', 128) . "\n");
throw $ex;
}
@@ -191,5 +190,4 @@ class PayPalHttpConnection
//Return result object
return $result;
}
}

View File

@@ -116,5 +116,4 @@ class PayPalLoggingManager
$this->logger->debug($message);
}
}
}

View File

@@ -32,5 +32,4 @@ class PayPalInvalidCredentialException extends \Exception
. ': <b>' . $this->getMessage() . '</b>';
return $errorMsg;
}
}

View File

@@ -33,5 +33,4 @@ class PayPalMissingCredentialException extends \Exception
return $errorMsg;
}
}

View File

@@ -78,9 +78,9 @@ class OauthHandler implements IPayPalHandler
{
if (isset($config['oauth.EndPoint'])) {
$baseEndpoint = $config['oauth.EndPoint'];
} else if (isset($config['service.EndPoint'])) {
} elseif (isset($config['service.EndPoint'])) {
$baseEndpoint = $config['service.EndPoint'];
} else if (isset($config['mode'])) {
} elseif (isset($config['mode'])) {
switch (strtoupper($config['mode'])) {
case 'SANDBOX':
$baseEndpoint = PayPalConstants::REST_SANDBOX_ENDPOINT;

View File

@@ -47,7 +47,6 @@ class RestHandler implements IPayPalHandler
*/
public function handle($httpConfig, $request, $options)
{
$credential = $this->apiContext->getCredential();
$config = $this->apiContext->getConfig();
@@ -105,7 +104,7 @@ class RestHandler implements IPayPalHandler
{
if (isset($config['service.EndPoint'])) {
return $config['service.EndPoint'];
} else if (isset($config['mode'])) {
} elseif (isset($config['mode'])) {
switch (strtoupper($config['mode'])) {
case 'SANDBOX':
return PayPalConstants::REST_SANDBOX_ENDPOINT;

View File

@@ -23,4 +23,4 @@ class PayPalDefaultLogFactory implements PayPalLogFactory
{
return new PayPalLogger($className);
}
}
}

View File

@@ -13,5 +13,4 @@ interface PayPalLogFactory
* @return LoggerInterface instance of logger object implementing LoggerInterface
*/
public function getLogger($className);
}
}

View File

@@ -6,7 +6,6 @@ use PayPal\Core\PayPalConfigManager;
use Psr\Log\AbstractLogger;
use Psr\Log\LogLevel;
class PayPalLogger extends AbstractLogger
{
@@ -75,11 +74,11 @@ class PayPalLogger extends AbstractLogger
public function log($level, $message, array $context = array())
{
if($this->isLoggingEnabled) {
if ($this->isLoggingEnabled) {
// Checks if the message is at level below configured logging level
if (array_search($level, $this->loggingLevels) <= array_search($this->loggingLevel, $this->loggingLevels)) {
error_log("[" . date('d-m-Y h:i:s') . "] " . $this->loggerName . " : " . strtoupper($level) . ": $message\n", 3, $this->loggerFile);
}
}
}
}
}

View File

@@ -18,7 +18,7 @@ class Cipher
*/
const IV_SIZE = 16;
function __construct($secretKey)
public function __construct($secretKey)
{
$this->secretKey = $secretKey;
}
@@ -29,7 +29,7 @@ class Cipher
* @param $input
* @return string
*/
function encrypt($input)
public function encrypt($input)
{
// Create a random IV. Not using mcrypt to generate one, as to not have a dependency on it.
$iv = substr(uniqid("", true), 0, Cipher::IV_SIZE);
@@ -45,7 +45,7 @@ class Cipher
* @param $input
* @return string
*/
function decrypt($input)
public function decrypt($input)
{
// Decode the IV + data
$input = base64_decode($input);

View File

@@ -52,7 +52,6 @@ class PayPalRestCall
*/
public function execute($handlers = array(), $path, $method, $data = '', $headers = array())
{
$config = $this->apiContext->getConfig();
$httpConfig = new PayPalHttpConfig(null, $method, $config);
$headers = $headers ? $headers : array();
@@ -75,5 +74,4 @@ class PayPalRestCall
return $response;
}
}

View File

@@ -23,7 +23,7 @@ class ArgumentValidator
if ($argument === null) {
// Error if Object Null
throw new \InvalidArgumentException("$argumentName cannot be null");
} else if (gettype($argument) == 'string' && trim($argument) == ''){
} elseif (gettype($argument) == 'string' && trim($argument) == '') {
// Error if String Empty
throw new \InvalidArgumentException("$argumentName string cannot be empty");
}

View File

@@ -32,4 +32,4 @@ class JsonValidator
}
return true;
}
}
}

View File

@@ -21,7 +21,6 @@ class NumericValidator
{
if (trim($argument) != null && !is_numeric($argument)) {
throw new \InvalidArgumentException("$argumentName is not a valid numeric value");
}
return true;
}

View File

@@ -23,4 +23,4 @@ class UrlValidator
throw new \InvalidArgumentException("$urlName is not a fully qualified URL");
}
}
}
}

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

@@ -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);
}

View File

@@ -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);
}

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 {
@@ -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);

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

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

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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 '

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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" />';

View File

@@ -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

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -13,7 +13,7 @@ $baseUrl = getBaseUrl() . '/UserConsentRedirect.php?success=true';
$redirectUrl = OpenIdSession::getAuthorizationUrl(
$baseUrl,
array('openid', 'profile', 'address', 'email', 'phone',
'https://uri.paypal.com/services/paypalattributes',
'https://uri.paypal.com/services/paypalattributes',
'https://uri.paypal.com/services/expresscheckout',
'https://uri.paypal.com/services/invoicing'),
null,

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 {
@@ -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);
}

View File

@@ -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 {

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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;

View File

@@ -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;

View File

@@ -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);
}

View File

@@ -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);
}

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

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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 = '';

View File

@@ -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);
}

View File

@@ -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);
}

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
@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

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,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);
}

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);

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();
@@ -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);

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

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
@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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);
}

Some files were not shown because too many files have changed in this diff Show More