Super Admin's Panel

How to create your own Module on FHBRS

Modules are the direct integrations that enable products to be delivered automatically. A properly configured Module makes it possible for an item to be delivered after it has been paid for or to render a process towards achieving that.

Example: if you as the Super Admin is providing a service and the provider’s domain is  providerdomain.com, so when someone orders on your site successfully, the Module are lines of codes stating what to do after an order has been made, in this case, the module will connect via API to providerdomain.com and when it’s successful then create the order so that the user is able to receive details via email or phone or whatever mode of communication for the user to get order filled.

Modules can be written in whatever programming language, we would basically present to you a guide which would be useful for whatever tweak or whatsoever.

 

So how this flows is;

USER –> FHBRS (Initiates a process or purchase) –> MODULE –> EXTERNAL API –> MODULE –> FHBRS –> USER

It flows from the user making a request either purchase or whatsoever, then the Module sends the request and return a result which FHBRS further processes.

 

Practical example using a shared hosting product: When someone makes an order for a shared hosting, FHBRS would process the module link for the associated product then wait for the response. Here from this example, the module would be all about creating the shared hosting account using the WHM API using the details sent by FHBRS like email, domain, nameservers and so on. The Module is actually the script that processes the order; this actually is needed if the order needs to be processed automatically.

 

Here is a graphical example on how to create a new Module; Navigate to the Products & Modules page then click the Modules tab like this;

 

 

When you click the Add Module, you would see the modal with required information like this;

 

After adding it, then you would be able to add the codes by clicking on Edit Module Code

 

 

 

Inside the box is where we would be adding the module codes. Before we continue, FHBRS has 4 types of calls when writing your module. They are as follows;

1) NEW: This is when the user is paying for the first time and its time to process the order

2) SUSPEND: If you have a subscription based product, here FHBRS would send this condition to your Module if due date is greater than or equals the present date.

3) UN-SUSPEND: This is when the user has made payment and the order was once suspended, now it’s time to unsuspended and make the product active again

4) UPGRADE: The user wants to upgrade to a higher plan if you have enabled it.

 

It’s placed on a variable called $process_type. So  a simple usage example here with PHP is

