Renaming Namespaces and Organizing Classes

- Updated OpenId classes to be in API namespace
- Updated PP Naming Convention to PayPal Naming Convention
- FormatConverter Class got its own namespace
- Handlers are grouped in Handler namespace
- Samples and Tests Updated Accordingly
This commit is contained in:
japatel
2014-12-17 17:15:01 -06:00
parent 4cb951f8b2
commit 9c0827643b
246 changed files with 1067 additions and 1057 deletions

View File

@@ -16,11 +16,11 @@ $createdPlan = require 'CreatePlan.php';
use PayPal\Api\Plan;
use PayPal\Api\PatchRequest;
use PayPal\Api\Patch;
use PayPal\Common\PPModel;
use PayPal\Common\PayPalModel;
try {
$patch = new Patch();
$value = new PPModel('{
$value = new PayPalModel('{
"state":"ACTIVE"
}');

View File

@@ -122,7 +122,7 @@ class ResultPrinter
public static function printError($title, $objectName, $objectId = null, $request = null, $exception = null)
{
$data = null;
if ($exception instanceof \PayPal\Exception\PPConnectionException) {
if ($exception instanceof \PayPal\Exception\PayPalConnectionException) {
$data = $exception->getData();
}
self::printOutput($title, $objectName, $objectId, $request, $data, $exception->getMessage());
@@ -134,8 +134,8 @@ class ResultPrinter
echo 'ERROR:'. $error;
}
if ($object) {
if (is_a($object, 'PayPal\Common\PPModel')) {
/** @var $object \PayPal\Common\PPModel */
if (is_a($object, 'PayPal\Common\PayPalModel')) {
/** @var $object \PayPal\Common\PayPalModel */
echo $object->toJSON(128);
} elseif (is_string($object) && \PayPal\Validation\JsonValidator::validate($object, true)) {
echo str_replace('\\/', '/', json_encode(json_decode($object), 128));
@@ -157,8 +157,8 @@ class ResultPrinter
'</p>';
}
if ($object) {
if (is_a($object, 'PayPal\Common\PPModel')) {
/** @var $object \PayPal\Common\PPModel */
if (is_a($object, 'PayPal\Common\PayPalModel')) {
/** @var $object \PayPal\Common\PayPalModel */
echo '<pre class="prettyprint '. ($error ? 'error' : '') .'">' . $object->toJSON(128) . "</pre>";
} elseif (is_string($object) && \PayPal\Validation\JsonValidator::validate($object, true)) {
echo '<pre class="prettyprint '. ($error ? 'error' : '') .'">'. str_replace('\\/', '/', json_encode(json_decode($object), 128)) . "</pre>";

View File

@@ -8,11 +8,11 @@ API used: /v1/payments/billing-plans/<Plan-Id></p></div></div></div><div class=
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Plan</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">PatchRequest</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Patch</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Common</span>\<span class="hljs-title">PPModel</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Common</span>\<span class="hljs-title">PayPalModel</span>;
<span class="hljs-keyword">try</span> {
<span class="hljs-variable">$patch</span> = <span class="hljs-keyword">new</span> Patch();
<span class="hljs-variable">$value</span> = <span class="hljs-keyword">new</span> PPModel(<span class="hljs-string">'{
<span class="hljs-variable">$value</span> = <span class="hljs-keyword">new</span> PayPalModel(<span class="hljs-string">'{
"state":"ACTIVE"
}'</span>);

View File

@@ -1,9 +1,9 @@
<!DOCTYPE html><html lang="en"><head><title>lipp/GenerateAccessTokenFromRefreshToken</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="lipp/GenerateAccessTokenFromRefreshToken"><meta name="groc-project-path" content="lipp/GenerateAccessTokenFromRefreshToken.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">lipp/GenerateAccessTokenFromRefreshToken.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor">&lt;?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="obtain-access-token-from-refresh-token">Obtain Access Token From Refresh Token</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-keyword">require</span> <span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">'/../bootstrap.php'</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Auth</span>\<span class="hljs-title">Openid</span>\<span class="hljs-title">PPOpenIdTokeninfo</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>You can retrieve the refresh token by executing ObtainUserConsent.php and store the refresh token</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$refreshToken</span> = <span class="hljs-string">'yzX4AkmMyBKR4on7vB5he-tDu38s24Zy-kTibhSuqA8kTdy0Yinxj7NpAyULx0bxqC5G8dbXOt0aVMlMmtpiVmSzhcjVZhYDM7WUQLC9KpaXGBHyltJPkLLQkXE'</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">OpenIdTokeninfo</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>You can retrieve the refresh token by executing ObtainUserConsent.php and store the refresh token</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$refreshToken</span> = <span class="hljs-string">'yzX4AkmMyBKR4on7vB5he-tDu38s24Zy-kTibhSuqA8kTdy0Yinxj7NpAyULx0bxqC5G8dbXOt0aVMlMmtpiVmSzhcjVZhYDM7WUQLC9KpaXGBHyltJPkLLQkXE'</span>;
<span class="hljs-keyword">try</span> {
<span class="hljs-variable">$tokenInfo</span> = <span class="hljs-keyword">new</span> PPOpenIdTokeninfo();
<span class="hljs-variable">$tokenInfo</span> = <span class="hljs-keyword">new</span> OpenIdTokeninfo();
<span class="hljs-variable">$tokenInfo</span> = <span class="hljs-variable">$tokenInfo</span>-&gt;createFromRefreshToken(<span class="hljs-keyword">array</span>(<span class="hljs-string">'refresh_token'</span> =&gt; <span class="hljs-variable">$refreshToken</span>), <span class="hljs-variable">$apiContext</span>);
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {

View File

@@ -1,7 +1,7 @@
<!DOCTYPE html><html lang="en"><head><title>lipp/GetUserInfo</title></head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"><meta name="groc-relative-root" content="../"><meta name="groc-document-path" content="lipp/GetUserInfo"><meta name="groc-project-path" content="lipp/GetUserInfo.php"><link rel="stylesheet" type="text/css" media="all" href="../assets/style.css"><script type="text/javascript" src="../assets/behavior.js"></script><body><div id="meta"><div class="file-path">lipp/GetUserInfo.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor">&lt;?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="obtain-access-token-from-refresh-token">Obtain Access Token From Refresh Token</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-keyword">require</span> <span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">'/../bootstrap.php'</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Auth</span>\<span class="hljs-title">Openid</span>\<span class="hljs-title">PPOpenIdUserinfo</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Auth</span>\<span class="hljs-title">Openid</span>\<span class="hljs-title">PPOpenIdTokeninfo</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>To obtain User Info, you have to follow three steps in general.
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">OpenIdUserinfo</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">OpenIdTokeninfo</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>To obtain User Info, you have to follow three steps in general.
First, you need to obtain user&#39;s consent to retrieve the information you want.
This is explained in the example &quot;ObtainUserConsent.php&quot;.</p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Once you get the user&#39;s consent, the end result would be long lived refresh token.
This refresh token should be stored in a permanent storage for later use.</p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Lastly, when you need to retrieve the user information, you need to generate the short lived access token
@@ -10,11 +10,11 @@ to retreive the information. The short lived access token can be retrieved using
<span class="hljs-keyword">try</span> {
<span class="hljs-variable">$tokenInfo</span> = <span class="hljs-keyword">new</span> PPOpenIdTokeninfo();
<span class="hljs-variable">$tokenInfo</span> = <span class="hljs-keyword">new</span> OpenIdTokeninfo();
<span class="hljs-variable">$tokenInfo</span> = <span class="hljs-variable">$tokenInfo</span>-&gt;createFromRefreshToken(<span class="hljs-keyword">array</span>(<span class="hljs-string">'refresh_token'</span> =&gt; <span class="hljs-variable">$refreshToken</span>), <span class="hljs-variable">$apiContext</span>);
<span class="hljs-variable">$params</span> = <span class="hljs-keyword">array</span>(<span class="hljs-string">'access_token'</span> =&gt; <span class="hljs-variable">$tokenInfo</span>-&gt;getAccessToken());
<span class="hljs-variable">$userInfo</span> = PPOpenIdUserinfo::getUserinfo(<span class="hljs-variable">$params</span>, <span class="hljs-variable">$apiContext</span>);
<span class="hljs-variable">$userInfo</span> = OpenIdUserinfo::getUserinfo(<span class="hljs-variable">$params</span>, <span class="hljs-variable">$apiContext</span>);
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
ResultPrinter::printError(<span class="hljs-string">"User Information"</span>, <span class="hljs-string">"User Info"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$params</span>, <span class="hljs-variable">$ex</span>);

View File

@@ -2,11 +2,11 @@
<span class="hljs-keyword">require</span> <span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">'/../bootstrap.php'</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Auth</span>\<span class="hljs-title">Openid</span>\<span class="hljs-title">PPOpenIdSession</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">OpenIdSession</span>;
<span class="hljs-variable">$baseUrl</span> = getBaseUrl() . <span class="hljs-string">'/UserConsentRedirect.php?success=true'</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="get-user-consent-url">Get User Consent URL</h3>
<p>The clientId is stored in the bootstrap file</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">//Get Authorization URL returns the redirect URL that could be used to get user's consent</span>
<span class="hljs-variable">$redirectUrl</span> = PPOpenIdSession::getAuthorizationUrl(
<span class="hljs-variable">$redirectUrl</span> = OpenIdSession::getAuthorizationUrl(
<span class="hljs-variable">$baseUrl</span>,
<span class="hljs-keyword">array</span>(<span class="hljs-string">'profile'</span>, <span class="hljs-string">'email'</span>, <span class="hljs-string">'phone'</span>),
<span class="hljs-keyword">null</span>,

View File

@@ -2,8 +2,8 @@
<span class="hljs-keyword">require</span> <span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">'/../bootstrap.php'</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Auth</span>\<span class="hljs-title">Openid</span>\<span class="hljs-title">PPOpenIdTokeninfo</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Exception</span>\<span class="hljs-title">PPConnectionException</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">OpenIdTokeninfo</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Exception</span>\<span class="hljs-title">PayPalConnectionException</span>;
session_start();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="user-consent-response">User Consent Response</h3>
<p>PayPal would redirect the user to the redirect_uri mentioned when creating the consent URL.
@@ -11,8 +11,8 @@ The user would then able to retrieve the access token by getting the code, which
<span class="hljs-variable">$code</span> = <span class="hljs-variable">$_GET</span>[<span class="hljs-string">'code'</span>];
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Obtain Authorization Code from Code, Client ID and Client Secret</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$accessToken</span> = PPOpenIdTokeninfo::createFromAuthorizationCode(<span class="hljs-keyword">array</span>(<span class="hljs-string">'code'</span> =&gt; <span class="hljs-variable">$code</span>), <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$apiContext</span>);
} <span class="hljs-keyword">catch</span> (PPConnectionException <span class="hljs-variable">$ex</span>) {
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Obtain Authorization Code from Code, Client ID and Client Secret</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$accessToken</span> = OpenIdTokeninfo::createFromAuthorizationCode(<span class="hljs-keyword">array</span>(<span class="hljs-string">'code'</span> =&gt; <span class="hljs-variable">$code</span>), <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$apiContext</span>);
} <span class="hljs-keyword">catch</span> (PayPalConnectionException <span class="hljs-variable">$ex</span>) {
ResultPrinter::printError(<span class="hljs-string">"Obtained Access Token"</span>, <span class="hljs-string">"Access Token"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$_GET</span>[<span class="hljs-string">'code'</span>], <span class="hljs-variable">$ex</span>);
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}

View File

@@ -33,7 +33,7 @@ be using this in production</p></div></div><div class="code"><div class="wrapper
<span class="hljs-variable">$webhook</span>-&gt;setEventTypes(<span class="hljs-variable">$webhookEventTypes</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>For Sample Purposes Only.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$request</span> = <span class="hljs-keyword">clone</span> <span class="hljs-variable">$webhook</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="create-webhook">Create Webhook</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
<span class="hljs-variable">$output</span> = <span class="hljs-variable">$webhook</span>-&gt;create(<span class="hljs-variable">$apiContext</span>);
} <span class="hljs-keyword">catch</span> (<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {</div></div></div><div class="segment"><div class="code folded"><div class="wrapper marker"><span class="c1"> // Ignore workflow code segment</span></div><div class="wrapper"> <span class="hljs-comment">// Ignore workflow code segment</span>
<span class="hljs-keyword">if</span> (<span class="hljs-variable">$ex</span> <span class="hljs-keyword">instanceof</span> \PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException) {
<span class="hljs-keyword">if</span> (<span class="hljs-variable">$ex</span> <span class="hljs-keyword">instanceof</span> \PayPal\<span class="hljs-keyword">Exception</span>\PayPalConnectionException) {
<span class="hljs-variable">$data</span> = <span class="hljs-variable">$ex</span>-&gt;getData();
ResultPrinter::printError(<span class="hljs-string">"Created Webhook Failed. Checking if it is Webhook Number Limit Exceeded. Trying to delete all existing webhooks"</span>, <span class="hljs-string">"Webhook"</span>, <span class="hljs-string">"Please Use &lt;a style='color: red;' href='DeleteAllWebhooks.php' &gt;Delete All Webhooks&lt;/a&gt; Sample to delete all existing webhooks in sample"</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$ex</span>);
<span class="hljs-keyword">if</span> (strpos(<span class="hljs-variable">$data</span>,<span class="hljs-string">'WEBHOOK_NUMBER_LIMIT_EXCEEDED'</span>) !== <span class="hljs-keyword">false</span>) {

File diff suppressed because one or more lines are too long

View File

@@ -8,7 +8,7 @@ that contains the web profile ID.</p></div></div><div class="code"><div class="w
<span class="hljs-variable">$webProfile</span>-&gt;setId(<span class="hljs-variable">$createProfileResponse</span>-&gt;getId());
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Execute the delete method</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$webProfile</span>-&gt;delete(<span class="hljs-variable">$apiContext</span>);
} <span class="hljs-keyword">catch</span> (\PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException <span class="hljs-variable">$ex</span>) {
} <span class="hljs-keyword">catch</span> (\PayPal\<span class="hljs-keyword">Exception</span>\PayPalConnectionException <span class="hljs-variable">$ex</span>) {
ResultPrinter::printError(<span class="hljs-string">"Deleted Web Profile"</span>, <span class="hljs-string">"Web Profile"</span>, <span class="hljs-variable">$createProfileResponse</span>-&gt;getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}

View File

@@ -7,7 +7,7 @@ that contains the web profile ID.</p></div></div><div class="code"><div class="w
<span class="hljs-variable">$createProfileResponse</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'CreateWebProfile.php'</span>;
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>If your request is successful, the API returns a web_profile object response that contains the profile details.</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$webProfile</span> = \PayPal\Api\WebProfile::get(<span class="hljs-variable">$createProfileResponse</span>-&gt;getId(), <span class="hljs-variable">$apiContext</span>);
} <span class="hljs-keyword">catch</span> (\PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException <span class="hljs-variable">$ex</span>) {
} <span class="hljs-keyword">catch</span> (\PayPal\<span class="hljs-keyword">Exception</span>\PayPalConnectionException <span class="hljs-variable">$ex</span>) {
ResultPrinter::printError(<span class="hljs-string">"Get Web Profile"</span>, <span class="hljs-string">"Web Profile"</span>, <span class="hljs-variable">$webProfile</span>-&gt;getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}

View File

@@ -5,7 +5,7 @@
static <code>get_list</code> method on the WebProfile class.
(See bootstrap.php for more on <code>ApiContext</code>)</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {
<span class="hljs-variable">$list</span> = \PayPal\Api\WebProfile::get_list(<span class="hljs-variable">$apiContext</span>);
} <span class="hljs-keyword">catch</span> (\PayPal\<span class="hljs-keyword">Exception</span>\PPConnectionException <span class="hljs-variable">$ex</span>) {
} <span class="hljs-keyword">catch</span> (\PayPal\<span class="hljs-keyword">Exception</span>\PayPalConnectionException <span class="hljs-variable">$ex</span>) {
ResultPrinter::printError(<span class="hljs-string">"Get List of All Web Profiles"</span>, <span class="hljs-string">"Web Profiles"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$ex</span>);
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
}

View File

@@ -3,14 +3,14 @@
// ### Obtain Access Token From Refresh Token
require __DIR__ . '/../bootstrap.php';
use PayPal\Auth\Openid\PPOpenIdTokeninfo;
use PayPal\Api\OpenIdTokeninfo;
// You can retrieve the refresh token by executing ObtainUserConsent.php and store the refresh token
$refreshToken = 'yzX4AkmMyBKR4on7vB5he-tDu38s24Zy-kTibhSuqA8kTdy0Yinxj7NpAyULx0bxqC5G8dbXOt0aVMlMmtpiVmSzhcjVZhYDM7WUQLC9KpaXGBHyltJPkLLQkXE';
try {
$tokenInfo = new PPOpenIdTokeninfo();
$tokenInfo = new OpenIdTokeninfo();
$tokenInfo = $tokenInfo->createFromRefreshToken(array('refresh_token' => $refreshToken), $apiContext);
} catch (Exception $ex) {

View File

@@ -3,8 +3,8 @@
// ### Obtain Access Token From Refresh Token
require __DIR__ . '/../bootstrap.php';
use PayPal\Auth\Openid\PPOpenIdUserinfo;
use PayPal\Auth\Openid\PPOpenIdTokeninfo;
use PayPal\Api\OpenIdUserinfo;
use PayPal\Api\OpenIdTokeninfo;
// To obtain User Info, you have to follow three steps in general.
// First, you need to obtain user's consent to retrieve the information you want.
@@ -22,11 +22,11 @@ $refreshToken = 'yzX4AkmMyBKR4on7vB5he-tDu38s24Zy-kTibhSuqA8kTdy0Yinxj7NpAyULx0b
try {
$tokenInfo = new PPOpenIdTokeninfo();
$tokenInfo = new OpenIdTokeninfo();
$tokenInfo = $tokenInfo->createFromRefreshToken(array('refresh_token' => $refreshToken), $apiContext);
$params = array('access_token' => $tokenInfo->getAccessToken());
$userInfo = PPOpenIdUserinfo::getUserinfo($params, $apiContext);
$userInfo = OpenIdUserinfo::getUserinfo($params, $apiContext);
} catch (Exception $ex) {
ResultPrinter::printError("User Information", "User Info", null, $params, $ex);

View File

@@ -2,7 +2,7 @@
require __DIR__ . '/../bootstrap.php';
use PayPal\Auth\Openid\PPOpenIdSession;
use PayPal\Api\OpenIdSession;
$baseUrl = getBaseUrl() . '/UserConsentRedirect.php?success=true';
@@ -10,7 +10,7 @@ $baseUrl = getBaseUrl() . '/UserConsentRedirect.php?success=true';
// The clientId is stored in the bootstrap file
//Get Authorization URL returns the redirect URL that could be used to get user's consent
$redirectUrl = PPOpenIdSession::getAuthorizationUrl(
$redirectUrl = OpenIdSession::getAuthorizationUrl(
$baseUrl,
array('profile', 'email', 'phone'),
null,

View File

@@ -2,8 +2,8 @@
require __DIR__ . '/../bootstrap.php';
use PayPal\Auth\Openid\PPOpenIdTokeninfo;
use PayPal\Exception\PPConnectionException;
use PayPal\Api\OpenIdTokeninfo;
use PayPal\Exception\PayPalConnectionException;
session_start();
@@ -16,8 +16,8 @@ if (isset($_GET['success']) && $_GET['success'] == 'true') {
try {
// Obtain Authorization Code from Code, Client ID and Client Secret
$accessToken = PPOpenIdTokeninfo::createFromAuthorizationCode(array('code' => $code), null, null, $apiContext);
} catch (PPConnectionException $ex) {
$accessToken = OpenIdTokeninfo::createFromAuthorizationCode(array('code' => $code), null, null, $apiContext);
} catch (PayPalConnectionException $ex) {
ResultPrinter::printError("Obtained Access Token", "Access Token", null, $_GET['code'], $ex);
exit(1);
}

View File

@@ -54,7 +54,7 @@ try {
$output = $webhook->create($apiContext);
} catch (Exception $ex) {
// ^ Ignore workflow code segment
if ($ex instanceof \PayPal\Exception\PPConnectionException) {
if ($ex instanceof \PayPal\Exception\PayPalConnectionException) {
$data = $ex->getData();
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) {

View File

@@ -51,7 +51,7 @@ $request = clone $webProfile;
try {
// Use this call to create a profile.
$createProfileResponse = $webProfile->create($apiContext);
} catch (\PayPal\Exception\PPConnectionException $ex) {
} catch (\PayPal\Exception\PayPalConnectionException $ex) {
ResultPrinter::printError("Created Web Profile", "Web Profile", null, $request, $ex);
exit(1);
}

View File

@@ -18,7 +18,7 @@ $webProfile->setId($createProfileResponse->getId());
try {
// Execute the delete method
$webProfile->delete($apiContext);
} catch (\PayPal\Exception\PPConnectionException $ex) {
} catch (\PayPal\Exception\PayPalConnectionException $ex) {
ResultPrinter::printError("Deleted Web Profile", "Web Profile", $createProfileResponse->getId(), null, $ex);
exit(1);
}

View File

@@ -14,7 +14,7 @@ $createProfileResponse = require 'CreateWebProfile.php';
try {
// If your request is successful, the API returns a web_profile object response that contains the profile details.
$webProfile = \PayPal\Api\WebProfile::get($createProfileResponse->getId(), $apiContext);
} catch (\PayPal\Exception\PPConnectionException $ex) {
} catch (\PayPal\Exception\PayPalConnectionException $ex) {
ResultPrinter::printError("Get Web Profile", "Web Profile", $webProfile->getId(), null, $ex);
exit(1);
}

View File

@@ -10,7 +10,7 @@ $apiContext = require __DIR__ . '/../bootstrap.php';
// (See bootstrap.php for more on `ApiContext`)
try {
$list = \PayPal\Api\WebProfile::get_list($apiContext);
} catch (\PayPal\Exception\PPConnectionException $ex) {
} catch (\PayPal\Exception\PayPalConnectionException $ex) {
ResultPrinter::printError("Get List of All Web Profiles", "Web Profiles", null, null, $ex);
exit(1);
}

View File

@@ -38,7 +38,7 @@ log.LogLevel=FINE
;Validation Configuration
[validation]
; If validation is set to strict, the PPModel would make sure that
; If validation is set to strict, the PayPalModel would make sure that
; there are proper accessors (Getters and Setters) for each model
; objects. Accepted value is
; 'log' : logs the error message to logger only (default)