Installing New PayPal module (Latest API 2.0) for osCommerce Version 2.2 Manually

From osCommerce Wiki
Jump to navigation Jump to search

Though we released the new osCommerce 4.x version quite a lot of shop owners keep using the systems based on osCommerce 2. Therefore, we adjusted the new PayPal module supporting Express and APM (Alternative Payment Method) methods for it to work with the systems based on osCommerce 2.


If you customized any of

admin/modules.php

includes/column_right.php

includes/classes/payment.php

login.php

shopping_cart.php


backup these files.


For example if you have SSH access 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


Use the following link to download the zip.


https://oscommerce.com/pub/osc22_customized_paypal_rest.zip

Image 1040.png


Unzip it to the required folder.

Image 1039.png
Image 1038.png


Upload the content of the new_to_upload folder to the public_html folder only using FTP client you normally use. Regarding to_modify folder you can use *_compare.php files from this folder for reference and/or compare tools as well as read the installation instructions in the install.txt file.

Image 1037.png
Image 1036.png


Set write permissions to folders:

ext/modules/payment/runtime/logs

ext/modules/payment/runtime/auth.cache

Image 1035.png
Image 1034.png


Note: Direct access to files in the folders should be denied. There is appropriate .htaccess file in the runtime folder. If you have custom web server configuration please update its settings accordingly.


Now we can start editing 5 core files that were mentioned in this manual above.


1) admin/modules.php (1chunk)

about line 95 Find

<td class="pageHeading" align="right"><?php echo tep_draw_separator('pixel_trans.gif', HEADING_IMAGE_WIDTH, HEADING_IMAGE_HEIGHT); ?></td>

and 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>
Image 1033.png
Image 1041.png
Image 1042.png
Image 1043.png


The other editing actions described below should be completed in the similar way as shown on the screenshots above.


2) includes/column_right.php (1chunk)


about line 13 Find

require(DIR_WS_BOXES . 'shopping_cart.php');


and 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);


and 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;

and 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) find

    function pre_confirmation_check() {

and 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 (1 chunk)

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 (1 chunk)

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

Go to the admin area of your website, click on Modules and Payment tabs and then on PayPal Quick Setup button to configure the new PayPal module.

Image 1044.png


See the links to the videos below demonstrating the new PayPal module integration with systems based on osCommerce 2.

https://www.youtube.com/playlist?list=PLHN7KfrDE8gMtPCprNISvqK2ZWTQdFVVH