Creating the payment settings
In this example, the payment processor will require the following:
To create payment settings for your payment processor, you must perform the following:
- Create a class to represent the payment settings.
In the folder for your custom payment processor, add a new class item.
- Make the class public.
Define the class to use the public access specifier.
- Implement the IPaymentSettings interface.
The IPaymentSettings interface requires the following properties:
- string[] ProcessorCards
Gets or sets an array containing the supported credit cards.
- string PaymentType
Gets or sets the type of the payment. (sale, authorize, capture, authorize and capture, etc.)
- Create the following properties:
- string ProcessingMode
Gets or sets whether the payment method is in live or test mode. The possible values for this property are “test” and “live”.
- bool TestMode
Returns true if the value of the ProcessingMode property is equal to “test”.
- double Timeout
Gets or sets the timeout for post to the payment processor.
NOTE: If you intend not to use test and live properties, you can skip the ProcessingMode and the TestMode properties. In this case you have to skip their representation in the configuration control too. For more information about the configuration control, see Creating the settings control.
- Create the payment processor specific properties.
Create properties for the values required by the payment processor. It is recommended to create properties for both live and test values:
- TestUsername and LiveUsername
- TestPassword and LivePassword
NOTE: If you intent not to use only live properties, create only one set of these properties and remove the prefixes from their names.
- Create wrapper properties.
Create wrapper properties that return the value of either the test or the live property based on the value of the TestMode property. This allows you to easily access the value of the needed property for the specified mode.
Here is a code example of a CustomPaymentProcessorSettings class:
public class CustomPaymentProcessorSettings : IPaymentSettings
{
public string Username
{
get
{
return TestMode ? TestUsername : LiveUsername;
}
set { }
}
public string Password
{
get
{
return TestMode ? TestPassword : LivePassword;
}
set { }
}
public bool TestMode
{
get
{
return ProcessingMode.ToLower() == "live" ? false : true;
}
set { }
}
public string TestUsername
{
get;
set;
}
public string TestPassword
{
get;
set;
}
public string LiveUsername
{
get;
set;
}
public string LivePassword
{
get;
set;
}
public string ProcessingMode
{
get;
set;
}
public double Timeout
{
get;
set;
}
public string[] ProcessorCreditCards
{
get;
set;
}
public string PaymentType
{
get;
set;
}
}