Stripe payment ssl protocol error WordPress

200 views Asked by At

We have used stripe payment using PHP. It works on the local machine but in live server, it's not worked as expected. We shared the code which we used and also attached the screenshot of the error. Not sure where we made the mistake, can you guide us?

Stripe Code :

require_once('Stripe.php');

Stripe::setApiKey('secret key');

echo '<form action="" method="post">
  <script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
          data-key="publish key"
          data-description="Access for a year"
          data-amount="5000"
          data-locale="auto"></script>
</form>';

if($_POST) {
 $token  = $_POST['stripeToken'];

  $customer = Stripe_Customer::create(array(
      'email' => '[email protected]',
      'source'  => $token
  ));

  $charge = Stripe_Charge::create(array(
      'customer' => $customer->id,
      'amount'   => 5000,
      'currency' => 'usd'
  ));

  echo '<h1>Successfully charged $50.00!</h1>';

}

Local Machine

Local Machine output result

Live Server

Live Server error report

1

There are 1 answers

0
duck On

1) It looks like potentially you haven't copied the data folder that comes with the stripe php bindings over to your server --- this contains the ca-certificates.crt file referenced in the failed loading cafile error. Make sure this folder is present on your server and see if that resolves the issue!

2) If you continue to have trouble the issue may involve an inability of your server to communicate over TLS 1.2 to Stripe. From your syntax it looks like you are using an older version of Stripe's PHP library so you'll want to use the second sample here to test that.

You can also run a test script like this to help determine your libcurl and openssl versions, if curl is able to make TLS 1.2 connections in the first place. If you need to upgrade curl and openssl some helpful advice is here. You can also chat with your sysadmin or web host on the matter.