pm2checkout.php

来自「this the oscommerce 3.0 aplha 4」· PHP 代码 · 共 264 行 · 第 1/2 页

PHP
264
字号
<?php/*  $Id: pm2checkout.php 1498 2007-03-29 14:04:50Z hpdl $  osCommerce, Open Source E-Commerce Solutions  http://www.oscommerce.com  Copyright (c) 2006 osCommerce  This program is free software; you can redistribute it and/or modify  it under the terms of the GNU General Public License v2 (1991)  as published by the Free Software Foundation.*/  class osC_Payment_pm2checkout extends osC_Payment {    var $_title,        $_code = 'pm2checkout',        $_author_name = 'osCommerce',        $_author_www = 'http://www.oscommerce.com',        $_status = false,        $_sort_order;    function osC_Payment_pm2checkout() {      global $osC_Language;      $this->_title = $osC_Language->get('payment_2checkout_title');      $this->_description = $osC_Language->get('payment_2checkout_description');      $this->_status = (defined('MODULE_PAYMENT_2CHECKOUT_STATUS') && (MODULE_PAYMENT_2CHECKOUT_STATUS == 'True') ? true : false);      $this->_sort_order = (defined('MODULE_PAYMENT_2CHECKOUT_SORT_ORDER') ? MODULE_PAYMENT_2CHECKOUT_SORT_ORDER : null);      if (defined('MODULE_PAYMENT_2CHECKOUT_STATUS')) {        $this->initialize();      }    }    function initialize() {      global $order;      if ((int)MODULE_PAYMENT_2CHECKOUT_ORDER_STATUS_ID > 0) {        $this->order_status = MODULE_PAYMENT_2CHECKOUT_ORDER_STATUS_ID;      }      if (is_object($order)) $this->update_status();      $this->form_action_url = 'https://www.2checkout.com/cgi-bin/Abuyers/purchase.2c';    }    function update_status() {      global $osC_Database, $order;      if ( ($this->_status === true) && ((int)MODULE_PAYMENT_2CHECKOUT_ZONE > 0) ) {        $check_flag = false;        $Qcheck = $osC_Database->query('select zone_id from :table_zones_to_geo_zones where geo_zone_id = :geo_zone_id and zone_country_id = :zone_country_id order by zone_id');        $Qcheck->bindTable(':table_zones_to_geo_zones', TABLE_ZONES_TO_GEO_ZONES);        $Qcheck->bindInt(':geo_zone_id', MODULE_PAYMENT_2CHECKOUT_ZONE);        $Qcheck->bindInt(':zone_country_id', $order->billing['country']['id']);        $Qcheck->execute();        while ($Qcheck->next()) {          if ($Qcheck->valueInt('zone_id') < 1) {            $check_flag = true;            break;          } elseif ($Qcheck->valueInt('zone_id') == $order->billing['zone_id']) {            $check_flag = true;            break;          }        }        if ($check_flag == false) {          $this->_status = false;        }      }    }    function getJavascriptBlock() {      global $osC_Language;      $js = '  if (payment_value == "' . $this->_code . '") {' . "\n" .            '    var cc_number = document.checkout_payment.pm_2checkout_cc_number.value;' . "\n" .            '    if (cc_number == "" || cc_number.length < ' . CC_NUMBER_MIN_LENGTH . ') {' . "\n" .            '      error_message = error_message + "' . sprintf($osC_Language->get('payment_2checkout_js_credit_card_number'), CC_NUMBER_MIN_LENGTH) . '\n";' . "\n" .            '      error = 1;' . "\n" .            '    }' . "\n" .            '  }' . "\n";      return $js;    }    function selection() {      global $osC_Database, $osC_Language, $order;      for ($i=1; $i < 13; $i++) {        $expires_month[] = array('id' => sprintf('%02d', $i), 'text' => strftime('%B',mktime(0,0,0,$i,1,2000)));      }      $today = getdate();      for ($i=$today['year']; $i < $today['year']+10; $i++) {        $expires_year[] = array('id' => strftime('%y',mktime(0,0,0,1,1,$i)), 'text' => strftime('%Y',mktime(0,0,0,1,1,$i)));      }      $Qcredit_cards = $osC_Database->query('select credit_card_name, credit_card_code from :table_credit_cards where credit_card_status = :credit_card_status');      $Qcredit_cards->bindRaw(':table_credit_cards', TABLE_CREDIT_CARDS);      $Qcredit_cards->bindInt(':credit_card_status', '1');      $Qcredit_cards->setCache('credit-cards');      $Qcredit_cards->execute();      while ($Qcredit_cards->next()) {        $credit_cards[] = array('id' => $Qcredit_cards->value('credit_card_code'), 'text' => $Qcredit_cards->value('credit_card_name'));      }      $Qcredit_cards->freeResult();      $selection = array('id' => $this->_code,                         'module' => $this->_title,                         'fields' => array(array('title' => $osC_Language->get('payment_2checkout_credit_card_owner_first_name'),                                                 'field' => osc_draw_input_field('pm_2checkout_cc_owner_firstname', $order->billing['firstname'])),                                           array('title' => $osC_Language->get('payment_2checkout_credit_card_owner_last_name'),                                                 'field' => osc_draw_input_field('pm_2checkout_cc_owner_lastname', $order->billing['lastname'])),                                           array('title' => $osC_Language->get('payment_2checkout_credit_cart_type'),                                                 'field' => osc_draw_pull_down_menu('pm_2checkout_cc_type', $credit_cards)),                                           array('title' => $osC_Language->get('payment_2checkout_credit_card_number'),                                                 'field' => osc_draw_input_field('pm_2checkout_cc_number')),                                           array('title' => $osC_Language->get('payment_2checkout_credit_card_expiry_date'),                                                 'field' => osc_draw_pull_down_menu('pm_2checkout_cc_expires_month', $expires_month) . '&nbsp;' . osc_draw_pull_down_menu('pm_2checkout_cc_expires_year', $expires_year)),                                           array('title' => $osC_Language->get('payment_2checkout_credit_card_checknumber'),                                                 'field' => osc_draw_input_field('pm_2checkout_cc_cvv', null, 'size="4" maxlength="4"') . '&nbsp;<small>' . $osC_Language->get('payment_2checkout_credit_card_checknumber_location') . '</small>')));      return $selection;    }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?