Developer Center

EN

Fixed Functions and Return

The function names which are mandatory in the module class are: create, terminate, suspend, unsuspend

All of these 4 functions run similarly, they can run both manually and automatically, each of which must return a success or error response.

Response Usage

All other functions except "create" function must return response in boolean data type.

If the function fails, the error message you specify must be a message that can be understood by user.

You should assign the error message to $this->error variable in the class.

"create" Response Example

The return value from the function must be an array. Received value is saved to users_products.options field in the database of service.

public function create($domain = '',array $order_options=[])
{
$username = $this->UsernameGenerator($domain);
$password = Utility::generate_hash(12);


if(isset($order_options["username"])) $username = $order_options["username"];
if(isset($order_options["password"])) $password = $order_options["password"];

$username = str_replace("-","",$username);
$creation_info = isset($order_options["creation_info"]) ? $order_options["creation_info"] : [];
$disk_limit = isset($order_options["disk_limit"]) ? $order_options["disk_limit"] : '';



try
{
/*
* $order_options or $this->order["options"]
* for parameters: https://docs.wisecp.com/en/kb/hosting-panel-module-development-parameters
* Here are the codes to be sent to the API...
*/
$result = "OK|101"; /* $this->api->create();*/
}
catch (Exception $e){
$this->error = $e->getMessage();
self::save_log(
'Servers',
$this->_name,
__FUNCTION__,
['order' => $this->order],
$e->getMessage(),
$e->getTraceAsString()
);
return false;
}

/*
* Error Result:
* $result = "Failed to create server, something went wrong.";
*/
if(substr($result,0,2) == 'OK')
{
$host = $this->server["ip"];
if(Validation::NSCheck($this->server["name"])) $host = $this->server["name"];

return [
'username' => $username,
'password' => $password,
'ftp_info' => [
'ip' => $this->server["ip"],
'host' => $host,
'username' => $username,
'password' => $password,
'port' => 21,
],
];
}
else
{
$this->error = $result;
return false;
}
}
Supported Functions Single Sign-On

Do you have any questions?

Feel free to contact us
Contact Us
Copyright © 2020. All rights reserved.
Join Our Discord Channel
Top