Jump to content

Changeing billing contact for an account throug external api


Aita

Recommended Posts

Hi

 

Is there a way to add / change a billing contact for a client through the external api calls.

 

I have not found any documentation in addclient or updateclient api calls where one can specify billing contact id

Link to comment
Share on other sites

  • 4 years later...
8 hours ago, steph.hope said:

Same question here. Needing to import a lot of clients and at least a hundred need billing contact set, is there really no way to do it by API?

I would have thought the AddContact API would be an option here...

of course, you might have to work out whether these contacts need to be users, contacts or both - and that depends on what they need to do, e.g whether they need to login, or just receive relevant emails.

Link to comment
Share on other sites

13 hours ago, steph.hope said:

From what understand I can add the contact just fine using that API, but I'm not able to set it as the billing contact.

a billing contact in the sense that they receive invoice emails ? I think you should just need to use the email_preferences[invoice] boolean option in the API, e.g set it to true.

the complicating factor for you in this is that the management of these "people" will be split between their "user" settings and their "contact" settings.

I know in v7, the email settings and permissions of contacts is all on the same page in the admin area; in v8, they're not... email settings under contacts, permissions under users - hence why these people may have to be both contacts and users.

Link to comment
Share on other sites

Nah, we have to have the actual 'billing contact' selected on the client so that the invoices are addressed to that contact and listed against them in our accounting software. I've resigned myself to the fact I'll have to either do it manually for these clients or do something with the database. Thanks for your advice though 🙂

Link to comment
Share on other sites

  • 3 weeks later...

So I'd believed WHMCS when they said "...in fact this will not work with our API Credential Roles functionality. If you want to implement a URL that can run custom code, I would recommend using an addon module with the admin area output or client area output functionality".

Turns out this isn't true and the extremely roundabout way I'd built a messy solution using an Addon Module was unnecessary. All that was required was manually adding a permission to tblapi_roles to allow access to the custom file.

(Thanks to the below post for the hint)

 

In case it's of use to anyone else - Please test it before using, I make no claims about its correctness:

Request Parameters "SetBillingContact"

Parameter Type Description Required
action string       “SetBillingContact” Required
clientid int   Optional
contactid int   Optional
       

Response Parameters

Parameter Type Description
result string     The result of the operation: success or error
<?php
if (!defined("WHMCS")) {
    exit("This file cannot be accessed directly");
}

$clientID = $whmcs->get_req_var("clientid");
$contactID = $whmcs->get_req_var("contactid");

if ($clientID == "" || $contactID == ""){
    $apiresults = array("result" => "error", "message" => "Missing required variable");
} else {
    try {
        $client = WHMCS\User\Client::findorfail($clientID);
        $client->billingcid = $contactID;
        $client->save();
        $apiresults = array('result' => 'success');
    } catch (Exception $e) {
        $apiresults = array("result" => "error", "message" => "Client not found");
        return NULL;
    }
}

?>

 

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated