Difference between revisions of "Dev:Gateway:Config"

From WHMCS Documentation

 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
<div class="docs-alert-warning">
+
<div class="docs-alert-danger">
'''This is a required function'''
+
<span class="title">Required</span><br />
 +
This is a required function by any type of module.
 
</div>
 
</div>
  
Line 7: Line 8:
 
There are 2 required system attributes - a Friendly Name - this is the name that is displayed to users of your module within the WHMCS interface, and the Usage Notes which allow you to provide additional instructions to users of your module.
 
There are 2 required system attributes - a Friendly Name - this is the name that is displayed to users of your module within the WHMCS interface, and the Usage Notes which allow you to provide additional instructions to users of your module.
  
Following those you can define an unlimited number of settings your module requires. These take the format below:
+
Following those you can define an unlimited number of settings your module requires.
  
<source lang="php">
+
===Field Definitions===
    "settingname" => array(
+
 
        "FriendlyName" => "Display Name",
+
Below are the supported configuration field types and their attributes.
        "Type" => "xxxx",
+
 
        // Additional attributes here
+
{| class="paramstable"
    ),
+
|- class="tablehead"
</source>
+
|Type
 +
|Required Attributes
 +
|Optional Attributes
 +
|-
 +
|text
 +
|FriendlyName - Display Name<br />Size - Length of Field
 +
|Default - Default Value to Assign<br />Description
 +
|-
 +
|password
 +
|FriendlyName - Display Name<br />Size - Length of Field
 +
|Default - Default Value to Assign<br />Description
 +
|-
 +
|yesno
 +
|FriendlyName - Display Name
 +
|Default - true/false<br />Description
 +
|-
 +
|dropdown
 +
|FriendlyName - Display Name<br />Options - Comma separated list of possible values
 +
|Default - Option to select<br />Description
 +
|-
 +
|radio
 +
|FriendlyName - Display Name<br />Options - Comma separated list of possible values
 +
|Default - Option to select<br />Description
 +
|-
 +
|textarea
 +
|FriendlyName - Display Name
 +
|Default<br />Cols - Number of columns<br />Rows - Number of rows<br />Description
 +
|}
 +
 
 +
===Code Sample===
  
We'll look at all the possible setting field types and their supported attributes below.  But first, let's take a look at an example of a typical configuration function for a gateway module.
+
The settings you define here will be passed into all the functions of your gateway module any time it is called.
  
 
<source lang="php">
 
<source lang="php">
Line 25: Line 55:
 
             "Type" => "System",
 
             "Type" => "System",
 
             "Value" => "My Custom Gateway Module",
 
             "Value" => "My Custom Gateway Module",
 +
        ),
 +
        "UsageNotes" => array(
 +
            "Type" => "System",
 +
            "Value" => "Don't have an account yet? <a href=\"#\">Click here to Signup</a>",
 
         ),
 
         ),
 
         "accountnumber" => array(
 
         "accountnumber" => array(
Line 30: Line 64:
 
             "Type" => "text",
 
             "Type" => "text",
 
             "Size" => "10",
 
             "Size" => "10",
             "Description" => "<a href=\"#\">Click here to Signup</a>"
+
             "Description" => "This can be found in Profile > Account Information"
 
         ),
 
         ),
 
         "apiusername" => array(
 
         "apiusername" => array(
Line 46: Line 80:
 
             "Type" => "yesno",
 
             "Type" => "yesno",
 
             "Default" => false,
 
             "Default" => false,
             "Description" => "Tick to enable",
+
             "Description" => "Check to enable",
 
         ),
 
         ),
 
     );
 
     );
 
}
 
}
 
</source>
 
</source>
 
The settings you define here will be passed into all the functions of your gateway module any time it is called.  Please Note: we recommend avoiding generic names like "invoiceid" and "currency" which may conflict with other data WHMCS is passing to your gateway's functions.
 

Latest revision as of 16:50, 17 December 2021

Required
This is a required function by any type of module.

This is where you define the display name for your module, setup/usage instructions (if applicable) and any settings a user must configure for it.

There are 2 required system attributes - a Friendly Name - this is the name that is displayed to users of your module within the WHMCS interface, and the Usage Notes which allow you to provide additional instructions to users of your module.

Following those you can define an unlimited number of settings your module requires.

Field Definitions

Below are the supported configuration field types and their attributes.

Type Required Attributes Optional Attributes
text FriendlyName - Display Name
Size - Length of Field
Default - Default Value to Assign
Description
password FriendlyName - Display Name
Size - Length of Field
Default - Default Value to Assign
Description
yesno FriendlyName - Display Name Default - true/false
Description
dropdown FriendlyName - Display Name
Options - Comma separated list of possible values
Default - Option to select
Description
radio FriendlyName - Display Name
Options - Comma separated list of possible values
Default - Option to select
Description
textarea FriendlyName - Display Name Default
Cols - Number of columns
Rows - Number of rows
Description

Code Sample

The settings you define here will be passed into all the functions of your gateway module any time it is called.

function demogateway_config() {
    return array(
        "FriendlyName" => array(
            "Type" => "System",
            "Value" => "My Custom Gateway Module",
        ),
        "UsageNotes" => array(
            "Type" => "System",
            "Value" => "Don't have an account yet? <a href=\"#\">Click here to Signup</a>",
        ),
        "accountnumber" => array(
            "FriendlyName" => "Account Number",
            "Type" => "text",
            "Size" => "10",
            "Description" => "This can be found in Profile > Account Information"
        ),
        "apiusername" => array(
            "FriendlyName" => "API Username",
            "Type" => "text",
            "Size" => "20",
        ),
        "apipassword" => array(
            "FriendlyName" => "API Password",
            "Type" => "password",
            "Size" => "20",
        ),
        "testmode" => array(
            "FriendlyName" => "Test Mode",
            "Type" => "yesno",
            "Default" => false,
            "Description" => "Check to enable",
        ),
    );
}