php - 使用 PHP/CURL 的 Neteller TransferOut

标签 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 中包含任何其他内容?

提前致谢

最佳答案

根据 user3584460's comment :

$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

注意,Merchant Ref ID 也需要有一定的长度。不确定 - 找不到引用,但 8 个字符不够长。

关于php - 使用 PHP/CURL 的 Neteller TransferOut,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32010775/

相关文章:

javascript - HTML 不想被执行

php - 我需要将多维 PHP 数组的特定元素与同一数组中的某些其他元素进行比较

javascript - 通过 Stripe 向用户收费并将资金存入另一个用户帐户

ios - Stripe : 502 (Bad Gateway)

ios - iOS 中使用 MPL 的 Paypal 登录 session

php - 如何从 mysql 数据库的行中插入多个图像?

php - 组织这些表+行的最有效方法是什么? - MySQL

PHP curl 头

php - Python 将数据 POST 到 Linux 上的本地 PHP

PHP - 如何获得 SSL key 长度