Developer Center

Fixed Functions and Return

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

All of these 5 functions run in a similar way, 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($order_options=[])
{
    try
    {
        /*
         * $order_options or $this->order["options"]
        * for parameters: https://docs.wisecp.com/en/kb/product-module-development-parameters
        * Here are the codes to be sent to the API...
        */
        $result = "OK";
    }
    catch (Exception $e){
        $this->error = $e->getMessage();
        self::save_log(
            'Product',
            $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')
        return true; /* boolean or array [ 'config' => [...],'creation_info' => [...],]  */
    else
    {
        $this->error = $result;
        return false;
    }
}
Supported Functions Defining Custom Pages and Functions for Client Area

Do you have any questions?

Feel free to contact us
Contact Us
Copyright © 2024. All Rights Reserved.
Join Our Discord Channel
Top