Software: Apache. PHP/8.1.30 uname -a: Linux server1.tuhinhossain.com 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root) Safe-mode: OFF (not secure) /home/picotech/domains/sms.picotech.app/public_html/vendor/paypal/rest-api-sdk-php/sample/doc/tls/ drwxr-xr-x |
Viewing file: Select action/file-type: tls/TlsCheck.php <?php require __DIR__ . '/../bootstrap.php';
use PayPal\Api\Amount;
use PayPal\Api\Details;
use PayPal\Api\Item;
use PayPal\Api\ItemList;
use PayPal\Api\Payer;
use PayPal\Api\Payment;
use PayPal\Api\RedirectUrls;
use PayPal\Api\Transaction; TLS CheckWe 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.
$apiContext->setConfig(array('service.EndPoint'=>"https://test-api.sandbox.paypal.com"));
Create a Payment for testingWe 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/openssl to enable TLSv1.2. <br /> - Your Current SSL Version is : " . $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 /> - Your Current SSL Version is : " . $curl_info['ssl_version'], null, null, null, "SUCCESS. Your system supports TLSv1.2");
return $payment; |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0047 ]-- |
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