Installing New PayPal module (Latest API 2.0) for osCommerce Version 2.2 Manually
Although osCommerce 4.x is now available, many shop owners continue to use osCommerce 2.2. To support these systems, the new PayPal module (with Express and APM – Alternative Payment Method options) has been adapted to work with osCommerce 2.
Start with the video for a quick introduction to the installation process.
Read the manual below for step-by-step guidance.
1) Backup Customized Files
If you have customized any of the following files, create a backup before proceeding:
admin/modules.phpincludes/column_right.phpincludes/classes/payment.phplogin.php
shopping_cart.php
For example, if you have SSH access, you can run:
tar -cpzf `date +%y%m%d%H%M`_paypal_rest_bk.tar.gz admin/modules.php includes/column_right.php includes/classes/payment.php login.php shopping_cart.php
2) Download and Upload Module Files
1. Download the PayPal module package:
https://oscommerce.com/pub/osc22_customized_paypal_rest.zip
2. Unzip the archive into a local folder.
3. Upload the contents of the new_to_upload folder into your website’s public_html directory using your FTP client.
4. Use the files in the to_modify folder as references. Compare them with your existing files using the included *_compare.php scripts or your preferred file comparison tool.
5. Read the installation instructions in the included install.txt file.
3) Set Permissions
Set write permissions for the following folders:
ext/modules/payment/runtime/logs
ext/modules/payment/runtime/auth.cache
Note: Direct access to these folders must be denied. An .htaccess file is included in the runtime folder. If you use a custom web server configuration, update its settings accordingly.
Now we can start editing 5 core files that were mentioned in this manual above.
4) Modify Core Files
The following modifications must be applied manually.
1. admin/modules.php
- About line 95 Find:
<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
- Replace with:
<td class="pageHeading" align="right"><?php
///paypal_rest
$pp_quick_setup = '';
if ($set=='payment') {
$pp_quick_setup = '<div id="installPPP" style="display:none; float:right;"><span class=""><a id="tdb1" href="javascript:void();" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only ui-priority-primary" role="button" aria-disabled="false"><span class="ui-button-text">' . ADD_PAYPAL . '</span></a></span>'
. '</div>';
$pp_quick_setup .= '
<link rel="stylesheet" type="text/css" href="' . HTTPS_CATALOG_SERVER . DIR_WS_CATALOG . 'ext/jquery/ui/redmond/jquery-ui-1.10.4.min.css">
<script type="text/javascript" src="' . HTTPS_CATALOG_SERVER . DIR_WS_CATALOG . 'ext/jquery/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="' . HTTPS_CATALOG_SERVER . DIR_WS_CATALOG . 'ext/jquery/ui/jquery-ui-1.10.4.min.js"></script>
';
echo $pp_quick_setup ;
include_once(DIR_FS_ADMIN . 'ext' . DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR . 'payment' . DIRECTORY_SEPARATOR . 'paypal_rest' . DIRECTORY_SEPARATOR . 'ppp_js.php');
}
///paypal_rest EOF
echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>
The other editing actions described below should be completed in the similar way as shown on the screenshots above.
2. includes/column_right.php
- About line 13 Find:
require(DIR_WS_BOXES . 'shopping_cart.php');
- Insert after:
///paypal_rest require(DIR_WS_BOXES . 'paypal_rest.php'); ///paypal_rest EOF
3. includes/classes/payment.php (3 chunks)
a) About line 33 Find:
$include_modules[] = array('class' => $class, 'file' => $value);
Insert after:
/// paypal_rest
if ($class == 'paypal_rest' && substr($module, 0, strlen($class)) == $class) {
$this->selected_module = $class;
}
/// paypal_rest EOF
b) About line 134 (141 after insert lines above), find
if (is_array($selection)) $selection_array[] = $selection;
Replace with:
/// paypal_rest
//if (is_array($selection)) $selection_array[] = $selection;
if (is_array($selection)) {
if (isset($selection['id'])) {
$selection_array[] = $selection;
} else {
$selection_array = array_merge($selection_array, $selection);
}
}
/// paypal_rest EOF
c) About line 142 (156 after insertion), find:
function pre_confirmation_check() {
Insert before:
/// paypal_rest (from osc23)
function checkout_initialization_method() {
$initialize_array = array();
if (is_array($this->modules)) {
reset($this->modules);
while (list(, $value) = each($this->modules)) {
$class = substr($value, 0, strrpos($value, '.'));
if ($GLOBALS[$class]->enabled && method_exists($GLOBALS[$class], 'checkout_initialization_method')) {
$initialize_array[] = $GLOBALS[$class]->checkout_initialization_method();
}
}
}
return $initialize_array;
}
/// paypal_rest EOF
4. login.php
- about line 214 Find:
</table></form></td> <!-- body_text_eof //-->
Insert before:
<?php
////paypal_rest
@include('ext/modules/payment/paypal_rest/quick_checkout.php');
////paypal_rest EOF
?>
5. shopping_cart.php
- About line 205 Find:
} else {
?>
<tr>
<td align="center" class="main"><?php new infoBox(array(array('text' => TEXT_CART_EMPTY))); ?
></td>
Insert before:
////paypal_rest
@include('ext/modules/payment/paypal_rest/quick_checkout.php');
////paypal_rest EOF
5) Configure PayPal Module
- Log in to the Admin area of your website.
- Navigate to Modules → Payment.
- Click the PayPal Quick Setup button to configure the new PayPal module.