forked from LiveCarta/PayPal-PHP-SDK
Updates to Sample Code
- Updated UI Presentation on samples - Fixed Bugs
This commit is contained in:
@@ -1,31 +1,20 @@
|
||||
<!DOCTYPE html><html lang="en"><head><title>payments/GetAuthorization</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="payments/GetAuthorization"><meta name="groc-project-path" content="payments/GetAuthorization.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">payments/GetAuthorization.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"><h1 id="getauthorization">GetAuthorization</h1>
|
||||
<p>This sample code demonstrates how you can get details
|
||||
of an authorized payment.
|
||||
API used: /v1/payments/authorization/<$authorizationId></p></div></div><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>;
|
||||
API used: /v1/payments/authorization/<$authorizationId></p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/**<span class="hljs-phpdoc"> @var</span> Authorization $authorization */</span>
|
||||
<span class="hljs-variable">$authorization</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'AuthorizePayment.php'</span>;
|
||||
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Authorization</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="getauthorization">GetAuthorization</h3>
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Authorization</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Payment</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="getauthorization">GetAuthorization</h3>
|
||||
<p>You can retrieve info about an Authorization
|
||||
by invoking the Authorization::get method
|
||||
with a valid ApiContext (See bootstrap.php for more on <code>ApiContext</code>)
|
||||
The return object contains the authorization state.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>create a authorization to get authorization Id
|
||||
createAuthorization is defined in common.php</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$authId</span> = createAuthorization(<span class="hljs-variable">$apiContext</span>);
|
||||
</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Retrieve the authorization</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$authorization</span> = Authorization::get(<span class="hljs-variable">$authId</span>, <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">echo</span> <span class="hljs-string">"Exception: "</span> . <span class="hljs-variable">$ex</span>->getMessage() . PHP_EOL;
|
||||
var_dump(<span class="hljs-variable">$ex</span>->getData());
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
The return object contains the authorization state.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Retrieve the authorization</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$result</span> = Authorization::get(<span class="hljs-variable">$authorization</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>) {
|
||||
ResultPrinter::printError(<span class="hljs-string">"Get Authorization"</span>, <span class="hljs-string">"Authorization"</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>);
|
||||
}
|
||||
<span class="hljs-preprocessor">?></span>
|
||||
<html>
|
||||
<head>
|
||||
<title>Lookup an authorization</title>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
Retrieved Authorization:
|
||||
<span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$authorization</span>->getId();<span class="hljs-preprocessor">?></span>
|
||||
</div>
|
||||
<pre><span class="hljs-preprocessor"><?php</span> <span class="hljs-keyword">echo</span> <span class="hljs-variable">$authorization</span>->toJSON(<span class="hljs-number">128</span>);<span class="hljs-preprocessor">?></span></pre>
|
||||
<a href=<span class="hljs-string">'../index.html'</span>>Back</a>
|
||||
</body>
|
||||
</html></div></div></div></div></body></html>
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Get Authorization"</span>, <span class="hljs-string">"Authorization"</span>, <span class="hljs-variable">$authorization</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$result</span>);
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$authorization</span>;</div></div></div></div></body></html>
|
||||
Reference in New Issue
Block a user