Creating Settings for a Payment Gateway

All Payment Gateways can create a settings page so that site owners can configure the gateway. Common options might be the site owners account username, API keys, or preferences on how the gateway should operate.

To create your settings, you’ll need to use the form() method. This is one of the two require methods you need to create for a valid gateway.

public function form(){
   return array();
}

As you can see, the form() method returns an array. This array represents a series of fields for a form. These fields will be displayed in the back-end, for the user to input data into. After saved, these options will be passed to the process() method of your gateway when processing orders.

Creating this array is simple. Here is the basic layout:

$fields = array(
    array(
       'title' => __( 'Field Title', 'myplugin' ),
       'name' => 'field_name',
       'type' => 'field_type', // text, textarea, checkbox
    )
);

The base $fields array is a list of the different fields. Each field is its own array with a title, name, and type. The above example shows how to make very basic fields. Text fields, textareas and checkboxes.

You can get more fancy with dropdowns and radio buttons. When using one of them, you can use the value key to define an array of possible options:

$fields = array(
    array(
       'title' => __( 'Field Title', 'myplugin' ),
       'name' => 'field_name',
       'type' => 'radio', // select or radio
       'value' => array(
          'value' => __( 'Display Text', 'myplugin' )
       )
    )
);

There are even more attributes and options you can play around with here.

Next Step: Processing Orders

Now that you’ve set up everything else, its time for the meat of your plugin. It is time to start processing orders and taking payments.

Processing Payments with a Payment Gateway

Your rating: none
Rating: 3 - 4 votes

Popular Add-ons

Bazar

A Stunning Child Theme for Classipress 4


(11)
$49

Daddy Like

A fast, lightweight, and elegant "like" system for comments, pages, posts,…


(12)
$19

Critic

A professional review and rating system for WordPress.


(13)
$29