【问题标题】:Invalid SSL option using the Authorize.NET PHP SDK使用 Authorize.NET PHP SDK 的 SSL 选项无效
【发布时间】:2018-03-29 17:10:56
【问题描述】:

我正在尝试使用 Authorize.NET 的 PHP SDK 对卡进行收费。但它一直给我这个错误:

 Thu, 29 Mar 2018 17:00:56 +0000 ERROR : [_sendRequest] (/lib/shared/AuthorizeNetRequest.php : 100) - ----Request---- Invalid SSL option

它以前工作过,但现在它一直给我一个错误,我研究过这个但没有找到答案,我在我的代码中尝试过这个:

$sale->VERIFY_PEER = false;

我还更新了我的 cert.pem 文件,但它仍然给我一个错误。

PHP 代码:

<?php
require 'vendor/autoload.php';
use lib\net\authorize\api\contract\v1 as AnetAPI;
use lib\net\authorize\api\controller as AnetController;


define("AUTHORIZENET_LOG_FILE", "phplog");
$usermeta = get_user_meta(get_current_user_id(), '_carddetails_', TRUE);
define("AUTHORIZENET_API_LOGIN_ID", "[LOGIN_ID]");
define("AUTHORIZENET_TRANSACTION_KEY", "[TRANSACTION_KEY]");
define("AUTHORIZENET_SANDBOX", true);
$sale = new AuthorizeNetAIM(AUTHORIZENET_API_LOGIN_ID, AUTHORIZENET_TRANSACTION_KEY);
$sale->VERIFY_PEER = false;
$sale->amount   = $_POST['grandTotal'];
$sale->card_num = $usermeta['number'];
$sale->exp_date = $usermeta['expdate'];
$sale->addLineItem('item1', // Item Id
    'Order 1', // Item Name
    'Order 1', // Item Description
    '1', // Item Quantity
    $_POST['grandTotal'], // Item Unit Price
    'N' // Item taxable
);
$customer              = (object) array();
$customer->first_name  = $usermeta['firstname'];
$customer->last_name   = $usermeta['lastname'];
$customer->company     = $usermeta['company'];
$customer->address     = $usermeta['address'];
$customer->city        = $usermeta['city'];
$customer->state       = $usermeta['state'];
$customer->zip         = $usermeta['zip'];
$customer->country     = $usermeta['country'];
$customer->cust_id     = 9999;
$customer->customer_ip = $_SERVER['REMOTE_ADDR'];
$sale->setFields($customer);

$response      = $sale->authorizeAndCapture();
$responseCode  = $response->response_code;
$authCode      = $response->authorization_code;
$avsResultCode = $response->avs_response;
$transId       = $response->transaction_id;
$transHash     = $response->md5_hash;
$accountNumber = $response->account_number;
$accountType   = $response->card_type;
$description   = $response->description;
if ($response->approved)
{
   echo "iT worked";
}
else
{
    echo $response->error_message;

}

?>

【问题讨论】:

    标签: php ssl authorize.net


    【解决方案1】:

    您应该从https://github.com/AuthorizeNet/sdk-php/tree/master/lib/ssl 获取最新证书。它最后一次更新是在 5 天前写这篇文章时包含新的授权证书。

    禁用或更改默认对等和证书验证可能很危险。

    【讨论】:

    • 我已经这样做了,但是它没有用,我已经解决了我的问题,请看我的回答!
    【解决方案2】:

    我想通了。

    我注释掉了:

    $sale->VERIFY_PEER = false;
    

    并注释了 HttpClient.php 的第 80 行

    我在这里找到了答案:https://github.com/AuthorizeNet/sdk-php/issues/223

    【讨论】:

      猜你喜欢
      • 2013-06-07
      • 2011-01-23
      • 1970-01-01
      • 2013-04-19
      • 2018-03-04
      • 1970-01-01
      • 1970-01-01
      • 2018-07-02
      • 2014-07-23
      相关资源
      最近更新 更多