This repository has been archived on 2026-04-06. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
PayPal-PHP-SDK/sample/doc/tls/TlsCheck.html
Bhavani Bheemanadham 63fa5b73a8 Releasinator changes
- Updated Releasinator version to 0.6
- Renamed Changelog.md file to CHANGELOG.md
- Added new line at the end of file
2016-07-15 14:52:00 -05:00

47 lines
7.6 KiB
HTML

<!DOCTYPE html><html lang="en"><head><title>tls/TlsCheck</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="tls/TlsCheck"><meta name="groc-project-path" content="tls/TlsCheck.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">tls/TlsCheck.php</div></div><div id="document"><div class="segment"><div class="code"><div class="wrapper"><span class="hljs-preprocessor">&lt;?php</span></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h1 id="create-payment-using-paypal-as-payment-method">Create Payment using PayPal as payment method</h1>
<p>This sample code demonstrates how you can process a
PayPal Account based Payment.
API used: /v1/payments/payment</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>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Amount</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Payer</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>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">RedirectUrls</span>;
<span class="hljs-keyword">use</span> <span class="hljs-title">PayPal</span>\<span class="hljs-title">Api</span>\<span class="hljs-title">Transaction</span>;</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h2 id="tls-check">TLS Check</h2>
<p>We will add a separate unique endpoint specifically set for testing TLS check instead of using
our conventional sandbox endpoint.
TLS ENDPOINT: <a href="https://test-api.sandbox.paypal.com">https://test-api.sandbox.paypal.com</a>
To test your own implementation to verify it TLS is successfully supported in your application, you can follow
the following steps.</p>
<ol>
<li>Create an APIContext object as usual. (No Change Required).</li>
<li>Add Configs as shown below to your apiContext object
Note: Explicitly disabling caching for specific testing.</li>
</ol></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$apiContext</span>-&gt;setConfig(<span class="hljs-keyword">array</span>(<span class="hljs-string">'service.EndPoint'</span>=&gt;<span class="hljs-string">"https://test-api.sandbox.paypal.com"</span>, <span class="hljs-string">'cache.enabled'</span>=&gt;<span class="hljs-keyword">false</span>));</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><ol>
<li>Thats it. Run your code, and see if it works as normal.</li>
<li>You can check sdk logs to verify it is infact pointing to the above URL instead of default sandbox one.</li>
</ol></div></div></div><div class="segment"><div class="comments "><div class="wrapper"><h3 id="create-a-payment-for-testing">Create a Payment for testing</h3>
<p>We will create a conventional paypal payment to verify its creation</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$payer</span> = <span class="hljs-keyword">new</span> Payer();
<span class="hljs-variable">$payer</span>-&gt;setPaymentMethod(<span class="hljs-string">"paypal"</span>);
<span class="hljs-variable">$amount</span> = <span class="hljs-keyword">new</span> Amount();
<span class="hljs-variable">$amount</span>-&gt;setCurrency(<span class="hljs-string">"USD"</span>)
-&gt;setTotal(<span class="hljs-number">20</span>);
<span class="hljs-variable">$transaction</span> = <span class="hljs-keyword">new</span> Transaction();
<span class="hljs-variable">$transaction</span>-&gt;setAmount(<span class="hljs-variable">$amount</span>);
<span class="hljs-variable">$baseUrl</span> = getBaseUrl();
<span class="hljs-variable">$redirectUrls</span> = <span class="hljs-keyword">new</span> RedirectUrls();
<span class="hljs-variable">$redirectUrls</span>-&gt;setReturnUrl(<span class="hljs-string">"$baseUrl/ExecutePayment.php?success=true"</span>)
-&gt;setCancelUrl(<span class="hljs-string">"$baseUrl/ExecutePayment.php?success=false"</span>);
<span class="hljs-variable">$payment</span> = <span class="hljs-keyword">new</span> Payment();
<span class="hljs-variable">$payment</span>-&gt;setIntent(<span class="hljs-string">"sale"</span>)
-&gt;setPayer(<span class="hljs-variable">$payer</span>)
-&gt;setRedirectUrls(<span class="hljs-variable">$redirectUrls</span>)
-&gt;setTransactions(<span class="hljs-keyword">array</span>(<span class="hljs-variable">$transaction</span>));</div></div></div><div class="segment"><div class="comments "><div class="wrapper"><p>For Sample Purposes Only.</p></div></div><div class="code"><div class="wrapper"><span class="hljs-variable">$request</span> = <span class="hljs-keyword">clone</span> <span class="hljs-variable">$payment</span>;
<span class="hljs-variable">$curl_info</span> = curl_version();
<span class="hljs-keyword">try</span> {
<span class="hljs-variable">$payment</span>-&gt;create(<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">"FAILURE: SECURITY WARNING: TLSv1.2 is not supported on this system. Please upgrade your curl to atleast 7.34.0.&lt;br /&gt; - Current Curl Version: "</span> . <span class="hljs-variable">$curl_info</span>[<span class="hljs-string">'version'</span>] . <span class="hljs-string">"&lt;br /&gt; - Current OpenSSL Version:"</span> . <span class="hljs-variable">$curl_info</span>[<span class="hljs-string">'ssl_version'</span>], <span class="hljs-string">"Payment"</span>, <span class="hljs-keyword">null</span>, <span class="hljs-variable">$request</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">"&lt;b&gt;SUCCESS&lt;/b&gt;: Your server supports TLS protocols required for secure connection to PayPal Servers. &lt;br /&gt; - Current Curl Version: "</span> . <span class="hljs-variable">$curl_info</span>[<span class="hljs-string">'version'</span>] . <span class="hljs-string">"&lt;br /&gt; - Current OpenSSL Version:"</span> . <span class="hljs-variable">$curl_info</span>[<span class="hljs-string">'ssl_version'</span>], <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-keyword">null</span>, <span class="hljs-string">"SUCCESS. Your system supports TLSv1.2"</span>);
<span class="hljs-keyword">return</span> <span class="hljs-variable">$payment</span>;</div></div></div></div></body></html>