Category: WHMCS

6 Oct

WHMCS Addon Modules

WHMCS has a lot of features, that’s enough for running many firms. But still there will be custom features required bu each companies. WHMCS addon modules are useful for developing custom features in your WHMCS.

If you are going to develop an addon module named My Addon, then create a folder named
my_addon in the whmcs folder modules/addons.

Then inside the my_addon folder, you have to create a file named my_addon.php
also in the same folder you can create hook file with name hooks.php

For each addon module, you can use it to display some data in the admin area and also in the client area.

So in the admin area, there will be a page for each addon. That can be used to display some data,
You can display some forms to do CRUD etc. For the admin area features, in the file my_addon.php you have to define a function named my_addon_output($vars).

For each addon module, there will be a client area page too. The function used to display something on the client area page is my_addon_clientarea($vars)

An example addon module code can be found in WHMCS Addon Module Git Hub repository.

Contact Us For WHMCS Addon Modules

If you would like to get an addon module for your WHMCS, Please contact us by filling the below form.

15 Sep

WHMCS Modules

WHMCS modules are used to add custom features to your WHMCS.

There are different types of modules in WHMCS, and they are

1) WHMCS Addon module

2) WHMCS Gateway module

3) WHMCS Server module

4) WHMCS Registrar module

5) WHMCS Report module

WHMCS Addon Modules

WHMCS addon module can be used to do some specific feature and then just upload to a predefined folder in WHMCS.

WHMCS Addon module should be uploaded to the modules/addons folder of you WHMCS. Then you can activate or deactivate it from WHMCS admin area.

When the addon module is activate, the custom feature will be available, if you deactivate it the feature won’t be available.

WHMCS Gateway modules

WHMCS do have a number of payment gateways supported by default. But if you want to add a new payment gateway,

You can add that to your WHMCS. Please check the link https://github.com/WHMCS/sample-gateway-module

to see how we can create a gateway module in WHMCS

WHMCS Server Modules ( Provisioning Modules )

A WHMCS server module (also known as provisioning module) can be used to create some servicesby calling APIs based on some settings we do in the WHMCS admin area. There are setting like create the account when order is activated, or create the account when payment is received etc. By create an account, what we mean is assume that

we have a WHMCS product for selling some cloud servers. Then using the server module, you can call the API provided by the cloud server provider to create an account from WHMCS. It will be called from a function named createaccount in the server module. We can suspend, unsuspend and terminate the service using the same server module.

Please check the link https://github.com/WHMCS/sample-provisioning-module to get an idea on how to create the module.

WHMCS Domain Registrar Modules

WHMCS Domain registrar module can be used to register, transfer, renew domains. You have to used the API provided by the registrar in the module and then call them. You can see more details about a registrar module development from the link https://github.com/WHMCS/sample-registrar-module

 

Contact Us For WHMCS Modules

If you would like to get a module for your WHMCS,  Please contact us by filling the below form.

16 Jun

WHMCS Customisation

WHMCS customisation can be done to add custom features to the WHMCS based on your requirement.
Custom features can be added using WHMCS addons, hooks and by modifying templates etc. WHMCS Hooks are powerful to add almost any custom features in to your WHMCS.

WHMCS Addons

WHMCS addons or WHMCS addon modules are just like WordPress  plugins. You can create a module that do some specific feature and then just upload to a predefined folder in WHMCS.

WHMCS Addon module should be uploaded to the modules/addons folder of you WHMCS. Then you can activate or deactivate it from WHMCS admin area.

When the addon module is activate, the custom feature will be available, if you deactivate it the feature won’t be available.

Contact Us For WHMCS Customization

If you would like to customize your WHMCS,  Please contact us.
Click here and fill the form, and we will get back to you.

Benefits from customizing WHMCS

By default WHMCS comes with templates that might not be matching with your brand’s colors. So you can customize your WHMCS template and order forms to match with your brand colors and that will give customers a better impression.

