Jump to content

Provision Module: Doubts on how to write a new module


progere

Recommended Posts

Hello, I'm trying to write my own provision module for a service I have, but I have doubts about how do I "talk" to whmcs...

 

For example, I have the following working code:

 

function template_ChangePassword($params) {

   # Code to perform action goes here...
   $instance = $username; # PS: check var to use in this, username does not seem right
   $directory = dirname(__FILE__);
   ob_start();
   passthru('/usr/bin/env python3 '.$directory.'/mailcloud.py unsuspendinstance '.$instance);
   $resultData = json_decode(ob_get_clean(), true);
   if ($resultData['status'] == "ok") {
       $successful = 1;
   }
   if ($successful) {
       $result = "success";
   } else {
       $result = $resultData['ERROR'];
   }
   return $result;

}

 

How do I make WHMCS retrieve my password and update its DB? Do i use internal API?

 

Like this?:

 

function template_ChangePassword($params) {

   # Code to perform action goes here...
   $instance = $username; # PS: check var to use in this, username does not seem right
   $directory = dirname(__FILE__);
   ob_start();
   passthru('/usr/bin/env python3 '.$directory.'/mailcloud.py unsuspendinstance '.$instance);
   $resultData = json_decode(ob_get_clean(), true);
   if ($resultData['status'] == "ok") {
       # WHMCS Internal API
       $command = "modulechangepw";
       $adminuser = "admin";
       $values["serviceid"] = $serviceid;
       $values["servicepassword"] = $resultData['password'];
       # Execute command 
       $result = localAPI($command,$values,$adminuser);
   }
}

 

I'm using ModuleDevKit and read the Provisioning_Module_Developer_Docs, but I think if there were some module examples it would be easier to understand how it works...

 

Thanks in advance.

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