Difference between revisions of "Dev:Gateway:Config"
From WHMCS Documentation
(Created page with '<div class="docs-alert-warning"> <span class="title">Required Function</span><br /> The config function is a required function for every gateway module where you must define the …') |
|||
(5 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
− | <div class="docs-alert- | + | <div class="docs-alert-danger"> |
− | <span class="title">Required | + | <span class="title">Required</span><br /> |
− | + | This is a required function by any type of module. | |
</div> | </div> | ||
+ | |||
+ | 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. | 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. | + | 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. | |
− | + | ||
− | + | {| class="paramstable" | |
− | + | |- class="tablehead" | |
− | </ | + | |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=== | ||
− | + | 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 24: | 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 29: | Line 64: | ||
"Type" => "text", | "Type" => "text", | ||
"Size" => "10", | "Size" => "10", | ||
− | "Description" => " | + | "Description" => "This can be found in Profile > Account Information" |
), | ), | ||
"apiusername" => array( | "apiusername" => array( | ||
Line 45: | Line 80: | ||
"Type" => "yesno", | "Type" => "yesno", | ||
"Default" => false, | "Default" => false, | ||
− | "Description" => " | + | "Description" => "Check to enable", |
), | ), | ||
); | ); | ||
} | } | ||
</source> | </source> | ||
− | |||
− |
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",
),
);
}