Also you can customize WHMCS order flow using some hooks and addons and you can add cool features that will improve the conversion. For eg: you can create links for adding multiple products to cart when customer click on a link that you send via mail. Features like that can be done with the help of Hooks.

Challenges with WHMCS Customization

There are challenges for Customizing WHMCS. First of all, WHMCS code is encrypted and so customization is possible, but not everything can be done.

Second thing, if we add some customization code to order form templates or system templates, it might be overwritten when we upgrade WHMCS later, so we have to redo those customization after WHMCS updates. But there are tricks that can be used to avoid rewriting the entire customization to an extend.

1 Jan

paya for whmcs

formerly Sage Payments is now known as Paya. We have developed the paya payment gateway module for WHMCS. Those who are interested can contact us.

1 Jul

Stripe alipay module for WHMCS

Stripe payment API integration with WHMCS is easy to do. This article covered payment using stripe with alipay.

1) First let’s create a source using the below code

 $response = \Stripe\Source::create(array(
      "type" => "alipay",
      "currency" => "usd",
      "amount" => $params['amount'] * 100,
      "metadata" => array(  
          "invoiceid" => $invoiceid,
          "userid" => $params['clientdetails']['userid'],
          "order_id" => $invoiceid . "_" . date( "YmdHis" )
      ),
      "redirect" => array(
        "return_url" => $systemUrl . "/modules/gateways/callback/stripe_alipay.php?invoiceid=$invoiceid"
      ),
    ));

2)Then we need to make use of the hook feature of stripe.

Hooks we have to use are
surce.chargeable, charge.succeeded.

From surce.chargeable we have to create charge as

 $charge = \Stripe\Charge::create(array(
        "amount" => $amount,
        "currency" => "usd",
        "source" => $source_id,
    ));

And then from charge.succeeded, We have to add transaction details as shown below.

    $source_meta_data = $event_json->data->object->source;
    $source_id = $event_json->data->object->id;
    $amount = ($event_json->data->object->amount) / (100.00);
    $invoiceid = $source_meta_data->metadata->invoiceid;
    $order_id = $source_meta_data->metadata->order_id;
    $userid = $source_meta_data->metadata->userid;
    $invoiceid = checkCbInvoiceID($invoiceid, "stripe_alipay");
    addInvoicePayment($invoiceid, $source_id, $amount, 0, "stripe_alipay");
    logTransaction("stripe_alipay", json_decode($body, true), "Successful");

This is a high level idea of the gateway module development.
If you would like to develop a stripe module or need more info, please contact from the link
Contact Us.
We will get back to you asap.

7 May

Smarty for WHMCS

In MVC, we always use view to display html contents. If we are not using any template engine, then we have to use php tags in the html page to add dynamic contents.

For example, we can use below code to loop through an array without any template engine.

<?php foreach ($users as $user) : ?>
<div>
    <h2><?php echo $user['name']; ?></h2>
    <p><?php echo $user['company']; ?></p>
</div>
<?php endforeach; ?>

Here we are using php tags to loop through the array. Also we are using php function to print it. WHMCS uses Smarty template engine, and we have to do loop in a different manner with Smarty template engine.

{foreach from=$users item=user}
	<h2>{$user.name}</h2>
	<p>{$user.company}</p>
{/foreach}

This is just an example that shows the difference between Smarty and normal view files. For normal view files, we add .php as extension. But for Smarty files, by default .tpl is the extension of the view files.

Now let’s explore more smarty examples.
Let’s fist create a WHMCS page.

For any custom client area page, we have to add the below content at the top of the page.

<?php

//Let's include whmcs classes
use WHMCS\ClientArea;
use WHMCS\Database\Capsule;

define('CLIENTAREA', true);

require __DIR__ . '/init.php';

$ca = new ClientArea();
$ca->initPage();

