Create the settings control class

This class will represent your custom control. To create it, you must perform the following:

  1. Create a class to represent the payment processor provider.
    In the folder for your custom payment processor, add a new class item.
  2. Make the class public.
    Define the class to use the public access specifier.
  3. Inherit the FieldControl class.
    Inherit the FieldControl class and implement its abstract members. The class has the following abstract members:
    • protected internal override WebControl TitleControl
      A property that returns an instance of the control in the template representing the title of the control.
    • protected internal override WebControl DescriptionControl
      A property that returns an instance of the control in the template representing the description of the control.
    • protected internal override WebControl ExampleControl
      A property that returns an instance of the control in the template representing an example for the input in the control.

      NOTE: You have to add Label controls for these three values in your template. For more information, see For developers: Create the template of the settings control.

    • protected override void InitializeControls(GenericContainer container)
      A method that is used to set values to the controls in the template. At the time this method is called all of the controls in the template can be instantiated and modified. Set the content of the Title, Example and Description controls to the respective properties of the field. The values of these properties are set while For developers: Install the payment processor provider.  Also, set the Value property of the hidden field responsible for storing the ID of the payment method. The property for this field and the other important controls in the template are created later in this topic.
    • protected override string LayoutTemplateName
      A property that returns the name of the resource representing the template of the control.

      NOTE: You get an instance of a control by calling the GetControl method of the GenericContainer instance. To get a control you must pass its ID as an argument.

  4. Create properties for the input controls in the template.
    You have to create a property in the control's class for each input field in the template. There must be a field for each of the properties of the For developers: Create the payment settings. For example, the following fields will be available in the template:
    • ProcessingMode
      The input field for this property is represented by a ChoiceField control.
    • PaymentType
      The input field for this property is represented by a ChoiceField control.
    • ProcessorCreditCards
      The input field for this property is represented by a ChoiceField control.
    • Timeout
      The input field for this property is represented by a TextField control.
    • LiveUsername
      The input field for this property is represented by a TextField control.
    • LivePassword
      The input field for this property is represented by a TextField control.
    • TestUsername
      The input field for this property is represented by a TextField control.
    • TestPassword
      The input field for this property is represented by a TextField control.

      NOTE: You get an instance of a control by calling the GetControl method of the GenericContainer instance. To get a control you must pass its ID as an argument.

  5. Create a property for the HiddenField control containing the ID of the payment method.
  6. Override the Value property.
    Configure the Value property to return Guid.Empty, when the value of the property is null.
  7. Override the GetScriptReferences method.
    Override the method and add a reference to the script file that contains the client component.
  8. Override the GetScriptDescriptors method.
    Add a component property for each of the fields in the template.

Use the following code sample:

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Get started with Integration Hub | Sitefinity Cloud | Sitefinity SaaS

This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.

Web Security for Sitefinity Administrators

This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?