You are here: Order System > Checkout Process > Payment Processing > Creating Payment Gateways

Creating Payment Gateways

Definitions

When creating and configuring payment methods in EPiServer Commerce, there are three components that need to be created or re-used as well as configured: Payment Types, Payment Gateways and Payment Methods.

Payment Types - Payment types are classes which contain the properties of a particular payment type. For example, a credit card payment type contains credit card number, card expiration date, card type, etc. All payment types inherit from the abstract class Payment. The most common payment types are already built-in to EPiServer Commerce:

Credit card, cash card, gift card, and invoice. In addition, a generic OtherPayment type is included in EPiServer Commerce. Payment types are meta classes.

Payment Gateways - Payment gateways provide an interface to the system which provides payment processing. A payment type is passed to the payment gateway and the gateway executes the payment transaction with the payment system (e.g. PayPal). One payment type is associated with each payment gateway.

Payment Methods - Payment methods contain information about the way the customer views a payment option and has a payment gateway associated with it.

Gateway Properties - some of the gateway properties are explained in the following:

How to Implement

There are several alternatives when setting up payment options for your site:

Using a Built-In Payment Gateway

  1. In Commerce Manager, go to the Administrative tab and Order System/Payments/ecf52:Language node.
  2. Select the built-in method to be used.
  3. Configure the payment method. See the Gateway Properties definitions above.
  4. Configure the Parameters tab of the payment method with details specific to the particular payment gateway. This interface provides fields dynamically based on the gateway.
  5. Press OK.

Create Multiple Instances of the Same Gateway

  1. Follow steps 4-6 of the Create Custom Payment Gateway directions below. Note that you should be able to copy the control associated with the existing implementation of the payment gateway (from the ManagementConsole/ConsoleManager/App/Order/Payments/Plugins/ecf52:existing gateway folder name AKA system keyword) and simply give the control class file (.ascx.cs) a unique name. Use a new folder name that corresponds to the System Keyword that will be used in step 4.
  2. In Commerce Manager, go to the Administrative tab and Order System/Payments/ecf52:Language node.
  3. Click the New button.
  4. Configure the payment method. See the Gateway Properties definitions above. Click the OK button.
  5. Re-open the payment method from the payment method list.
  6. Go to the second tab and set any configuration information required for the particular implementation of this gateway. Press OK to save the new information.

Create Custom Payment Gateway

bool ProcessPayment(Payment payment, ref string message);

 

* Provide implementation for the ProcessPayment method to execute the payment transaction you need. Look at the BusinessLayer/OrderSystem/PaymentGateways/ICharge/IChargeGateway.cs class file for an example implementation.

public void LoadObject(object dto) 
                        { 
                          _PaymentMethodDto = dto as PaymentMethodDto; 
                        }

 

Note that _PaymentMethodDto is a member variable of type PaymentMethodDto.

Note that these directions do not contain details on how to display this information to the customer on the web site. For custom gateways, you'll need to implement your own method for displaying and saving payment information for this gateway. The simplest tool to use to retrieve payment option information is the PaymentMethodDto class. For saving customer payment information entered on the public site, look in the PublicLayer/FrontEnd2/Templates/Default/Checkout/CheckoutWizardModule.ascx and ..CheckoutPaymentModule.ascx controls.

Adding Payment Types

If you need a payment type that doesn't correspond to one of the payment types built into EPiServer Commerce, you can extend the built-in OtherPayment payment type with whatever meta fields you need.

How to modify OtherPayment Payment Type

  1. In Commerce Manager, goto the Administration tab, Order System/Meta Classes node.
  2. Select Order Form Payment from the Element dropdown list.
  3. Select Other Payment from the Type dropdown list.
  4. Select the meta fields that you need to associate with the meta class.
  5. If you need a field that isn't available :

Adding Meta Fields to Payment types

If you're implementing your own gateway, you may want to add meta fields to one of the built-in payment types (e.g. CreditCardPayment) to store custom information. This can be done through Commerce Manager. See the directions above about modifying the OtherPayment payment type and use the same approach with the meta class you need to add meta fields to.

Namespaces:

Mediachase.Commerce.Orders (IShippingGateway, Payment types)

Mediachase.Commerce.Plugins.Payment (Payment Gateway classes)

For more information about payment providers in EPiServer Commerce, please refer also to the Configuring Payment Providers section in this documentation.

 


Version: EPiServer Commerce 1 R2 SP2| Last updated: 2012-06-29 | Copyright © EPiServer AB | Send feedback to us