Dynameyes
Dynameyes

Reputation: 495

NETELLER TransferIn: Authentication credentials are invalid

I'm having a problem in integrating the Neteller API to transfer money from a user account to our merchant account. I've succcessfully received the accessToken (using auth_code grant type), however when I try using transferIn I am getting the error Authentication credentials are invalid.

Here is my code:

//getting the accessToken from NETELLER's response
$accessToken = $_POST['accessToken'];

$service_url = "https://test.api.neteller.com/v1/transferIn";
$curl = curl_init($service_url);

$curl_post_data = array(
    "paymentMethod" => array(
        "type" => "neteller",
        "value" => "[email protected]"
    ),
    "transaction" => array(
        "merchantRefId" => (string)date('YmdHis'),
        "amount" => 25,
        "currency" => "USD"
    ),
    "verificationCode" => "234124"
);

$jsonDataEncoded = json_encode($curl_post_data);
curl_setopt($curl, CURLOPT_POSTFIELDS, $jsonDataEncoded);

$headers = array(
     "Content-type: application/json",
     "Authorization: Bearer " . $accessToken
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);

$curl_response = curl_exec($curl);

curl_close($curl);

However, I am getting this error:

{ "error":{ "code": "5279", "message": "Authentication credentials are invalid" } }

Am I missing anything in the transferIn curl postfields?

Thanks!

Upvotes: 0

Views: 1090

Answers (1)

SimeonUzunov
SimeonUzunov

Reputation: 209

You shouldn't be using the auth_code grant type, the correct one is client_credentials. This is explained in detail on page 41 of the latest REST API guide, which you can download from your merchant account >> "Developer" tab >> "Documentation" page.

Just to clarify - the auth_code flow obtains authorization from the user (for ex. for subscription payments, additional account profile information, etc). Although it will work for payments too, it will add 2 more steps to the flow and can be a conversion killer.

Additionally, I found some issues in your code, which you should also address:

  1. The amount you are trying to deposit is too small -- you need to convert the transaction amount to the smallest currency unit before sending it to the API. For example - you want to request a deposit for $5, the smallest currency unit for USD is cents, which is 1/100 of a dollar, so you need to send $5 * 100 = 500 to the API. Important to note here is that the HUF, KRW and JPY currencies do not have subunits, so the amount needs to be sent to the API as is (no conversion needed).

  2. The verificationCode for the USD test account is 270955. This information is available on page 153 of the REST API guide.

Please try to implement the client_credentials grant type flow and post here if you encounter any issues, I will try to assist you. Alternatively, you can add me on Skype (it is in my profile information).

Upvotes: 1

Related Questions