lolgc1 Posted August 4, 2018 Report Posted August 4, 2018 Hi. I tried to add a invoice for a service but no success. Ive tried for like 1 hour now and cant get a solution. $client_id = 15; $service_id = 181; $today = date("Y-m-d"); $response = $api->get("invoices", "add", array('vars' => array('client_id' => $client_id, 'date_billed' => $today, 'date_due' => $today, 'date_closed' => $today, 'date_autodebit' => $today, 'status' => 'active', 'currency' => '208', 'note_public' => 'Public note', 'note_private' => 'Privat note', array($service_id,'Desc', 1,1,0), 'period' => 'month', 'duration' => 'indefinitely', 'duration_time' => '1', 'recur_date_billed' => $today, 1))); Does anyone know why it doesnt work? Quote
WebhostingNZ.com Posted August 5, 2018 Report Posted August 5, 2018 Hey @lolgc1 I don't know why but I haven't looked into it either, you've posted on Sunday I'm sure you'll get a reply tomorrow/Monday Quote
Tyson Posted August 6, 2018 Report Posted August 6, 2018 On 8/4/2018 at 5:26 AM, lolgc1 said: Hi. I tried to add a invoice for a service but no success. Ive tried for like 1 hour now and cant get a solution. $client_id = 15; $service_id = 181; $today = date("Y-m-d"); $response = $api->get("invoices", "add", array('vars' => array('client_id' => $client_id, 'date_billed' => $today, 'date_due' => $today, 'date_closed' => $today, 'date_autodebit' => $today, 'status' => 'active', 'currency' => '208', 'note_public' => 'Public note', 'note_private' => 'Privat note', array($service_id,'Desc', 1,1,0), 'period' => 'month', 'duration' => 'indefinitely', 'duration_time' => '1', 'recur_date_billed' => $today, 1))); Does anyone know why it doesnt work? When the API doesn't work the way you expect, you should look at the errors you enconter, e.g.: print_r($response->errors()); See the docs for an example. From looking at your request, you are making a couple mistakes: You're using the "GET" HTTP verb to add something. "GET" [i.e. $api->get(..)] should only be used for retrieving information, not setting information. Use "POST" [i.e. $api->post(...)] You're not passing valid key => value pairs for all values expected by Invoices::add You have "array($service_id,'Desc', 1,1,0)". Is that supposed to be the line items? Why aren't they in key => value format? You have "...'recur_date_billed' => $today, 1)));". What is that extraneous 1 at the end of the list that is not in key => value format? It'll be easier to figure out and avoid issues if you format your source code better: $response = $api->get( "invoices", "add", array( 'vars' => array( 'client_id' => $client_id, 'date_billed' => $today, 'date_due' => $today, 'date_closed' => $today, 'date_autodebit' => $today, 'status' => 'active', 'currency' => '208', 'note_public' => 'Public note', 'note_private' => 'Privat note', array($service_id,'Desc', 1,1,0), 'period' => 'month', 'duration' => 'indefinitely', 'duration_time' => '1', 'recur_date_billed' => $today, 1 ) ) ); activa and Blesta Addons 2 Quote
lolgc1 Posted August 16, 2018 Author Report Posted August 16, 2018 Hi. Thanks for the answer. Sorry for a late reply, havent been online. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.