HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideLegal TermsGitHubNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Payment gateways

Describes payment gateways in Optimizely Commerce Connect 13 that 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:

  • Use a built-in payment gateway.
  • Create multiple instances of the same gateway with a different configuration.
  • Create a custom payment gateway.

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.

Use a built-in payment gateway

  1. 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.

Create 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.

Create 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 file for an example of implementing 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.

  4. Re-compile the solution.

  5. 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.

  6. In Commerce Manager, go to the Administration tab and Order System/Payments.

  7. Click New.

  8. 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.

  9. See the gateway properties description above for information about the fields on the first tab.

  10. Select the new gateway from the drop-down list.

  11. If you intend to start using the payment method, set IsActive to Yes.

  12. When all information is added to the first tab, click OK.

  13. Re-open the payment method from the payment method list.

  14. Go to the second tab and set configuration information required for this gateway implementation.

  15. 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.

Add payment types

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

Modify OtherPayment payment type

  1. 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 metaclass.
  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.

If you are implementing your 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 metaclass to which you need to add meta-fields.