Jump to content
  • 0

Custom server module help with customfields values database updating


RstsTeam

Question

```    } catch (Exception $e) {

        // Record the error in WHMCS's module log.

        logModuleCall(

            'vps',

            __FUNCTION__,

            $params,

            $e->getMessage(),

            $e->getTraceAsString()

        );

        return $e->getMessage();

    }

     

    return 'success';

}
/*  testing code

    $data = array(

    'error' => 'Custom error testing',
    'success' => 'success', 
    'data' => $data
    );
    return $data;
}
*/
/*  use WHMCS\Database\Capsule;
``` It's Lavarel framework https://developers.whmcs.com/advanced/db-interaction/
//This is example custom filed that i have on //product

$vpsusername = $customfields['VPS Username'];

/*
Now I can enter and save VPS Username field in WHMCS client product admin area but I would like to automatically generate service username and password and update customfield value in database. By looking into database I found how is value of customfield saved.

*/

SELECT * FROM `tblcustomfieldsvalues` ORDER BY `tblcustomfieldsvalues`.`updated_at` DESC   relid 216

Hello,

I'm building custom server module for automatic vps setup based on client order. 

Main part is finished when order is accepted server building is started and everything is working great. Now I want to extend and improve module with new functions.

 

1. On module _Create i would like to update automatically generated service username and password and update that generated values to customfield values in database. 

How to do that and if it's even possible?

 

2.  I have an issue where I can't get custom return in latest WHMCS update. Earlier you could return success or custom message. Now custom message is not accepted for some reason only success or error is . Question is how to get custom errors or custom return messages back from remote script. Only success is accepted as whmcs solution or I'm missing something.

 

Thank you in advance 

 

 

 

 

 

 

 

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Okay so i managed to solve issue number 1.

Now i have remaining issue when i return anything it's always sucess and when i return $data WHMCS just won't show anything but it's still passed as success

```    } catch (Exception $e) {

        // Record the error in WHMCS's module log.

        logModuleCall(

            'vps',

            __FUNCTION__,

            $params,

            $e->getMessage(),

            $e->getTraceAsString()

        );

        return $e->getMessage();

    }

     

    return 'success';

}
/*  testing code

    $data = array(

    'error' => 'Custom error testing',
    'success' => 'success', 
    'data' => $data
    );
    return $data;
}
*/

 

Link to comment
Share on other sites

  • 0

You can't return anything but 'success'  or the error. This is described in the sample module's comments:
 

/**
 * Provision a new instance of a product/service.
 *
 * Attempt to provision a new instance of a given product/service. This is
 * called any time provisioning is requested inside of WHMCS. Depending upon the
 * configuration, this can be any of:
 * * When a new order is placed
 * * When an invoice for a new order is paid
 * * Upon manual request by an admin user
 *
 * @param array $params common module parameters
 *
 * @see https://developers.whmcs.com/provisioning-modules/module-parameters/
 *
 * @return string "success" or an error message
 */

If you need to save specific data, you can pass them to the service's properties: https://developers.whmcs.com/provisioning-modules/service-properties/

Link to comment
Share on other sites

  • 0
Just now, DennisHermannsen said:

You can't return anything but 'success'  or the error. This is described in the sample module's comments:
 


/**
 * Provision a new instance of a product/service.
 *
 * Attempt to provision a new instance of a given product/service. This is
 * called any time provisioning is requested inside of WHMCS. Depending upon the
 * configuration, this can be any of:
 * * When a new order is placed
 * * When an invoice for a new order is paid
 * * Upon manual request by an admin user
 *
 * @param array $params common module parameters
 *
 * @see https://developers.whmcs.com/provisioning-modules/module-parameters/
 *
 * @return string "success" or an error message
 */

If you need to save specific data, you can pass them to the service's properties: https://developers.whmcs.com/provisioning-modules/service-properties/

 

Thank you, i managed to find my issue. It was connection timeout that was killing return of  'success' or 'error' 

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
Answer this question...

×   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.

×
×
  • 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