PayPal TLS Classic ASP and PHP test script

I hope you all are aware of smoke testing performed by PayPal on their LIVE APIs. I also hope you all are shifted to TLS 1.2 and tested your integration on PayPal Sandbox. PayPal Sandbox is already upgraded to TLS 1.2 and if your integration is working fine here then you are safe.

Else you still have some time to migrate your code logic till June when PayPal will shift to LIVE on TLS 1.2. endpoint has been provided by PayPal to verify that your systems can support the latest security standards. This endpoint supports all of the security standards to which the PayPal endpoints are moving.
The following is Classic ASP code you can visit for other languages.

ASP.NET Script

 protected void Page_Load(object sender, EventArgs e)
        System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
        string responsestr;
        using (var response = WebRequest.Create("").GetResponse())
        using (var streamReader = new StreamReader(response.GetResponseStream()))
            responsestr = streamReader.ReadToEnd();

PHP Script

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "");
curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/cacert.pem');
// Some environments may be capable of TLS 1.2 but it is not in their list of defaults so need the SSL version option to be set.
curl_setopt($ch, CURLOPT_SSLVERSION, 6);
echo "\n";
if ($err = curl_error($ch)) {
    echo "DEBUG INFORMATION:\n###########\n";
    echo "CURL VERSION:\n";
    echo json_encode(curl_version(), JSON_PRETTY_PRINT);

Download cacert.pem from here

Classic ASP script

 strResponse =  Request.Form("encResp")
destURL = ""
Set http_obj = Server.CreateObject("WinHTTP.WinHTTPRequest.5.1") "POST", destURL , false
http_obj.setRequestHeader "Content-type", "application/x-www-form-urlencoded"
http_obj.option (9) = 2720    

decResponse = http_obj.ResponseText

response.Write decResponse

You might get following response

ERROR! Connection is using TLS version lesser than 1.2. Please use TLS1.2

On success: A successful connection to will return an HTTP 200 response with the following text in the body: “PayPal_Connection_OK”

On failure: One of the following errors will occur depending on what your system does not support:
HTTPS - will return an HTTP 400 response that contains this text: “ERROR!

Connection is not HTTPS. Please use”
 HTTP/1.1 - will return an HTTP 400 response that contains this text: “ERROR!

Connection is using HTTP/1.0 protocol. Please use HTTP/1.1”
 TLS 1.2 (SHA-256) - Your code will throw an SSL connection error.

Contact us for any question on this topic

Search for any Payment Gateway PayPal, CCAvenue, WorldPay, Technology Help

Click here to Contact for any Integration Help

Earn Rs 51 and Help a Needy and more on further referral (INDIA ONLY) I’m inviting you to join Tez, a simple and secure payments app by Google. Here’s my code UG0W9 - just enter it before your first transaction. Once you’ve sent your first payment, we’ll each get ₹51!