Receiving 401 Authentication Access error when trying to request Hosted Payment Field access token via PHP. I have followed this tutorial -> Easy start with BlueSnap hosted payment fields; read about these similar issues -> 1. BlueSnap integration with node js and angular 2. Error getting payment_field_token in Bluesnap API as well as read through the basic auth info http://developers.bluesnap.com/docs/authentication with no luck. Can anyone figure this out?
<?php
$TokenRequest=curl_init();
curl_setopt($TokenRequest, CURLOPT_URL, "https://sandbox.bluesnap.com/services/2/payment-fields-tokens");
curl_setopt($TokenRequest, CURLOPT_HEADER, 1);
curl_setopt($TokenRequest, CURLOPT_HTTPHEADER, array("Authorization: Basic CREDENTIALS_HERE", "Content-type: application/json"));
curl_setopt($TokenRequest, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($TokenRequest, CURLOPT_RETURNTRANSFER, true);
$TokenResponse=curl_exec($TokenRequest);
list($Headers, $Response)=explode("\r\n\r\n", $TokenResponse, 2);
$Headers=explode("\n", $Headers);
foreach($Headers as $Header)
{
if (stripos($Header, "Location")!==false)
{
$Token=trim(str_replace("Location: ", "", $Header));
}
}
?>