Writing a New Payment Gateway
Payment Gateways are an important part of an E-Commerce Website, there are many Gateway Providers. The trick is to find the one that suits your business needs. Once you’ve chosen a gateway, check to see if it is already integrated with the Wp-E-Commerce Plugin if not, this documentation will help you in making a Gateway Module.
Please note, this resource is intended for developers with a know how in PHP and mySQL and for developing gateway modules for Wp-E-Commerce 3.7 and up.
Parameters and required information
At the beginning of your script you must have these variables and fill them in with your new gateways information.
$nzshpcrt_gateways[$num]['name'] = 'My New Gateway';
This is the gateway name used in the front end of the site (checkout page)
$nzshpcrt_gateways[$num]['internalname'] = 'my_new_gateway';
This is the gateway name used internally
Naming convention is all small letters and no spaces
$nzshpcrt_gateways[$num]['function'] = 'gateway_my_new_gateway';
This is the name of the function called on execution (usually the function that talks to your gateway).
Naming convention is gateway_ followed by the internal name of your gateway, in this example my_new_gateway.
$nzshpcrt_gateways[$num]['form'] = "form_my_new_gateway";
This is the name of the function that returns a form within the admin section where you would provide information regarding your gateway and account.
Naming convention is form_ followed by the internal name of your gateway, in this example my_new_gateway.
$nzshpcrt_gateways[$num]['submit_function'] = "submit_my_new_gateway";
This is the name of the function used to validate and submit your form fields from the previous function (form_my_new_gateway)
Naming convention is submit_ followed by the internal name of your gateway, in this example my_new_gateway.
From the above code we can assume we will require at least 3 functions:
- gateway_my_new_gateway($seperator, $sessionid)
- form_my_new_gateway()
- submit_my_new_gateway()
These three functions are the bare minimum needed to create a gateway, you can add more functions to allow cleaner more module code but they must all reside in the one file.
Functions
Starting with the easiest one:
form_my_new_gateway()
This function receives no parameters and returns a string with form elements ($output) within <tr> <td> </tr> <td>
tags, this is to make sure the fields appear within the admin section inside the table.
Note: There is no need for a <form> tag, as that is automatically done within the Wp-E-Commerce Plugin.