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

@@ -10,7 +10,7 @@ __Welcome to PayPal PHP SDK__. This repository contains PayPal's PHP SDK and sam
## Please Note
> **The Payment Card Industry (PCI) Council has [mandated](http://blog.pcisecuritystandards.org/migrating-from-ssl-and-early-tls) that early versions of TLS be retired from service. All organizations that handle credit card information are required to comply with this standard. As part of this obligation, PayPal is updating its services to require TLS 1.2 for all HTTPS connections. At this time, PayPal will also require HTTP/1.1 for all connections. [Click here](https://github.com/paypal/tls-update) for more information**
> **If you have the SDK v1.6.2 or higher installed, you can easily test this by running the [TLSCheck sample](sample/tls/TlsCheck.php).**
> **Connections to the sandbox environment use only TLS 1.2.**
## SDK Documentation

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>

View File

@@ -232,30 +232,6 @@ if (PHP_SAPI == 'cli') {
</div>
</div>
<div class="col-md-9 samples">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 id="tls" class="panel-title"><a
href="https://developer.paypal.com/webapps/developer/docs/api/#payments"
target="_blank">TLS CHECK</a></h3>
</div>
<!-- List group -->
<ul class="list-group">
<li class="list-group-item">
<div class="row">
<div class="col-md-8"><h5>Check if your system supports TLSv1.2<h5></div>
<div class="col-md-4">
<a href="tls/TlsCheck.php" class="btn btn-primary pull-left execute"> Try It <i
class="fa fa-play-circle-o"></i></a>
<a href="doc/tls/TlsCheck.html" class="btn btn-default pull-right">Source <i
class="fa fa-file-code-o"></i></a>
<a href="https://github.com/paypal/tls-update#php" class="btn btn-default pull-right">Read More <i
class="fa fa-exclamation"></i></a>
</div>
</div>
</li>
</ul>
</div>
<div class="panel panel-primary">
<div class="panel-heading">
<h3 id="payments" class="panel-title"><a

View File

@@ -1,63 +0,0 @@
<?php
// # Create Payment using PayPal as payment method
// This sample code demonstrates how you can process a
// PayPal Account based Payment.
// API used: /v1/payments/payment
require __DIR__ . '/../bootstrap.php';
use PayPal\Api\Amount;
use PayPal\Api\Payer;
use PayPal\Api\Payment;
use PayPal\Api\RedirectUrls;
use PayPal\Api\Transaction;
// ## TLS Check
// We will add a separate unique endpoint specifically set for testing TLS check instead of using
// our conventional sandbox endpoint.
// TLS ENDPOINT: https://test-api.sandbox.paypal.com
// To test your own implementation to verify it TLS is successfully supported in your application, you can follow
// the following steps.
// 1. Create an APIContext object as usual. (No Change Required).
// 2. Add Configs as shown below to your apiContext object
// Note: Explicitly disabling caching for specific testing.
$apiContext->setConfig(array('service.EndPoint'=>"https://test-api.sandbox.paypal.com", 'cache.enabled'=>false));
// 3. Thats it. Run your code, and see if it works as normal.
// 4. You can check sdk logs to verify it is infact pointing to the above URL instead of default sandbox one.
// ### Create a Payment for testing
// We will create a conventional paypal payment to verify its creation
$payer = new Payer();
$payer->setPaymentMethod("paypal");
$amount = new Amount();
$amount->setCurrency("USD")
->setTotal(20);
$transaction = new Transaction();
$transaction->setAmount($amount);
$baseUrl = getBaseUrl();
$redirectUrls = new RedirectUrls();
$redirectUrls->setReturnUrl("$baseUrl/ExecutePayment.php?success=true")
->setCancelUrl("$baseUrl/ExecutePayment.php?success=false");
$payment = new Payment();
$payment->setIntent("sale")
->setPayer($payer)
->setRedirectUrls($redirectUrls)
->setTransactions(array($transaction));
// For Sample Purposes Only.
$request = clone $payment;
$curl_info = curl_version();
try {
$payment->create($apiContext);
} catch (Exception $ex) {
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printError("FAILURE: SECURITY WARNING: TLSv1.2 is not supported on this system. Please upgrade your curl to atleast 7.34.0.<br /> - Current Curl Version: " . $curl_info['version'] . "<br /> - Current OpenSSL Version:" . $curl_info['ssl_version'], "Payment", null, $request, $ex);
exit(1);
}
// NOTE: PLEASE DO NOT USE RESULTPRINTER CLASS IN YOUR ORIGINAL CODE. FOR SAMPLE ONLY
ResultPrinter::printResult("<b>SUCCESS</b>: Your server supports TLS protocols required for secure connection to PayPal Servers. <br /> - Current Curl Version: " . $curl_info['version'] . "<br /> - Current OpenSSL Version:" . $curl_info['ssl_version'], null, null, null, "SUCCESS. Your system supports TLSv1.2");
return $payment;