【问题标题】:Confused on a SecureNet response code using cURL对使用 cURL 的 SecureNet 响应代码感到困惑
【发布时间】:2015-11-21 06:50:37
【问题描述】:

我已在 Google 和 StackOverflow 上搜索过有关此错误的信息,但无法找到结果。也许有人可以为我指明正确的方向,因为我以前从未使用过 SecureNet API

我在 PHP 中有一个工作表单,但是在将其提交给 SecureNet 时,我得到了一个响应:: p>

{"success":false,"result":"AUTHENTICATION_ERROR","responseCode":3,"message":"SecureNetId and SecureNetKey should be passed as Basic authentication tokens or in request object.","responseDateTime":"2015-08-27T02:58:12.54Z","rawRequest":null,"rawResponse":null,"jsonRequest":null}bool(true)

这是我的代码:

    $url = 'https://gwapi.demo.securenet.com/api/Payments/Charge';
$data = array(
    "publickey" => $apiPkey,
    "amount" => $donationAmount,
    "card" => array(
        "number" => $cardNumber,
        "cvv" => $cvv,
        "expirationDate" => $expiryMonth . '/' . $expiryYear,
        "address" => array(
            "line1" => $address,
            "city" => $city,
            "state" => $state,
            "zip" => $zip
        ),
        "firstName" => "Jack",
        "lastName" => "Test"
    ),
    "extendedInformation" => array(
        "typeOfGoods" => "DIGITAL"
    ),
    "developerApplication" => array(
        "developerId" => $apiID,
        "version" => $apiVersion
    )
);

$secureNet = http_build_query($data);

//open connection
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $secureNet);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$result = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Curl error: ' . curl_error($ch);
}

var_dump($result);

curl_close($ch);

【问题讨论】:

    标签: php curl payment-gateway


    【解决方案1】:

    我想通了,我没有发送标题。

        $headers = array(
            "Authorization: Basic " . base64_encode($apidID . ':' . $apiSkey)
        );
    
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    

    【讨论】:

      猜你喜欢
      • 2015-07-12
      • 2012-10-05
      • 2010-10-28
      • 1970-01-01
      • 1970-01-01
      • 2016-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多