【问题标题】:Neteller TransferOut with PHP / CURL使用 PHP / CURL 的 Neteller TransferOut
【发布时间】:2015-11-07 18:02:40
【问题描述】:

我在使用 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 看起来不太好 - 试试 $headers = array("Content-type: application/json", "Authorization: Bearer " . $accessToken);。至少这是根据php.net/manual/en/function.curl-setopt.php的格式
  • 是的,就是这样-简单。谢谢!

标签: php curl payment


【解决方案1】:

根据user3584460's comment

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

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

【讨论】:

    猜你喜欢
    • 2017-11-13
    • 2013-09-24
    • 1970-01-01
    • 1970-01-01
    • 2023-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多