Change Invoice Status to PAID from outside using API 3.0

Hi,

I'm trying to change the status of my invoice using the API 3.0 from outside after a successful payment made by an external payment gateway. I just need the Token Authorization as it will be made internally. Here is an extract of my code:

$orderRef = $_GET['booking_id'];
$ch = curl_init();
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($curl, CURLOPT_USERPWD, "username:pwd");
curl_setopt($ch, CURLOPT_URL,'https://xxxx.checkfront.com/api/3.0/booking/'.$orderRef.'/update');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,
            "status_id=PAID");
// receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);

Unfortunately I got in response:

{"version":"3.0","account_id":0,"host_id":"xxxx.checkfront.com","name":"xxxxxx","locale":{"id":"en_US","lang":"en","currency":"xxx"},"request":{"status":"ERROR","resource":null,"records":0,"error":{"id":"access_denied","title":"Invalid permissions","details":"You do not have access to this resource.","data":""},"limit":0,"page":1,"pages":1,"time":0.0007,"timestamp":1521687857.071791,"method":"post"}}.

Is there any restriction to change the status of a existing invoice using the Token Authorization ?

Thank you for your help

Comments

  • Hi OnWheels,

    Thank you for using our forums!

    Can you please confirm that for this line:

    curl_setopt($curl, CURLOPT_USERPWD, "username:pwd");

    username = your API key
    pwd = your API secret

    Right now, it looks like this is using a string when those should be variables pointing to the appropriate values. You can find your API key and secret by going to Manage > Developer > API > select your application.

    If you are already sending the API key and secret, please let me know and I can continue to look into this.

    All the best,
    Chase - Checkfront Support Team
Sign In or Register to comment.