Disclaimer: This website requires JavaScript to function properly. Some features may not work as expected. Please enable JavaScript in your browser settings for the best experience.

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

Payment gateways

Describes payment gateways in Optimizely Customized Commerce 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 these implementation options described below:

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

Create a custom payment method

  1. Before creating a new payment method in commerce admin, create a class implementing IPaymentMethod interface.
  2. Set a unique SystemKeyword value.
  3. This class will be representation of your custom payment method.

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. Include a reference reference of payment gateway project in your website project.

  4. In Commerce Admin, go to the Administration tab and Payments.

  5. Click Create.

  6. Enter the value for System Keyword the same as in your corresponding payment method class.

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

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

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

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

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

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

  13. 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. You can also make use of PaymentManager helper class to retrieve payment methods from system based on language.

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.