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

Category Icons

Add icons to your ClassiPress categories


(6)
$19

Bazar

A Stunning Child Theme for Classipress 4


(11)
$49

Profiler for Vantage

Adds a one page author website to your Vantage theme.


(6)
$39