Remove the TLS 1.2 sample

- All PayPal sandbox connections require TLS 1.2 so if there is a problem
  connecting to sandbox, you will encounter it across the board.
This commit is contained in:
Bryant Luk
2016-11-10 11:33:32 -06:00
parent 09b7d4526c
commit 331ed21fb2
5 changed files with 1 additions and 162 deletions

View File

@@ -1939,34 +1939,6 @@ f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3
]
}
]
}, {
"type": "folder",
"data": {
"path": "tls",
"title": "tls"
},
"depth": 1,
"children": [
{
"type": "file",
"data": {
"language": {
"nameMatchers": [{}, ".fbp"],
"pygmentsLexer": "php",
"singleLineComment": ["//"],
"ignorePrefix": "}",
"foldPrefix": "^",
"name": "PHP"
},
"sourcePath": "/Users/japatel/paypal/github/PayPal-PHP-SDK/sample/tls/TlsCheck.php",
"projectPath": "tls/TlsCheck.php",
"targetPath": "tls/TlsCheck",
"pageTitle": "tls/TlsCheck",
"title": "TlsCheck"
},
"depth": 2
}
]
}, {
"type": "folder",
"data": {

View File

@@ -1,46 +0,0 @@
<!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>