使用 PHP / CURL 的 Neteller TransferOut
Neteller TransferOut with PHP / CURL
我在使用 Neteller API 将钱从我们的商家帐户转账给用户时遇到了一些问题。我已经成功收到 accessToken,但是当我尝试使用 transferOut 时,我只是得到了无效的凭据?我使用的代码是:
$headers = array(
"Content-type" => "application/json",
"Authorization" => "Bearer " . $accessToken
);
//build the request body structure
$requestParams = array(
"payeeProfile" => array(
"email" => $the_email_address_to_send_to
),
"transaction" => array(
"merchantRefId" => $transaction_id,
"amount" => $amount,
"currency" => $currencyCode
)
);
// encode the requestParams to a string
$requestParams = json_encode($requestParams);
// The curl stuff
$curl = curl_init();
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_URL, "https://api.neteller.com/v1/transferOut");
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POSTFIELDS, $requestParams);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
// Ok lets send this lovely looking curl over
$serverOutput = json_decode(curl_exec($curl));
显然,所有变量($transaction_id、$amount、$currency)都已正确设置。但是我得到的回复是:
stdClass Object
(
[error] => stdClass Object
(
[code] => 5279
[message] => Authentication credentials are invalid
)
)
我很困惑,accessToken 肯定是我需要的凭据,而且已经收到了。我是否打算在 transferOut curl postfields 中包含任何其他内容?
提前致谢
根据:
$headers
does not look OK - try $headers = array("Content-type: application/json", "Authorization: Bearer " . $accessToken);
. At least this is the format according to http://php.net/manual/en/function.curl-setopt.php
注意,商户参考号也需要有一定的长度。不确定 - 找不到参考,但 8 个字符不够长。
我在使用 Neteller API 将钱从我们的商家帐户转账给用户时遇到了一些问题。我已经成功收到 accessToken,但是当我尝试使用 transferOut 时,我只是得到了无效的凭据?我使用的代码是:
$headers = array(
"Content-type" => "application/json",
"Authorization" => "Bearer " . $accessToken
);
//build the request body structure
$requestParams = array(
"payeeProfile" => array(
"email" => $the_email_address_to_send_to
),
"transaction" => array(
"merchantRefId" => $transaction_id,
"amount" => $amount,
"currency" => $currencyCode
)
);
// encode the requestParams to a string
$requestParams = json_encode($requestParams);
// The curl stuff
$curl = curl_init();
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_URL, "https://api.neteller.com/v1/transferOut");
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POSTFIELDS, $requestParams);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
// Ok lets send this lovely looking curl over
$serverOutput = json_decode(curl_exec($curl));
显然,所有变量($transaction_id、$amount、$currency)都已正确设置。但是我得到的回复是:
stdClass Object
(
[error] => stdClass Object
(
[code] => 5279
[message] => Authentication credentials are invalid
)
)
我很困惑,accessToken 肯定是我需要的凭据,而且已经收到了。我是否打算在 transferOut curl postfields 中包含任何其他内容?
提前致谢
根据
$headers
does not look OK - try$headers = array("Content-type: application/json", "Authorization: Bearer " . $accessToken);
. At least this is the format according to http://php.net/manual/en/function.curl-setopt.php
注意,商户参考号也需要有一定的长度。不确定 - 找不到参考,但 8 个字符不够长。