Plug-In Configuration

Generally plug-ins have no database connection, so they store no configuration. Plug-in configuration is managed and kept by Billing.

Billing gets all parameters required for plug-in configuration from the plug-in as follows:

  1. Calls the plug-in method %Plug-in_Name%_GetConfig method.
  2. Prompts the administrator to populate them with values in an auto-generated configuration page in Provider Control Panel.
  3. Stores the values in Billing database.

%Plug-in_Name%_GetConfig response

%Plug-in_Name%_GetConfig response is an array that contains a set of parameters like:

'parameter_id' => array( 
        'friendlyName'=> 'Parameter Visible Name', # name that will be shown in configuration page in CP 
        'type'        => 'text',                   # type of parameter (can be string, integer, yesno, file etc.) 
        'size'        => 20                        # data size limitation 
)

Below is an abstract example:

function Plugin_Name_GetConfig() {
    return array(
        'friendlyName' => pa_localized_string('plugin_name_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' => 'Connection settings',                    # 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' => 'Gateway 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' => 'Authentication 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' => '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' => 'Test Mode',                              # Display name for the item
            'default' => 'yes'                                          # Default value is 'yes'
        )
    );
}

After the plug-in is configured, the config passed to the plug-in's method looks simple:

"config" : {
    "gateway_url" : "https://plugin-gateway-url.com",
    "auth_code" : 421,
    "format" : "json",
    "test_mode" : "yes"
}