How to port Payment gateways from osCommerce
From FreeWay
In order to port Payment Gateways from osCommerce, you need to perform the following steps:
Step 1 Copy the required files:
includes/modules/payment/yourpayment.php
includes/languages/english/modules/payment/yourpayment.php
Give Write Permission to your payment file.
Step 2 Insert the line for the payment heading title, payment image in the file:
includes/modules/payment/yourpayment.php
Insert the code below inside the constructor function of your payment file:
$name = "your payment ";
$image = "";
if(MODULE_PAYMENT_[YOURPAYMENT]_DISPLAY_NAME !=
"MODULE_PAYMENT_[YOURPAYMENT]_DISPLAY_NAME")$name =
MODULE_PAYMENT_[YOURPAYMENT]_DISPLAY_NAME;
if(MODULE_PAYMENT_[YOURPAYMENT]_IMAGE !=
"MODULE_PAYMENT_[YOURPAYMENT]_IMAGE")$image =
MODULE_PAYMENT_[YOURPAYMENT]_IMAGE;
if (DIR_WS_ADMIN != "DIR_WS_ADMIN" && DIR_WS_ADMIN != "") $path = "../";
if($image != "" && file_exists($path . DIR_WS_IMAGES. $image)){
$image = '<img src="' . HTTP_SERVER. DIR_WS_HTTP_CATALOG. DIR_WS_IMAGES. $image. '"
width="103" height="33">';
} else {
$image_array = array ('.gif','.jpg','.jpeg','.png');
$image_check = true;
for($i=0;$i<sizeof($image_array);$i++){
if($image_check && $image != "" && file_exists($path . DIR_WS_IMAGES. $image. $image_array[$i])){
$image = '<img src="' . HTTP_SERVER. DIR_WS_HTTP_CATALOG. DIR_WS_IMAGES. $image.
$image_array[$i] . '" width="103" height="33">';
$image_check = false;
}}
If ($image_check) $image = "";
}
define ('MODULE_PAYMENT_[YOURPAYMENT]_TEXT_TITLE', $name . ' ' . $image);
define('MODULE_PAYMENT_[YOURPAYMENT]_TEXT_TEXT_TITLE', $name);
$this->text_title = MODULE_PAYMENT_[YOURPAYMENT]_TEXT_TEXT_TITLE;
After this line:
$this->code=’your payment’;
Step 3 Replace the lines listed below inside the function update_status():
function update_status() {
global $order;
tep_check_module_status($this,MODULE_PAYMENT_[YOURPAYMENT]_ZONE,
trim(MODULE_PAYMENT_[YOURPAYMENT]_EXCEPT_ZONE),trim(MODULE_PAYMENT_[YOURPAY
MENT]_EXCEPT_COUNTRY));
$this-
>barred=tep_check_payment_barred(trim(MODULE_PAYMENT_[YOURPAYMENT]_EXCEPT_COUNTR
Y));
}
Insert configuration install queries for Payment Display name, Payment Image, Payment except Zone and Payment except Country.
- 1. tep_db_query ("insert into " . TABLE_CONFIGURATION. " (configuration_title, configuration_key,
- configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function,
- date_added) values ('Exclude these Countries',
- 'MODULE_PAYMENT_[YOURPAYMENT]_EXCEPT_COUNTRY', , 'If countries are selected, disable this
- payment method for that countries.', '6', '3',
- 'tep_cfg_pull_down_zone_except_countries(MODULE_PAYMENT_[YOURPAYMENT]_ZONE,',
- 'tep_get_zone_except_country', now())");
- 2. tep_db_query("insert into " . TABLE_CONFIGURATION. " (configuration_title, configuration_key,
- configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function,
- date_added) values ('Exclude these Zones', 'MODULE_PAYMENT_ [YOURPAYMENT]_EXCEPT_ZONE', ,
- 'If a zone is selected, disable this payment method for that zone.', '6', '4', 'tep_cfg_pull_down_zone_classes
- (','tep_get_zone_class_title', now())");
- 3. tep_db_query ("insert into " . TABLE_CONFIGURATION. " (configuration_title, configuration_key,
- configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values
- ('Display Name', 'MODULE_PAYMENT_[YOURPAYMENT]_DISPLAY_NAME', 'your payment', 'Set the
- Display name to payment module', '6', '11', now())");
- 4. tep_db_query ("insert into " . TABLE_CONFIGURATION. " (configuration_title, configuration_key,
- configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added)
- values ('Image', 'MODULE_PAYMENT_[YOURPAYMENT]_IMAGE', 'your payment', 'Set the Image of
- payment module', '6', '12', 'tep_cfg_file_field(', now())");
Insert the Configuration key function key () keys as listed below:
MODULE_PAYMENT_[YOURPAYMENT]_EXCEPT_COUNTRY,
MODULE_PAYMENT_[YOURPAYMENT]_EXCEPT_ZONE,
5
MODULE_PAYMENT_[YOURPAYMENT]_DISPLAY_NAME,MODULE_PAYMENT_[YOURPAYMENT]_I
MAGE
return array('MODULE_PAYMENT_[YOURPAYMENT]_STATUS',
'MODULE_PAYMENT_[YOURPAYMENT]_ZONE',
'MODULE_PAYMENT_[YOURPAYMENT]_EXCEPT_ZONE',
'MODULE_PAYMENT_[YOURPAYMENT]_EXCEPT_COUNTRY',
'MODULE_PAYMENT_[YOURPAYMENT]_SORT_ORDER',
'MODULE_PAYMENT_[YOURPAYMENT]_ORDER_STATUS_ID','MODULE_PAYMENT_[YOURPAYME
NT] _DISPLAY_NAME','MODULE_PAYMENT_[YOURPAYMENT]_IMAGE');
Payment Sort order must be greater than >0 . Ensure that payment module sort order query in install function contains value >0.
Step 4 Insert the heading title configuration key inincludes/languages/englih/modules/payment/yourpayment.phplike this:
define ('MODULE_PAYMENT_[YOURPAYMENT]_TEXT_TEXT_TITLE', 'your payment');
Step 5 These steps are the same for the backend payments. Just copy this files into:
admin/includes/modules/payment/yourpayment.php and admin/includes/languages/english/modules/payment/yourpayment.php
Step 6 Now your payment gateway is ready for installation and testing.