[ Index ]
 

Code source de osCommerce 2.2ms2-060817

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/catalog/includes/modules/payment/ -> paypal.php (source)

   1  <?php
   2  /*
   3    $Id: paypal.php,v 1.39 2003/01/29 19:57:15 hpdl Exp $
   4  
   5    osCommerce, Open Source E-Commerce Solutions
   6    http://www.oscommerce.com
   7  
   8    Copyright (c) 2003 osCommerce
   9  
  10    Released under the GNU General Public License
  11  */
  12  
  13    class paypal {
  14      var $code, $title, $description, $enabled;
  15  
  16  // class constructor
  17      function paypal() {
  18        global $order;
  19  
  20        $this->code = 'paypal';
  21        $this->title = MODULE_PAYMENT_PAYPAL_TEXT_TITLE;
  22        $this->description = MODULE_PAYMENT_PAYPAL_TEXT_DESCRIPTION;
  23        $this->sort_order = MODULE_PAYMENT_PAYPAL_SORT_ORDER;
  24        $this->enabled = ((MODULE_PAYMENT_PAYPAL_STATUS == 'True') ? true : false);
  25  
  26        if ((int)MODULE_PAYMENT_PAYPAL_ORDER_STATUS_ID > 0) {
  27          $this->order_status = MODULE_PAYMENT_PAYPAL_ORDER_STATUS_ID;
  28        }
  29  
  30        if (is_object($order)) $this->update_status();
  31  
  32        $this->form_action_url = 'https://secure.paypal.com/cgi-bin/webscr';
  33      }
  34  
  35  // class methods
  36      function update_status() {
  37        global $order;
  38  
  39        if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_PAYPAL_ZONE > 0) ) {
  40          $check_flag = false;
  41          $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_PAYPAL_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");
  42          while ($check = tep_db_fetch_array($check_query)) {
  43            if ($check['zone_id'] < 1) {
  44              $check_flag = true;
  45              break;
  46            } elseif ($check['zone_id'] == $order->billing['zone_id']) {
  47              $check_flag = true;
  48              break;
  49            }
  50          }
  51  
  52          if ($check_flag == false) {
  53            $this->enabled = false;
  54          }
  55        }
  56      }
  57  
  58      function javascript_validation() {
  59        return false;
  60      }
  61  
  62      function selection() {
  63        return array('id' => $this->code,
  64                     'module' => $this->title);
  65      }
  66  
  67      function pre_confirmation_check() {
  68        return false;
  69      }
  70  
  71      function confirmation() {
  72        return false;
  73      }
  74  
  75      function process_button() {
  76        global $order, $currencies, $currency;
  77  
  78        if (MODULE_PAYMENT_PAYPAL_CURRENCY == 'Selected Currency') {
  79          $my_currency = $currency;
  80        } else {
  81          $my_currency = substr(MODULE_PAYMENT_PAYPAL_CURRENCY, 5);
  82        }
  83        if (!in_array($my_currency, array('CAD', 'EUR', 'GBP', 'JPY', 'USD'))) {
  84          $my_currency = 'USD';
  85        }
  86        $process_button_string = tep_draw_hidden_field('cmd', '_xclick') .
  87                                 tep_draw_hidden_field('business', MODULE_PAYMENT_PAYPAL_ID) .
  88                                 tep_draw_hidden_field('item_name', STORE_NAME) .
  89                                 tep_draw_hidden_field('amount', number_format(($order->info['total'] - $order->info['shipping_cost']) * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency))) .
  90                                 tep_draw_hidden_field('shipping', number_format($order->info['shipping_cost'] * $currencies->get_value($my_currency), $currencies->get_decimal_places($my_currency))) .
  91                                 tep_draw_hidden_field('currency_code', $my_currency) .
  92                                 tep_draw_hidden_field('return', tep_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL')) .
  93                                 tep_draw_hidden_field('cancel_return', tep_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
  94  
  95        return $process_button_string;
  96      }
  97  
  98      function before_process() {
  99        return false;
 100      }
 101  
 102      function after_process() {
 103        return false;
 104      }
 105  
 106      function output_error() {
 107        return false;
 108      }
 109  
 110      function check() {
 111        if (!isset($this->_check)) {
 112          $check_query = tep_db_query("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_PAYPAL_STATUS'");
 113          $this->_check = tep_db_num_rows($check_query);
 114        }
 115        return $this->_check;
 116      }
 117  
 118      function install() {
 119        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 ('Enable PayPal Module', 'MODULE_PAYMENT_PAYPAL_STATUS', 'True', 'Do you want to accept PayPal payments?', '6', '3', 'tep_cfg_select_option(array(\'True\', \'False\'), ', now())");
 120        tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('E-Mail Address', 'MODULE_PAYMENT_PAYPAL_ID', 'you@yourbusiness.com', 'The e-mail address to use for the PayPal service', '6', '4', now())");
 121        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 ('Transaction Currency', 'MODULE_PAYMENT_PAYPAL_CURRENCY', 'Selected Currency', 'The currency to use for credit card transactions', '6', '6', 'tep_cfg_select_option(array(\'Selected Currency\',\'Only USD\',\'Only CAD\',\'Only EUR\',\'Only GBP\',\'Only JPY\'), ', now())");
 122        tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) values ('Sort order of display.', 'MODULE_PAYMENT_PAYPAL_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '0', now())");
 123        tep_db_query("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) values ('Payment Zone', 'MODULE_PAYMENT_PAYPAL_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '2', 'tep_get_zone_class_title', 'tep_cfg_pull_down_zone_classes(', now())");
 124        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 ('Set Order Status', 'MODULE_PAYMENT_PAYPAL_ORDER_STATUS_ID', '0', 'Set the status of orders made with this payment module to this value', '6', '0', 'tep_cfg_pull_down_order_statuses(', 'tep_get_order_status_name', now())");
 125      }
 126  
 127      function remove() {
 128        tep_db_query("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
 129      }
 130  
 131      function keys() {
 132        return array('MODULE_PAYMENT_PAYPAL_STATUS', 'MODULE_PAYMENT_PAYPAL_ID', 'MODULE_PAYMENT_PAYPAL_CURRENCY', 'MODULE_PAYMENT_PAYPAL_ZONE', 'MODULE_PAYMENT_PAYPAL_ORDER_STATUS_ID', 'MODULE_PAYMENT_PAYPAL_SORT_ORDER');
 133      }
 134    }
 135  ?>


Généré le : Mon Nov 26 19:48:25 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics