forked from LiveCarta/PayPal-PHP-SDK
Sample ResultPrinter Not to be Used
- Comment everywhere the ResultPrinter is used to not use outside sample
This commit is contained in:
@@ -72,14 +72,10 @@ Payment ID
|
||||
(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">$result</span> = <span class="hljs-variable">$createdPayment</span>->update(<span class="hljs-variable">$patchRequest</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">"Update Payment"</span>, <span class="hljs-string">"PatchRequest"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$patchRequest</span>, <span class="hljs-variable">$ex</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="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printError(<span class="hljs-string">"Update Payment"</span>, <span class="hljs-string">"PatchRequest"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$patchRequest</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Update Payment"</span>, <span class="hljs-string">"PatchRequest"</span>, <span class="hljs-variable">$payment</span>->getId(), <span class="hljs-variable">$patchRequest</span>, <span class="hljs-keyword">null</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="getting-updated-payment-object">Getting Updated Payment Object</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-keyword">if</span> (<span class="hljs-variable">$result</span> == <span class="hljs-keyword">true</span>) {
|
||||
<span class="hljs-variable">$result</span> = Payment::get(<span class="hljs-variable">$createdPayment</span>->getId(), <span class="hljs-variable">$apiContext</span>);
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Get Payment"</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-variable">$result</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$result</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="get-redirect-url">Get redirect url</h3>
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Update Payment"</span>, <span class="hljs-string">"PatchRequest"</span>, <span class="hljs-variable">$payment</span>->getId(), <span class="hljs-variable">$patchRequest</span>, <span class="hljs-keyword">null</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="getting-updated-payment-object">Getting Updated Payment Object</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-keyword">if</span> (<span class="hljs-variable">$result</span> == <span class="hljs-keyword">true</span>) {
|
||||
<span class="hljs-variable">$result</span> = Payment::get(<span class="hljs-variable">$createdPayment</span>->getId(), <span class="hljs-variable">$apiContext</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Get Payment"</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-variable">$result</span>->getId(), <span class="hljs-keyword">null</span>, <span class="hljs-variable">$result</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="get-redirect-url">Get redirect url</h3>
|
||||
<p>The API response provides the url that you must redirect
|
||||
the buyer to. Retrieve the url from the $payment->getLinks()
|
||||
method</p></div></div><div class="code"><div class="wrapper"><span class="hljs-keyword">foreach</span> (<span class="hljs-variable">$result</span>->getLinks() <span class="hljs-keyword">as</span> <span class="hljs-variable">$link</span>) {
|
||||
@@ -87,9 +83,7 @@ method</p></div></div><div class="code"><div class="wrapper"><span class="hljs-k
|
||||
<span class="hljs-variable">$approvalUrl</span> = <span class="hljs-variable">$link</span>->getHref();
|
||||
<span class="hljs-keyword">break</span>;
|
||||
}
|
||||
}
|
||||
|
||||
ResultPrinter::printResult(<span class="hljs-string">"Created Payment Using PayPal. Please visit the URL to Approve."</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-string">"<a href='$approvalUrl' >$approvalUrl</a>"</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$result</span>);
|
||||
}</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY</p></div></div><div class="code"><div class="wrapper"> ResultPrinter::printResult(<span class="hljs-string">"Created Payment Using PayPal. Please visit the URL to Approve."</span>, <span class="hljs-string">"Payment"</span>, <span class="hljs-string">"<a href='$approvalUrl' >$approvalUrl</a>"</span>, <span class="hljs-variable">$request</span>, <span class="hljs-variable">$result</span>);
|
||||
}
|
||||
|
||||
<span class="hljs-keyword">return</span> <span class="hljs-variable">$result</span>;</div></div></div></div></body></html>
|
||||
Reference in New Issue
Block a user