forked from LiveCarta/PayPal-PHP-SDK
Enabled Payment Experience
- Updated Api to enabled Payment Experience - Updated Tests and Samples - Added Json Validator - Ability for PPModel to return array of self objects
This commit is contained in:
20
sample/doc/payment-experience/CreateWebProfile.html
Normal file
20
sample/doc/payment-experience/CreateWebProfile.html
Normal file
File diff suppressed because one or more lines are too long
20
sample/doc/payment-experience/DeleteWebProfile.html
Normal file
20
sample/doc/payment-experience/DeleteWebProfile.html
Normal file
@@ -0,0 +1,20 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>payment-experience/DeleteWebProfile</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="payment-experience/DeleteWebProfile"><meta name="groc-project-path" content="payment-experience/DeleteWebProfile.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">payment-experience/DeleteWebProfile.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor"><?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h4 id="delete-web-profile">Delete Web Profile</h4>
|
||||
<p>Use this call to delete a web experience profile.
|
||||
Documentation available at <a href="https://developer.paypal.com/webapps/developer/docs/api/#delete-a-web-experience-profile">https://developer.paypal.com/webapps/developer/docs/api/#delete-a-web-experience-profile</a></p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>We are going to re-use the sample code from CreateWebProfile.php.
|
||||
If you have not visited the sample yet, please visit it before trying GetWebProfile.php
|
||||
The CreateWebProfile.php will create a web profile for us, and return a CreateProfileResponse,
|
||||
that contains the web profile ID.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> \PayPal\Api\CreateProfileResponse $result */</span>
|
||||
<span class="hljs-variable">$createProfileResponse</span> = <span class="hljs-keyword">require_once</span> <span class="hljs-string">'CreateWebProfile.php'</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Create a new instance of web Profile ID, and set the ID.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$webProfile</span> = <span class="hljs-keyword">new</span> \PayPal\Api\WebProfile();
|
||||
<span class="hljs-variable">$webProfile</span>->setId(<span class="hljs-variable">$createProfileResponse</span>->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>->delete(<span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (\<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>->getMessage() . PHP_EOL;
|
||||
<span class="hljs-keyword">if</span> (is_a(<span class="hljs-variable">$ex</span>, <span class="hljs-string">'\PayPal\Exception\PPConnectionException'</span>)) {
|
||||
<span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> $ex \PayPal\Exception\PPConnectionException */</span>
|
||||
var_dump(<span class="hljs-variable">$ex</span>->getData());
|
||||
}
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
print_result(<span class="hljs-string">"Deleted Web Profile"</span>, <span class="hljs-string">"Web Profile"</span>, <span class="hljs-variable">$createProfileResponse</span>->getId());</div></div></div></div></body></html>
|
||||
21
sample/doc/payment-experience/GetWebProfile.html
Normal file
21
sample/doc/payment-experience/GetWebProfile.html
Normal file
@@ -0,0 +1,21 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>payment-experience/GetWebProfile</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="payment-experience/GetWebProfile"><meta name="groc-project-path" content="payment-experience/GetWebProfile.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">payment-experience/GetWebProfile.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor"><?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="get-web-profile">Get Web Profile</h3>
|
||||
<p>If your request is successful, the API returns a web_profile object response that contains the profile details.
|
||||
Documentation available at <a href="https://developer.paypal.com/webapps/developer/docs/api/#retrieve-a-web-experience-profile">https://developer.paypal.com/webapps/developer/docs/api/#retrieve-a-web-experience-profile</a></p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>We are going to re-use the sample code from CreateWebProfile.php.
|
||||
If you have not visited the sample yet, please visit it before trying GetWebProfile.php
|
||||
The CreateWebProfile.php will create a web profile for us, and return a CreateProfileResponse,
|
||||
that contains the web profile ID.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> \PayPal\Api\CreateProfileResponse $result */</span>
|
||||
<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>->getId(), <span class="hljs-variable">$apiContext</span>);
|
||||
} <span class="hljs-keyword">catch</span> (\<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>->getMessage() . PHP_EOL;
|
||||
<span class="hljs-keyword">if</span> (is_a(<span class="hljs-variable">$ex</span>, <span class="hljs-string">'\PayPal\Exception\PPConnectionException'</span>)) {
|
||||
<span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> $ex \PayPal\Exception\PPConnectionException */</span>
|
||||
var_dump(<span class="hljs-variable">$ex</span>->getData());
|
||||
}
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
print_result(<span class="hljs-string">"Get Web Profile"</span>, <span class="hljs-string">"Web Profile"</span>, <span class="hljs-variable">$webProfile</span>->getId(), <span class="hljs-variable">$webProfile</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$webProfile</span>;</div></div></div></div></body></html>
|
||||
23
sample/doc/payment-experience/ListWebProfiles.html
Normal file
23
sample/doc/payment-experience/ListWebProfiles.html
Normal file
@@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>payment-experience/ListWebProfiles</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="payment-experience/ListWebProfiles"><meta name="groc-project-path" content="payment-experience/ListWebProfiles.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">payment-experience/ListWebProfiles.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor"><?php</span>
|
||||
|
||||
<span class="hljs-variable">$apiContext</span> = <span class="hljs-keyword">require</span> <span class="hljs-keyword">__DIR__</span> . <span class="hljs-string">'/../bootstrap.php'</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-list-of-all-web-profiles">Retrieve List of All Web Profiles</h3>
|
||||
<p>Documentation available at <a href="https://developer.paypal.com/webapps/developer/docs/api/#list-web-experience-profiles">https://developer.paypal.com/webapps/developer/docs/api/#list-web-experience-profiles</a></p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Retrieve the list of all web profiles by calling the
|
||||
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> (\<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>->getMessage() . PHP_EOL;
|
||||
<span class="hljs-keyword">if</span> (is_a(<span class="hljs-variable">$ex</span>, <span class="hljs-string">'\PayPal\Exception\PPConnectionException'</span>)) {
|
||||
<span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> $ex \PayPal\Exception\PPConnectionException */</span>
|
||||
var_dump(<span class="hljs-variable">$ex</span>->getData());
|
||||
}
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
<span class="hljs-variable">$result</span> = <span class="hljs-string">''</span>;
|
||||
<span class="hljs-keyword">foreach</span> (<span class="hljs-variable">$list</span> <span class="hljs-keyword">as</span> <span class="hljs-variable">$object</span>) {
|
||||
<span class="hljs-variable">$result</span> .= <span class="hljs-variable">$object</span>->toJSON(JSON_PRETTY_PRINT) . PHP_EOL;
|
||||
}
|
||||
|
||||
print_result(<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-variable">$result</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$list</span>;</div></div></div></div></body></html>
|
||||
29
sample/doc/payment-experience/PartiallyUpdateWebProfile.html
Normal file
29
sample/doc/payment-experience/PartiallyUpdateWebProfile.html
Normal file
@@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>payment-experience/PartiallyUpdateWebProfile</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="payment-experience/PartiallyUpdateWebProfile"><meta name="groc-project-path" content="payment-experience/PartiallyUpdateWebProfile.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">payment-experience/PartiallyUpdateWebProfile.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor"><?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h4 id="partially-update-web-profile">Partially Update Web Profile</h4>
|
||||
<p>Use this call to partially update a web experience profile.
|
||||
Documentation available at <a href="https://developer.paypal.com/webapps/developer/docs/api/#partially-update-a-web-experience-profile">https://developer.paypal.com/webapps/developer/docs/api/#partially-update-a-web-experience-profile</a></p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>We will be re-using the sample code to get a web profile. GetWebProfile.php will
|
||||
create a new web profileId for sample, and return the web profile object.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> \PayPal\Api\WebProfile $webProfile */</span>
|
||||
<span class="hljs-variable">$webProfile</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'GetWebProfile.php'</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="create-patch-operation">Create Patch Operation</h3>
|
||||
<p>APIs allows us to pass an array of patches
|
||||
to make patch operations.
|
||||
Each Patch operation can be created by using Patch Class
|
||||
as shown below</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$patchOperation1</span> = <span class="hljs-keyword">new</span> \PayPal\Api\Patch();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>The operation to perform. Required. Allowed values: add, remove, replace, move, copy, test</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$patchOperation1</span>->setOp(<span class="hljs-string">"add"</span>)</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>string containing a JSON-Pointer value that references a location within the target document (the target location) where the operation is performed. Required.</p></div></div><div class="code"><div class="wrapper"> ->setPath(<span class="hljs-string">"/presentation/brand_name"</span>)</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>New value to apply based on the operation.</p></div></div><div class="code"><div class="wrapper"> ->setValue(<span class="hljs-string">"New Brand Name"</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Similar patch operation to remove the landing page type</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$patchOperation2</span> = <span class="hljs-keyword">new</span> \PayPal\Api\Patch();
|
||||
<span class="hljs-variable">$patchOperation2</span>->setOp(<span class="hljs-string">"remove"</span>)
|
||||
->setPath(<span class="hljs-string">"/flow_config/landing_page_type"</span>);
|
||||
|
||||
|
||||
<span class="hljs-comment">//Generate an array of patch operations</span>
|
||||
<span class="hljs-variable">$patches</span> = <span class="hljs-keyword">array</span>(<span class="hljs-variable">$patchOperation1</span>, <span class="hljs-variable">$patchOperation2</span>);
|
||||
|
||||
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Execute the partial update, to carry out these two operations on a given web profile object</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-keyword">if</span> (<span class="hljs-variable">$webProfile</span>->partial_update(<span class="hljs-variable">$patches</span>, <span class="hljs-variable">$apiContext</span>)) {
|
||||
<span class="hljs-variable">$webProfile</span> = \PayPal\Api\WebProfile::get(<span class="hljs-variable">$webProfile</span>->getId(), <span class="hljs-variable">$apiContext</span>);
|
||||
}
|
||||
} <span class="hljs-keyword">catch</span> (\<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>->getMessage() . PHP_EOL;
|
||||
<span class="hljs-keyword">if</span> (is_a(<span class="hljs-variable">$ex</span>, <span class="hljs-string">'\PayPal\Exception\PPConnectionException'</span>)) {
|
||||
<span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> $ex \PayPal\Exception\PPConnectionException */</span>
|
||||
var_dump(<span class="hljs-variable">$ex</span>->getData());
|
||||
}
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
print_result(<span class="hljs-string">"Partially Updated Web Profile"</span>, <span class="hljs-string">"Web Profile"</span>, <span class="hljs-variable">$webProfile</span>->getId(), <span class="hljs-variable">$webProfile</span>);</div></div></div></div></body></html>
|
||||
19
sample/doc/payment-experience/UpdateWebProfile.html
Normal file
19
sample/doc/payment-experience/UpdateWebProfile.html
Normal file
@@ -0,0 +1,19 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>payment-experience/UpdateWebProfile</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="payment-experience/UpdateWebProfile"><meta name="groc-project-path" content="payment-experience/UpdateWebProfile.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">payment-experience/UpdateWebProfile.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor"><?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h4 id="update-web-profile">Update Web Profile</h4>
|
||||
<p>Use this call to update an experience profile.
|
||||
Documentation available at <a href="https://developer.paypal.com/webapps/developer/docs/api/#update-a-web-experience-profile">https://developer.paypal.com/webapps/developer/docs/api/#update-a-web-experience-profile</a></p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>We will be re-using the sample code to get a web profile. GetWebProfile.php will
|
||||
create a new web profileId for sample, and return the web profile object.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> \PayPal\Api\WebProfile $webProfile */</span>
|
||||
<span class="hljs-variable">$webProfile</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'GetWebProfile.php'</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Updated the logo image of presentation object in a given web profile.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$webProfile</span>->getPresentation()->setLogoImage(<span class="hljs-string">"http://www.google.com/favico.ico"</span>);
|
||||
|
||||
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Update the web profile to change the logo image.</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-keyword">if</span> (<span class="hljs-variable">$webProfile</span>->update(<span class="hljs-variable">$apiContext</span>)) {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>If the update is successfull, we can now get the object, and verify the web profile
|
||||
object</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$updatedWebProfile</span> = \PayPal\Api\WebProfile::get(<span class="hljs-variable">$webProfile</span>->getId(), <span class="hljs-variable">$apiContext</span>);
|
||||
}
|
||||
} <span class="hljs-keyword">catch</span> (\<span class="hljs-keyword">Exception</span> <span class="hljs-variable">$ex</span>) {
|
||||
<span class="hljs-keyword">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>->getMessage() . PHP_EOL;
|
||||
<span class="hljs-keyword">if</span> (is_a(<span class="hljs-variable">$ex</span>, <span class="hljs-string">'\PayPal\Exception\PPConnectionException'</span>)) {
|
||||
<span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> $ex \PayPal\Exception\PPConnectionException */</span>
|
||||
var_dump(<span class="hljs-variable">$ex</span>->getData());
|
||||
}
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
print_result(<span class="hljs-string">"Updated Web Profile"</span>, <span class="hljs-string">"Web Profile"</span>, <span class="hljs-variable">$updatedWebProfile</span>->getId(), <span class="hljs-variable">$updatedWebProfile</span>);</div></div></div></div></body></html>
|
||||
Reference in New Issue
Block a user