Skip to content

Using the Payment Gateway Framework

Max Rice edited this page Dec 9, 2015 · 1 revision

Supports (zero or more):

  • tokenization - supports tokenization methods
  • card_types - allows the user to configure a set of card types to display on the checkout page
  • charge - transaction type charge
  • authorization - transaction type authorization
  • customer_decline_messages - detailed customer decline messages on checkout

Payment Types (one and only one per gateway class):

  • credit-card - supports credit card transactions
  • echeck = supports echeck transactions

Usage

Extend the class and implement the following methods:

  • get_method_form_fields() - return an array of admin settings form fields specific for this method (will probably include at least authentication fields).
  • payment_fields() - probably very simple implementation, ie woocommerce_intuit_qbms_payment_fields( $this );

Override any of the following optional method stubs:

  • add_payment_gateway_transaction_data( $order, $response ) - add any gateway-specific transaction data to the order

Types of Tokenization Requests

There are two different models used by payment gateways to tokenize payment methods: tokenize with sale/zero dollar pre-auth, or tokenize first. Sample gateways of the former include First Data and NETbilling, which automatically tokenize a payment method as part of a regular authorization/charge transaction. While an example of the latter is Intuit QBMS, which has a dedicated tokenize request that is always used. This framework assumes the "tokenize first" protocol. To implement a gateway that combines tokenization with sale, simply do the following:

  • Override SV_WC_Payment_Gateway_Direct::tokenize_with_sale() to return true
  • Make sure that the API authorization response class also implements the SV_WC_Payment_Gateway_API_Create_Payment_Token_Response interface

The framework assumes that for tokenize with sale gateways there will also be a separate zero-dollar tokenization request, this should be implemented by SV_WC_Payment_Gateway_API::tokenize_payment_method()

Subscriptions/Pre-Orders support

If a gateway supports tokenization, it will automatically support both Subscriptions (1.5.x and 2.0.x) and Pre-Orders without any further changes.

Gateway Type

Implement the following method stubs based on the gateway type:

  • get_api() - for direct payment methods this returns the API instance

Customer ID

Most gateways use a form of customer identification. If your gateway does not, or you don't require it, override the following methods to return false:

  • get_customer_id_user_meta_name()
  • get_guest_customer_id()
  • get_customer_id()

Transaction URL

Some, not all, gateways support linking directly to a transaction within the merchant account. If your gateway support this, you can override the following method to return the direct transaction URL for the given order. Don't forget to declare support for this within the gateway plugin class!:

  • get_transaction_url( $order )