forked from LiveCarta/PayPal-PHP-SDK
Remove credit card samples (#896)
* removed credit card payment samples * update docs to reflect sample changes * update readme to recommend braintree for direct card payments
This commit is contained in:
@@ -2,19 +2,19 @@
|
||||
<p>This sample code demonstrates how you can
|
||||
process a refund on a Captured transaction.
|
||||
API used: /v1/payments/capture/{<captureID>}/refund</p></div></div><div class="code"><div class="wrapper"><span class="hljs-comment">/** <span class="hljs-doctag">@var</span> Capture $capture */</span>
|
||||
<span class="hljs-variable">$capture</span> = <span class="hljs-keyword">require</span> <span class="hljs-string">'AuthorizationCapture.php'</span>;
|
||||
|
||||
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Capture</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Refund</span>;
|
||||
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">RefundRequest</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="refund">Refund</h3>
|
||||
<p>Create a refund object indicating
|
||||
refund amount and call the refund method</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$refundRequest</span> = <span class="hljs-keyword">new</span> RefundRequest();
|
||||
<span class="hljs-variable">$refundRequest</span>->setAmount(<span class="hljs-variable">$amt</span>);
|
||||
refund amount and call the refund method</p></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Replace $captureId with any static Id you might already have. </p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$captureId</span> = <span class="hljs-string">"<your authorization id here>"</span>;
|
||||
|
||||
|
||||
|
||||
<span class="hljs-keyword">try</span> {</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>Create a new apiContext object so we send a new
|
||||
PayPal-Request-Id (idempotency) header for this resource</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$apiContext</span> = getApiContext(<span class="hljs-variable">$clientId</span>, <span class="hljs-variable">$clientSecret</span>);
|
||||
PayPal-Request-Id (idempotency) header for this resource</p></div></div><div class="code"><div class="wrapper"> <span class="hljs-variable">$apiContext</span> = getApiContext(<span class="hljs-variable">$clientId</span>, <span class="hljs-variable">$clientSecret</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="retrieve-capture-details">Retrieve Capture details</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"> <span class="hljs-variable">$capture</span> = Capture::get(<span class="hljs-variable">$captureId</span>, <span class="hljs-variable">$apiContext</span>);</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="refund-the-capture">Refund the Capture</h3></div></div></div><div class="segment"><div class="code"><div class="wrapper"> <span class="hljs-variable">$captureRefund</span> = <span class="hljs-variable">$capture</span>->refundCapturedPayment(<span class="hljs-variable">$refundRequest</span>, <span class="hljs-variable">$apiContext</span>);
|
||||
|
||||
<span class="hljs-variable">$captureRefund</span> = <span class="hljs-variable">$capture</span>->refundCapturedPayment(<span class="hljs-variable">$refundRequest</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>) {</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">"Refund Capture"</span>, <span class="hljs-string">"Capture"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$refundRequest</span>, <span class="hljs-variable">$ex</span>);
|
||||
<span class="hljs-keyword">exit</span>(<span class="hljs-number">1</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">"Refund Capture"</span>, <span class="hljs-string">"Capture"</span>, <span class="hljs-variable">$captureRefund</span>->getId(), <span class="hljs-variable">$refundRequest</span>, <span class="hljs-variable">$captureRefund</span>);</div></div></div></div></body></html>
|
||||
}</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">"Refund Capture"</span>, <span class="hljs-string">"Capture"</span>, <span class="hljs-variable">$captureRefund</span>->getId(), <span class="hljs-variable">$refundRequest</span>, <span class="hljs-variable">$captureRefund</span>);</div></div></div></div></body></html>
|
||||
Reference in New Issue
Block a user