无法验证Adyen的SSL证书。 Adyen Payments

时间:2017-05-03 15:49:50

标签: php ssl curl

当我在本地提出创建付款请求时,我收到以下错误。我正在使用以下api进行付款。 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

以下是我用于创建付款的代码

<?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> 

任何人都可以让我知道我如何解决这个问题或者我错过了什么?我想,这是在php.ini文件中配置php的东西吗?

1 个答案:

答案 0 :(得分:0)

我可以通过关注帖子中的解决方案来修复它。

HTTPS and SSL3_GET_SERVER_CERTIFICATE:certificate verify failed, CA is OK

这是Windows中一个非常常见的问题。你只需要将cacert.pem设置为curl.cainfo。

从PHP 5.3.7开始,你可以这样做:

下载https://curl.haxx.se/ca/cacert.pem并将其保存在某处。 更新php.ini - 添加curl.cainfo =&#34; PATH_TO / cacert.pem&#34; 否则,您需要为每个cURL资源执行以下操作:

curl_setopt($ ch,CURLOPT_CAINFO,&#34; PATH_TO / cacert.pem&#34;);