forked from LiveCarta/PayPal-PHP-SDK
22 lines
4.5 KiB
HTML
22 lines
4.5 KiB
HTML
<!DOCTYPE html><html lang="en"><head><title>invoice/GetThirdPartyInvoice</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="invoice/GetThirdPartyInvoice"><meta name="groc-project-path" content="invoice/GetThirdPartyInvoice.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">invoice/GetThirdPartyInvoice.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="get-third-invoice-sample">Get Third Invoice Sample</h1>
|
|
<p>This sample code demonstrate how you can retrieve
|
|
a third party invoice.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/** <span class="hljs-doctag">@var</span> Invoice $invoice */</span>
|
|
<span class="hljs-variable">$invoice</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'CreateThirdPartyInvoice.php'</span>;
|
|
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Invoice</span>;
|
|
|
|
<span class="hljs-variable">$invoiceId</span> = <span class="hljs-variable">$invoice</span>->getId();</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Step 1. This would be refresh token retrieved from <a href="http://paypal.github.io/PayPal-PHP-SDK/sample/doc/lipp/ObtainUserConsent.html">http://paypal.github.io/PayPal-PHP-SDK/sample/doc/lipp/ObtainUserConsent.html</a></p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$refreshToken</span> = <span class="hljs-string">"SCNWVZfdg43XaOmoEicazpkXyda32CGnP208EkuQ_QBIrXCYMhlvORFHHyoXPT0VbEMIHYVJEm0gVf1Vf72YgJzPScBenKoVPq__y1QRT7wwJo3WYADwUW4Q5ic"</span>;
|
|
|
|
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="step-2">Step 2</h3>
|
|
<p>Update your apiContext with refresh token obtained from Step 1.</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$apiContext</span>->getCredential()->updateAccessToken(<span class="hljs-variable">$apiContext</span>->getConfig(), <span class="hljs-variable">$refreshToken</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-invoice">Retrieve Invoice</h3>
|
|
<p>Retrieve the invoice object by calling the
|
|
static <code>get</code> method
|
|
on the Invoice class by passing a valid
|
|
Invoice ID
|
|
(See bootstrap.php for more on <code>ApiContext</code>)
|
|
Similar calls can be done to search invoices, delete, and update.</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$retrievedInvoice</span> = Invoice::get(<span class="hljs-variable">$invoiceId</span>, <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 Third Party Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$retrievedInvoice</span>->getId(), <span class="hljs-variable">$invoiceId</span>, <span class="hljs-variable">$retrievedInvoice</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">"Get Third Party Invoice"</span>, <span class="hljs-string">"Invoice"</span>, <span class="hljs-variable">$invoiceId</span>, <span class="hljs-variable">$invoiceId</span>, <span class="hljs-variable">$ex</span>);
|
|
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</span>);
|
|
}
|
|
|
|
<span class="hljs-keyword">return</span> <span class="hljs-variable">$retrievedInvoice</span>;</div></div></div></div></body></html>
|