Dev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Payment gateways

Describes payment gateways in Optimizely Commerce Connect 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. Each payment gateway is associated with a specific payment type.

When creating and configuring payment methods, choose one of the following implementation options:

  • Create multiple instances of the same gateway with different configurations.
  • Create a custom payment gateway.

Classes in this topic are available in the following namespace:

  • Mediachase.Commerce.Orders — Contains IPaymentGateway and Payment.

Gateway properties

Configure the following gateway properties:

  • Id — The system-assigned unique identifier of the payment gateway.
  • Name — The name shown to the user.
  • Description — A description shown to the user.
  • SystemKeyword — The unique name for each instance of the gateway. Non-unique keywords are not saved to the database. The keyword is not editable after the gateway is created.
  • Language — The language for the payment gateway.
  • ClassName — The name of the gateway class associated with the payment.

Create a custom payment method

  1. Create a class that implements the IPaymentMethod interface. The class represents your custom payment method.
  2. Set a unique SystemKeyword value on the class.
  3. Register the payment method in Commerce Admin. The next section describes the Commerce Admin steps for a custom payment gateway, which include registering the payment method.

Create a custom payment gateway

  1. Create a separate project in the solution to store custom business logic for your application, if one does not already exist.

  2. Create a class in this project that inherits from the abstract class AbstractPaymentGateway. The base class has one property (Settings) and one method (ProcessPayment).

    • Settings — A dictionary that stores additional gateway information. Use it for details such as web service authentication credentials, or a flag that indicates whether a call is for authorization or payment processing.

    • ProcessPayment — Contacts the payment processing system and processes the payment. The method signature is:

      bool ProcessPayment(Payment payment, ref string message);

      Implement ProcessPayment to execute the payment transaction your gateway needs.

  3. Add a reference to the payment gateway project from your website project.

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

  5. Click Create.

  6. Enter the same SystemKeyword value as in your corresponding payment method class.

  7. Use the gateway property descriptions in the previous section to fill in the fields on the first tab.

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

  9. To enable the payment method, set IsActive to Yes.

  10. After completing the first tab, click OK.

  11. Reopen the payment method from the payment method list.

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

  13. Click OK.

📘

Note

This article does not cover displaying payment information on the storefront. For custom gateways, implement your own logic to display and save payment information. The PaymentMethodDto class is the simplest way to retrieve payment information. The PaymentManager helper class also retrieves payment methods from the system by language.

Add payment types

If none of the built-in payment types fit your scenario, extend the built-in OtherPayment payment type with the meta fields you need.