<?php if ($process_type == ‘UPGRADE‘){ ?>

This means FHBRS will make a call to your script when someone wants to Upgrade with a variable called $process_type with value as UPGRADE. Since there would be 4 of these type of calls, you would need to specify which of your script should run at a given time.

 

 

VARIABLES:

There are basic values which are ready for use when programming the Module. The following variables apply to the respective calls which already exist on that page. This process is very straight forward, the variables are written in PHP which can be used and applied using any programming language. These variables are Pre-Defined; just use them on the script being written. These variables are as follows;

 

BILLING DETAILS: (the billing details entered for the order)

$bill_fname – This is the First name of the person as entered from the billing’s page

$bill_lname – This is the Last name of the person as entered from the billing’s page

$bill_email – This is the email address of the person as entered from the billing’s page

$bill_phone – This is the phone number of the person as entered from the billing’s page

$bill_address – This is the address of the person as entered from the billing’s page

$bill_city – This is the City of the person as entered from the billing’s page

$bill_state– This is the State or Province of the person as entered from the billing’s page

$bill_postal_code – This is the Postal code of the person as entered from the billing’s page

$bill_country – This is the Country of the person as entered from the billing’s page (ex. US, CA)

$bill_company_name – This is the Company Name of the person as entered from the billing’s page

$bill_company_address – This is the Company address of the person as entered from the billing’s page

$bill_state – This is the Company state of the person as entered from the billing’s page

$bill_company_zip – This is the Company’s postal code of the person as entered from the billing’s page

$bill_country – This is the Company’s Country of the person as entered from the billing’s page

 

 

 

USER DETAILS: (the details of the person as it exist on the users table)

$u_fname – This is the first name of the person who has initiated the transaction

$u_lname -This is the last name of the person who has initiated the transaction

$u_email –  This is the email address of the person who has initiated the transaction

$u_address –  This is the address of the person who has initiated the transaction

$u_city –  This is the city of the person who has initiated the transaction

$u_state –  This is the state or province of the person who has initiated the transaction

$u_postal_code –  This is the postal code of the person who has initiated the transaction

$u_country –  This is the country of the person who has initiated the transaction (Ex. Spain, Italy)

$u_email_status –  This is the email verification status of the user. 1 for verified, 0 for not verified.

 

 

PRODUCT DETAILS:

$product_name – This is the name of the product

$product_code – This is the product code

$product_intro – This is the intro set for the product

$product_description– This is the description for the product

$product_image – This is the product image

 

 

ORDER DETAILS:

$ords_original_amount – This is the default amount of the product in user’s currency

$ords_package_amount – This is the sales cost of the product in user’s currency

$ords_vat – This is the amount charged in vat in user’s currency

$ords_tax – This is the amount charged as tax in user’s currency

$ords_unit – This is the number of this product ordered

$ords_add_hosting – This could store several values. For a web hosting site, this would store the domain name entered when adding products to cart.

$ords_duration – This is the duration which was entered. If you have several proces for different periods, you can get which was paid for here.

$ords_user – The site’s email address of the user who has ordered this

$ords_time – Timestamp of when this was ordered

$ords_status – The order status of the order. 3 for pending, 0 for nothing and 1 for processed.

$ords_payment_status – The payment status for the order. 1 for paid, 0 for nothing.

$ords_payment_date – The timestamp of when payment was made.

$ords_payment_method – The payment method used in making payment.

$ords_token – The unique token for this order

$ords_affiliate_earn – The amount paid for affiliate for this order

$ords_discount – The amount of discount for this order

$ords_discount_for – What product the discount was for if it exists.

$ords_site_url – The site domain where the order was made

$ords_val1 – $ord_val10 – Please check respective License types to see what value would be entered here. For SMS license, $ord_val1 stores the phone numbers separated by commas, $ord_val2 stores the sender name, $ord_val3 stores the message to be sent.

For a webhosting license, $ord_val1 – $ord_val10 would store the configuration you set, Learn more here. For SMM license, Read Here.

 

 

 

CATEGORY DETAILS:

$category_name – This is the name of the category

 

 

ADDONS DETAILS:

$addons_name – This is the name of the addon chosen for this ordered product

$addons_col1  to $addons_col20 AND $addons_val1 to $addons_val20

 

$addons_col1 – This will return what was added during setup

$addons_val1 – This will return what was added during setup

Since they are already pre-defined, you can just use the values to detect which privilege you have configured for this product.

 

 

 

 

 

 

USAGE EXAMPLE:

Programming a module using the variables above is quite straight forward. First you need to specify which call from the explanation before this, you would notice that there are 4 possible things the module can do.

  1. Create a new order
  2. Suspend an order: this is for those who have setup a recurrent product
  3. Un-suspend an order: this should happen when the user has paid for an order which was once suspended
  4. Upgrade an order: If this option is set to make it possible for users to upgrade from one product to the other, this becomes active.

 

 

Practical example with PHP.

<?php if ($process_type == ‘NEW’){ ?>

Here you can process your script and whatever you want to achieve in whatever programming language calling values you want to use from the available values above.

<?php } ?>

 

 

 

RETURN VARIABLES:

The return variables are the variables you would create after the process is done, the variables would be inserted into important fields for the user to view. Example is an activity name that shows exactly what was paid for and a comment regarding it.

The variables are;

$s_activity_name: Here, the user would see more information on the order paid for
$s_username: If you have anything that has to do with storing a unique username or value for the order, then store it here. Just add the value as a variable.
$s_ips: If your script is storing IP address for the user then this is where you store it, this is very useful for hosting businesses.
$s_other_details: Here is where you can write some notes about the order, this would be used as a reference for both you and the user who has ordered the product.
$subject – This only applies to when newly creating the order. You should include the subject of the message to be sent to the user
$body – This only applies to when newly creating the order. You should include the message you want to send to the user. Example: Your order has been created and the details are as below. This and the subject would be sent to the user using your site’s template or the site template for the reseller.
If you enabled the reseller network, remember here that the user could either be directly from you or from the resellers’ so make use of appropriate link. The site URL where the user made the order from is among the available variables you can use.
Here is an example of how the returned variables was created for a shared hosting module after connecting to WHM’s API.

 

 

 

Here is an example of how the information you specified for the returned variables in the UI would look like;

The activity name would be the title in recent activities for the user.

 

 

Need help building a Module? Contact Us!

Related Articles