-1

I am getting the following error when i made request on my local to create payments. I am using following api for make payment. https://github.com/Adyen/adyen-php-api-library

Fatal error: Uncaught exception 'Adyen\AdyenException' with message 'Could not verify Adyen's SSL certificate. Please make sure that your network is not intercepting certificates. (Try going to https://pal-test.adyen.com/pal/servlet/Payment/v18/authorise in your browser.) If this problem persists, (Network error [errno 60]: SSL certificate problem: unable to get local issuer certificate)' in C:\xampp\htdocs\test\vendor\adyen\php-api-library\src\Adyen\HttpClient\CurlClient.php:210 Stack trace: #0 C:\xampp\htdocs\test\vendor\adyen\php-api-library\src\Adyen\HttpClient\CurlClient.php(74): Adyen\HttpClient\CurlClient->handleCurlError('https://pal-tes...', 60, 'SSL certificate...', Object(Monolog\Logger)) #1 C:\xampp\htdocs\test\vendor\adyen\php-api-library\src\Adyen\Service\AbstractResource.php(42): Adyen\HttpClient\CurlClient->requestJson(Object(Adyen\Service\Payment), 'https://pal-tes...', Array) #2 C:\xampp\htdocs\test\vendor\adyen\php-api-library\src\Adyen\Service\Payment.php(22): Adyen\Service\AbstractResource->request in C:\xampp\htdocs\test\vendor\adyen\php-api-library\src\Adyen\HttpClient\CurlClient.php on line 210

Here is the code which i am using to create payments

<?php error_reporting(E_ALL);
ini_set('display_errors', 1);
include 'vendor/autoload.php';
if(isset($_POST['adyen-encrypted-data']))
{
    echo 'test';
    $client = new \Adyen\Client();
    $client->setApplicationName("Adyen PHP Api Library Example");
    $client->setUsername("myusername");
    $client->setPassword("mypassword");
    $client->setEnvironment(\Adyen\Environment::TEST);

    $service = new Adyen\Service\Payment($client);

    $json = '{
              "amount": {
                "value": 1499,
                "currency": "GBP"
              },
              "reference": "payment-test",
              "merchantAccount": "mymerchantaccount",
              "additionalData": {
                "card.encrypted.json": "'.$_POST["adyen-encrypted-data"].'"
              }
            }';

    $params = json_decode($json, true);

    $result = $service->authorise($params);
    var_dump($result);
}
?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title></title>
    <link rel="stylesheet" href="">
</head>
<body>
<script type="text/javascript" src="https://test.adyen.com/hpp/cse/js/8214937568103526.shtml"></script>
    <form method="POST" action="pay.php" id="adyen-encrypted-form">
        <input type="text" size="20" data-encrypted-name="number"/>
        <input type="text" size="20" data-encrypted-name="holderName"/>
        <input type="text" size="2" data-encrypted-name="expiryMonth"/>
        <input type="text" size="4" data-encrypted-name="expiryYear"/>
        <input type="text" size="4" data-encrypted-name="cvc"/>
        <input type="hidden" value="<?php echo date('Y-m-d').'T'.date('H:i:s', time()).'000Z'; ?>"  data-encrypted-name="generationtime"/>
        <input type="submit" value="Pay"/>
    </form>
    <script>
    // The form element to encrypt.
    var form = document.getElementById('adyen-encrypted-form');
    // See https://github.com/Adyen/CSE-JS/blob/master/Options.md for details on the options to use.
    var options = {};
    // Bind encryption options to the form.
    adyen.createEncryptedForm(form, options);
    </script>
</body>
</html> 

can any one please let me know that how i fix this issue or i am missing something? I think, it is something related to configuration of php in php.ini file?

Abdul Rauf
  • 763
  • 2
  • 8
  • 28

1 Answers1

3

I am able to fix it by following the solution from the post.

HTTPS and SSL3_GET_SERVER_CERTIFICATE:certificate verify failed, CA is OK

It's a pretty common problem in Windows. You need just to set cacert.pem to curl.cainfo.

Since PHP 5.3.7 you could do:

download https://curl.haxx.se/ca/cacert.pem and save it somewhere. update php.ini -- add curl.cainfo = "PATH_TO/cacert.pem" Otherwise you will need to do the following for every cURL resource:

curl_setopt ($ch, CURLOPT_CAINFO, "PATH_TO/cacert.pem");

Community
  • 1
  • 1
Abdul Rauf
  • 763
  • 2
  • 8
  • 28