Neteller TransferOut与PHP / CURL

时间:2015-08-14 13:01:26

标签: php curl payment

我在使用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中包含任何其他内容?

提前致谢

1 个答案:

答案 0 :(得分:4)

根据user3584460's comment

  

$headers看起来不正常 - 请尝试$headers = array("Content-type: application/json", "Authorization: Bearer " . $accessToken);。至少这是根据http://php.net/manual/en/function.curl-setopt.php

的格式

请注意,商家参考ID也需要一定的长度。不确定什么 - 找不到参考,但8个字符不够长。