Let’s name our custom page as custom_page.php and upload it to the root folder of whmcs.
Now , we have the content required for any client area page on custom_page.php.
Now let’s display some html using the php file.
For that we have to create a tpl file.

Before that, let’s discuss about client area theming.

With whmcs, there are many themes available. For each theme,
there will be different css, images etc. Templates are stored in the folder templates/.
WHMCS has a default client area template with the name ‘six’. So the client area .tpl files are stored in the folder templates/six.

Now, back to our custom_page.php. For this page, we have to create a tpl file to add html contents. Let’s name the tpl file as custom_page.tpl, then it should be uploaded to the folder templates/six.

So our tpl file full path is templates/six/custom_page.tpl

Let’s just add content as

<p>Hello world!!!! </p>

To use the above file as tpl file, we have to define that in custom_page.php

That can be one as

$ca->setTemplate('custom_page');  //it will load the templates/six/custom_page.tpl

if our tpl file name was test.tpl, then we could load that as

$ca->setTemplate('test');  //it will load templates/six/test.tpl

Then to print the content, we have to add below line to the custom_page.php

$ca->output();

So the full custom_page.php is

<?php

//Let's include whmcs classes
use WHMCS\ClientArea;
use WHMCS\Database\Capsule;

define('CLIENTAREA', true);

require __DIR__ . '/init.php';

$ca = new ClientArea();
$ca->initPage();

$ca->setTemplate('custom_page'); 
$ca->output();

And our templates/six/custom_page.tpl content is

<p>Hellow world!!!! </p>

Then browse the url
http://whmcssite.com/custom_page.php

And you will see the html content
Hello world!!!!

Now we know how to display static content using smarty.

Now let’s see how to display dynamic contents using smarty.
For that, now let’s just display the logged in user’s email in the tpl.

We have to add the below code to the php file after the line $ca->initPage();

//get the logged in user id
$loggedin_user_id =  $_SESSION['uid'];
$client = Capsule::table('tblclients')
        ->where('id', '=', $loggedin_user_id)
        ->first();
$ca->assign('client_email', $client->email);

And below code to the tpl

<p>
        Client email is: {$client_email}
</p>

So the trick is, we havee to fetch what ever data to be displayed using a query and then pass that to the
tpl as

$ca->assign('client_email', $client->email);

Then we can just access that from the tpl as {$client_email}

If we were passing the email as

$ca->assign('clientMail', $client->email);

Then we can access it from the tpl as

{$clientMail}

We can do a lot more with smarty, Some of them are explained in the below links.
https://www.smarty.net/docsv2/en/language.function.if.tpl
https://www.smarty.net/docs/en/language.function.foreach.tpl
https://www.smarty.net/docs/en/language.variables.tpl
https://www.smarty.net/docs/en/language.function.include.tpl
https://www.smarty.net/docs/en/language.syntax.variables.tpl

~

31 Mar

Useful Laravel Commands

#Reload the database
php artisan migrate:fresh –seed

#Install new packages and the compile
`composer install` & `npm install`

#Create a seeder file
php artisan make:seeder NewModelSeeder

#Run a single seeder file
php artisan db:seed –class=NewModelSeeder

#Create a model
php artisan make:model MyNewModel

#Create a controller
php artisan make:controller MyNewController –resource

#Create a migration file
php artisan make:migration create_my_new_table –create=my_new_table

#Run migration
php artisan migrate

11 Dec

How to get WHMCS date format?

To know the date format is set in the WHMCS, we can use the below query.

$date_format =  Capsule::table('tblconfiguration')
              ->where('setting', '=', 'DateFormat')
              ->value('value');

Some of the example date formats are MM-DD-YYYY, MM/DD/YYYY, DD-MM-YYYY etc.

We can convert that to the classical d m Y format by using the below code.

            $date_format = str_replace("DD", "d", $date_format);
            $date_format = str_replace("MM", "m", $date_format);
            $date_format = str_replace("YYYY", "Y", $date_format);