This repository has been archived on 2024-06-26. You can view files and clone it, but cannot push or open issues or pull requests.
sakura/_sakura/vendor/paypal/rest-api-sdk-php/sample/source/GetSale.html

30 lines
No EOL
4.5 KiB
HTML

<!DOCTYPE html><html lang="en"><head><title>GetSale</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="GetSale"><meta name="groc-project-path" content="GetSale.php"><link rel="stylesheet" type="text/css" media="all" href="assets/style.css"><body><div id="document"><div class="segment"><a id="segment-0" name="segment-0" class="section_anchor"></a><div class="code"><div class="wrapper"><span class="cp">&lt;?php</span></div></div></div><div class="segment"><a id="segment-1" name="segment-1" class="section_anchor"></a><div class="comments"><div class="pilwrap"><a href="#segment-1" class="pilcrow"></a></div><div class="wrapper"><h1 id="get-sale-sample">Get Sale sample</h1>
<p>This sample code demonstrates how you can retrieve
details of completed Sale Transaction.
API used: /v1/payments/sale/{sale-id}</p></div></div><div class="code"><div class="wrapper"><span class="k">require</span> <span class="nx">__DIR__</span> <span class="o">.</span> <span class="s1">&#39;/../bootstrap.php&#39;</span><span class="p">;</span>
<span class="k">use</span> <span class="nx">PayPal\Api\Sale</span><span class="p">;</span>
<span class="nv">$saleId</span> <span class="o">=</span> <span class="s1">&#39;3RM92092UW5126232&#39;</span><span class="p">;</span></div></div></div><div class="segment"><a id="segment-2" name="segment-2" class="section_anchor"></a><div class="comments"><div class="pilwrap"><a href="#segment-2" class="pilcrow"></a></div><div class="wrapper"><h3 id="authentication">Authentication</h3>
<p>Pass in a <code>OAuthTokenCredential</code> object
explicilty to authenticate the call.
If you skip this step, the client id/secret
set in the config file will be used. </p></div></div><div class="code"><div class="wrapper"><span class="nx">Sale</span><span class="o">::</span><span class="na">setCredential</span><span class="p">(</span><span class="nv">$cred</span><span class="p">);</span>
<span class="k">try</span> <span class="p">{</span> </div></div></div><div class="segment"><a id="segment-3" name="segment-3" class="section_anchor"></a><div class="comments"><div class="pilwrap"><a href="#segment-3" class="pilcrow"></a></div><div class="wrapper"><h3 id="retrieve-the-sale-object">Retrieve the sale object</h3>
<p>Pass the ID of the sale
transaction from your payment resource.</p></div></div><div class="code"><div class="wrapper"> <span class="nv">$sale</span> <span class="o">=</span> <span class="nx">Sale</span><span class="o">::</span><span class="na">get</span><span class="p">(</span><span class="nv">$saleId</span><span class="p">);</span>
<span class="p">}</span> <span class="k">catch</span> <span class="p">(</span><span class="nx">\PPConnectionException</span> <span class="nv">$ex</span><span class="p">)</span> <span class="p">{</span>
<span class="k">echo</span> <span class="s2">&quot;Exception:&quot;</span> <span class="o">.</span> <span class="nv">$ex</span><span class="o">-&gt;</span><span class="na">getMessage</span><span class="p">()</span> <span class="o">.</span> <span class="nx">PHP_EOL</span><span class="p">;</span>
<span class="nb">var_dump</span><span class="p">(</span><span class="nv">$ex</span><span class="o">-&gt;</span><span class="na">getData</span><span class="p">());</span>
<span class="k">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">);</span>
<span class="p">}</span>
<span class="cp">?&gt;</span><span class="x"></span>
<span class="x">&lt;html&gt;</span>
<span class="x">&lt;body&gt;</span>
<span class="x"> &lt;div&gt;Retrieving sale id: </span><span class="cp">&lt;?php</span> <span class="k">echo</span> <span class="nv">$saleId</span><span class="p">;</span><span class="cp">?&gt;</span><span class="x">&lt;/div&gt;</span>
<span class="x"> &lt;pre&gt;</span><span class="cp">&lt;?php</span> <span class="nb">var_dump</span><span class="p">(</span><span class="nv">$sale</span><span class="p">);</span><span class="cp">?&gt;</span><span class="x">&lt;/pre&gt;</span>
<span class="x"> &lt;a href=&#39;../index.html&#39;&gt;Back&lt;/a&gt;</span>
<span class="x">&lt;/body&gt;</span>
<span class="x">&lt;/html&gt;</span></div></div></div><div class="segment"><div class="comments"><a href="../">Back</a></div></div></div><script type="text/javascript" src="assets/jquery.min.js"></script><script type="text/javascript" src="assets/docs.js"></script></body></html>