How to update customer Billing info


#1

No matter what I seem to get Result Fail! Error code 403
However I have given my API key access to absolutely everything
Currently running Dev version 1.3

$BillingApiUrl = “admin/customers/customer-billing/$CustomerId”;

print “Update Billing\n”;
$result = $api->api_call_post($BillingApiUrl,
array(
‘make_invoices’ => ‘1’,
‘customer_id’ => $CustomerId,
‘grace_period’ => ‘28’,
‘billing_date’ => substr($date, 8, -9),
// ‘payment_method’ => ‘STRIPE’,
‘billing_due’ => substr($date, 8, -9),
// ‘auto_pay_invoices_from_deposit’ => ‘yes’,

));

print "Result: ";
if ($result) {
print “Ok!\n”;
print_r($api->response);
$BillingUpdateId = $api->response[‘id’];
} else {
print “Fail! Error code: $api->response_code\n”;
print_r($api->response);
$BillingUpdateId = false;

}
print “\n-------------------------------------------------\n”;


#2

may be you should use PUT to update ?

POST for create …


#3

With api_call_put I seem to get error 500 instead of 403

And further to this it looks like the Apiary says to use POST?
http://docs.splynx.apiary.io/#reference/customers/customers-billing/update-billing


#4

Of course you will have error 500:

 Update Billing
 PHP Warning:  Missing argument 3 for SplynxApi::api_call_put(), called in /tmp/update_builing_info.php on line 28 and defined in /tmp/SplynxApi.php on line 244
 PHP Notice:  Array to string conversion in /tmp/SplynxApi.php on line 195
 PHP Notice:  Undefined variable: params in /tmp/SplynxApi.php on line 246
 Result: Fail! Error code: 500

method “put” use 3 argument, so you should use it like:

$BillingApiUrl = "admin/customers/customer-billing";

$result = $api->api_call_put($BillingApiUrl, '2',  array( .....));

#6

Ahhh Thank you
I have it working now


#7

API updated