psigate.php

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

PHP
331
字号
<?php/*  $Id: psigate.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_psigate extends osC_Payment {    var $_title,        $_code = 'psigate',        $_author_name = 'osCommerce',        $_author_www = 'http://www.oscommerce.com',        $_status = false,        $_sort_order;    function osC_Payment_psigate() {      global $osC_Language;      $this->_title = $osC_Language->get('payment_psigate_title');      $this->_description = $osC_Language->get('payment_psigate_description');      $this->_status = (defined('MODULE_PAYMENT_PSIGATE_STATUS') && (MODULE_PAYMENT_PSIGATE_STATUS == 'True') ? true : false);      $this->_sort_order = (defined('MODULE_PAYMENT_PSIGATE_SORT_ORDER') ? MODULE_PAYMENT_PSIGATE_SORT_ORDER : null);      if (defined('MODULE_PAYMENT_PSIGATE_STATUS')) {        $this->initialize();      }    }    function initialize() {      global $order;      if ((int)MODULE_PAYMENT_PSIGATE_ORDER_STATUS_ID > 0) {        $this->order_status = MODULE_PAYMENT_PSIGATE_ORDER_STATUS_ID;      }      if (is_object($order)) $this->update_status();      $this->form_action_url = 'https://order.psigate.com/psigate.asp';    }    function update_status() {      global $osC_Database, $order;      if ( ($this->_status === true) && ((int)MODULE_PAYMENT_PSIGATE_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_PSIGATE_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;      if (MODULE_PAYMENT_PSIGATE_INPUT_MODE == 'Local') {        $js = 'if (payment_value == "' . $this->_code . '") {' . "\n" .              '  var psigate_cc_number = document.checkout_payment.psigate_cc_number.value;' . "\n" .              '  if (psigate_cc_number == "" || psigate_cc_number.length < ' . CC_NUMBER_MIN_LENGTH . ') {' . "\n" .              '    error_message = error_message + "' . $osC_Language->get('payment_psigate_js_credit_card_number') . '\n";' . "\n" .              '    error = 1;' . "\n" .              '  }' . "\n" .              '}' . "\n";        return $js;      } else {        return false;      }    }    function selection() {      global $osC_Database, $osC_Language, $order;      if (MODULE_PAYMENT_PSIGATE_INPUT_MODE == 'Local') {        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_psigate_credit_card_owner'),                                                   'field' => osc_draw_input_field('psigate_cc_owner', $order->billing['firstname'] . ' ' . $order->billing['lastname'])),                                             array('title' => $osC_Language->get('payment_psigate_credit_card_type'),                                                   'field' => osc_draw_pull_down_menu('psigate_cc_type', $credit_cards)),                                             array('title' => $osC_Language->get('payment_psigate_credit_card_number'),                                                   'field' => osc_draw_input_field('psigate_cc_number')),                                             array('title' => $osC_Language->get('payment_psigate_credit_card_expiry_date'),                                                   'field' => osc_draw_pull_down_menu('psigate_cc_expires_month', $expires_month) . '&nbsp;' . osc_draw_pull_down_menu('psigate_cc_expires_year', $expires_year))));      } else {        $selection = array('id' => $this->_code,                           'module' => $this->_title);      }      return $selection;    }    function pre_confirmation_check() {      global $osC_Language, $messageStack;      if (MODULE_PAYMENT_PSIGATE_INPUT_MODE == 'Local') {        $this->_verifyData();        $this->cc_card_owner = $_POST['psigate_cc_owner'];        $this->cc_card_type = $_POST['psigate_cc_type'];        $this->cc_card_number = $_POST['psigate_cc_number'];        $this->cc_expiry_month = $_POST['psigate_cc_expires_month'];        $this->cc_expiry_year = $_POST['psigate_cc_expires_year'];      } else {        return false;      }    }    function confirmation() {      global $osC_Language, $order;      if (MODULE_PAYMENT_PSIGATE_INPUT_MODE == 'Local') {        $confirmation = array('title' => $this->_title . ': ' . $this->cc_card_type,                              'fields' => array(array('title' => $osC_Language->get('payment_psigate_credit_card_owner'),                                                      'field' => $this->cc_card_owner),                                                array('title' => $osC_Language->get('payment_psigate_credit_card_number'),                                                      'field' => substr($this->cc_card_number, 0, 4) . str_repeat('X', (strlen($this->cc_card_number) - 8)) . substr($this->cc_card_number, -4)),                                                array('title' => $osC_Language->get('payment_psigate_credit_card_expiry_date'),                                                      'field' => strftime('%B, %Y', mktime(0,0,0,$this->cc_expiry_month, 1, '20' . $this->cc_expiry_year)))));        return $confirmation;

⌨️ 快捷键说明

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