Php 在使用cURL的SecureNet响应代码上感到困惑
我已经在谷歌和StackOverflow上搜索了这个错误,但我在搜索结果时遇到了麻烦。也许有人可以为我指明正确的方向,因为我以前从未使用过SecureNet API 我在PHP中有一个工作表单,但是当我将其提交给时,我得到了响应:Php 在使用cURL的SecureNet响应代码上感到困惑,php,curl,payment-gateway,Php,Curl,Payment Gateway,我已经在谷歌和StackOverflow上搜索了这个错误,但我在搜索结果时遇到了麻烦。也许有人可以为我指明正确的方向,因为我以前从未使用过SecureNet API 我在PHP中有一个工作表单,但是当我将其提交给时,我得到了响应: {"success":false,"result":"AUTHENTICATION_ERROR","responseCode":3,"message":"SecureNetId and SecureNetKey should be passed as Basic au
{"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);
我知道了,我没有发送标题
$headers = array(
"Authorization: Basic " . base64_encode($apidID . ':' . $apiSkey)
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);