Hide menu Last updated: Oct 24 2016
Area: Episerver Commerce Applies to versions: 10 and higher
Other versions:

Payment gateways

Payment gateways in Episerver Commerce provide an interface to the payment processing system. A payment type is passed to the payment gateway, which executes the payment transaction with the payment system. One payment type is associated with each payment gateway.

When creating and configuring payment methods, you have the following implementation options, described below:

Note: Classes in this topic are available in the Mediachase.Commerce.Orders namespace, which contains IPaymentGateway and Payment types.

Gateway properties

To use the various options, configure the following gateway properties:

  • Id. The system-assigned unique identifier of the payment gateway.
  • Name. The name to be displayed to the user.
  • Description. A description to be displayed to the user.
  • System Keyword. The unique name for each instance of the gateway; new, non-unique keywords will not save to the database. This is not editable after a gateway is initially created.
  • Language. A language for the payment gateway.
  • Class Name. Name of the gateway class to be associated with the payment.

Using a built-in payment gateway

  1. In Commerce Manager, go to Administration > Order System > Payments > language.
  2. Select the built-in method to be used.
  3. Configure the payment method. See the gateway properties definitions above.
  4. Configure the payment method's Parameters tab with details for the payment gateway. This interface provides fields dynamically based on the gateway.
  5. Click OK.

Creating multiple instances of a gateway

  1. Re-compile the solution.
  2. Copy the .dlls associated with the project where the payment gateway is implemented to the bin folders of both the Commerce Manager and public websites.
  3. In Commerce Manager, go to the Administration tab and Order System > Payments > Language.
  4. Click New.
  5. Configure the payment method (see gateway properties definitions above), and click OK.
  6. Re-open the payment method from the payment method list.
  7. Go to the second tab and set any configuration information required for this implementation of the gateway.
  8. Click OK.

Creating a custom payment gateway

  1. Create a separate project in the solution to store custom business logic implementations for your application, if this has not been done already.
  2. Create a class in this project that inherits from the abstract class AbstractPaymentGateway. This base class has only has one property, Settings, and one method, ProcessPayment().
    • The Settings property is a dictionary type that allows other gateway information to be stored. For example, web service authentication details for connecting to the payment provider, or an indicator whether the payment provider call is for authorization or payment processing.
    • ProcessPayment is the method used to contact the payment processing system and process payments. Example: signature for the ProcessPayment method
      bool ProcessPayment(Payment payment, ref string message);

      Provide implementation for the ProcessPayment method to execute the payment transaction you need.

  3. Create an admin config user control. This is used to provide an interface in the Commerce Manager for the second tab of the Payment Method edit screen. This tab is not available until after the information on the first tab is saved for the first time for a new method.
    • Add the new ascx file to a new folder in the <Commerce Manager Site>/Apps/Order/Payments/Plugins folder, named the same as the System Keyword to be set to below.
    • Name the .ascx file ConfigurePayment.ascx.
    • The control must implement the IGatewayControl interface and inherit from OrderBaseUserControl. Look at the ManagementConsole > ConsoleManager > Apps > Order > Payments > PlugIns > Authorize > ConfigurePayment.ascx for an example of how to implement this.
    • LoadObject(). At a minimum, this method should contain code as below.

Example: minimum code for LoadObject() method.

public void LoadObject(object dto) 
{ 
    _paymentMethodDto = dto as PaymentMethodDto; 
}
Note: _paymentMethodDto is a member variable of type PaymentMethodDto.
  1. Re-compile the solution.
  2. Copy the .dlls associated with the project where the payment gateway is implemented to the bin folders of both the Commerce Manager and Public websites.
  3. In Commerce Manager, go to the Administration tab and Order System/Payments.
  4. Click New.
  5. Enter a System Keyword that corresponds with the folder added in the <Commerce Manager Site>/Apps/Order/Payments/Plugins/ folder (step 4) to contain the admin control.
  6. See the gateway properties description above for information about the fields on the first tab.
  7. Select the new gateway from the drop-down list.
  8. If you intend to start using the payment method, set IsActive to Yes.
  9. When all information is added to the first tab, click OK.
  10. Re-open the payment method from the payment method list.
  11. Go to the second tab and set configuration information required for this implementation of the gateway.
  12. Click OK.

    Note: These directions do not explain how to display this information on the website. For custom gateways, implement your own method for displaying and saving payment information for this gateway. The simplest tool for retrieving payment information is the PaymentMethodDto class.

Adding payment types

If you need a payment type that does not correspond to one of the built-in payment types, extend the built-in OtherPayment payment type with whatever meta fields you need.

Modifying OtherPayment payment type

  1. In Commerce Manager, go to Administration > Order System > Meta Classes.
  2. From the Element drop-down list, select Order Form Payment.
  3. From the Type drop-down list, select Other Payment.
  4. Select the meta fields that you need to associate with the meta class.
  5. If you need a field that is not available:
    1. Click the Meta Fields node.
    2. Click New.
    3. Add the field properties and click OK.
    4. Repeat as needed.

Adding meta fields to payment types

If you are implementing your own gateway, you may want to add meta fields to one of the built-in payment types, for instance CreditCardPayment, to store custom information. You can do this through Commerce Manager. See modifying the OtherPayment payment type, and use the same approach with the meta class to which you need to add meta fields.

Comments