GetConfig
Purpose
Returns parameters to configure a plugin. See Plugin Configuration for more information.
Mandatory
Yes.
Input Parameters
None.
Response
An associative array that contains the following keys:
Param name | Description | Type |
---|---|---|
friendlyName
|
The plugin title that will be displayed in the plug-in configuration page and in the gateway selection options. | string |
parameter_id
|
This defines a section or a parameter field. It can assume the |
Section | Param |
Example
The following example shows the GetConfig
method implementation in the Example plugin.
function Example_GetConfig()
{
return array(
'friendlyName' => pa_localized_string('plugin_title'), # title - A plugin title that will be shown in plugin configuration page and in the gateway selection options.
# Note: localization is available here.
'connection' => array( # "connection" is a section name
'type' => 'section', # type => section means that parameters from 'items' will be grouped in the section with the title of 'friendly' value
'friendlyName' => pa_localized_string('conn_setting'), # friendlyName - A display name that will be shown in plugin config
'items' => array( # items - Section items
'gateway_url' => array( # Item called by 'gateway_url'
'type' => 'text', # Parameter's type is text
'friendlyName' => pa_localized_string('gtw_url'), # Display text for 'gateway_url' parameter
'default' => 'https://plugin-gateway-url.com', # Parameter's default value
'required' => true # Parameter is required and will be marked with red symbol '*' in the plugin configuration page
),
'auth_code' => array( # Item called by 'auth_code'
'type' => 'integer', # 'auth_code' parameter's type is integer
'friendlyName' => pa_localized_string('auth_code'), # Display text for 'auth_code' parameter
'min' => 100, # Minimum of parameter value
'max' => 999 # Maximum of parameter value
)
)
),
'format' => array( # Protocol format (it is just an example :))
'type' => 'dropdown', # Type is dropdown. Shown as combobox
'options' => array( # Parameter's options
'xml', 'json', 'csv'
),
'default' => 'json', # Parameter's default value
'friendlyName' => pa_localized_string('protocol_format') # Display text
),
'test_mode' => array( # Test mode parameter (without a section in this example)
'type' => 'yesno', # Can be 'yes' or 'no'. "Test mode" will be shown as checkbox
'friendlyName' => pa_localized_string('test_mode'), # Display name for the item
'default' => 'yes' # Default value is 'yes'
)
);
}
The following image shows how the configuration parameters can be set in the control panel. Billing uses the GetConfig
response array to display that UI and, once Save is clicked, Billing saves data in its database. The stored configuration data will be sent to the plugin after the interaction with the plugin.
The following JSON fragment shows how configuration is sent to the plugin throughout the method request:
"config" : {
"gateway_url" : "https://plugin-gateway-url.com",
"auth_code" : 421,
"format" : "json",
"test_mode" : "yes"}