⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 authorizenet.php

📁 每个RFC 3261信息头有一个相应的存取标识. 但是,许多信息头拥有同样的形式。 例如。To和From的信息头都是由显示名和一个URI组成。 To和From信息头用来管理与处理NameAddr实例的
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php/*  $Id: authorizenet.php,v 1.48 2003/04/10 21:42:30 project3000 Exp $  osCommerce, Open Source E-Commerce Solutions  http://www.oscommerce.com  Copyright (c) 2003 osCommerce  Released under the GNU General Public License*/  class authorizenet {    var $code, $title, $description, $enabled;// class constructor    function authorizenet() {      global $order;      $this->code = 'authorizenet';      $this->title = MODULE_PAYMENT_AUTHORIZENET_TEXT_TITLE;      $this->description = MODULE_PAYMENT_AUTHORIZENET_TEXT_DESCRIPTION;      $this->enabled = ((MODULE_PAYMENT_AUTHORIZENET_STATUS == 'True') ? true : false);      $this->sort_order = MODULE_PAYMENT_AUTHORIZENET_SORT_ORDER;      if ((int)MODULE_PAYMENT_AUTHORIZENET_ORDER_STATUS_ID > 0) {        $this->order_status = MODULE_PAYMENT_AUTHORIZENET_ORDER_STATUS_ID;      }      if (is_object($order)) $this->update_status();      $this->form_action_url = 'https://secure.authorize.net/gateway/transact.dll';    }// Authorize.net utility functions// DISCLAIMER://     This code is distributed in the hope that it will be useful, but without any warranty; //     without even the implied warranty of merchantability or fitness for a particular purpose.// Main Interfaces://// function InsertFP ($loginid, $txnkey, $amount, $sequence) - Insert HTML form elements required for SIM// function CalculateFP ($loginid, $txnkey, $amount, $sequence, $tstamp) - Returns Fingerprint.// compute HMAC-MD5// Uses PHP mhash extension. Pl sure to enable the extension// function hmac ($key, $data) {//   return (bin2hex (mhash(MHASH_MD5, $data, $key)));//}// Thanks is lance from http://www.php.net/manual/en/function.mhash.php//lance_rushing at hot* spamfree *mail dot com//27-Nov-2002 09:36 // //Want to Create a md5 HMAC, but don't have hmash installed?////Use this:function hmac ($key, $data){   // RFC 2104 HMAC implementation for php.   // Creates an md5 HMAC.   // Eliminates the need to install mhash to compute a HMAC   // Hacked by Lance Rushing   $b = 64; // byte length for md5   if (strlen($key) > $b) {       $key = pack("H*",md5($key));   }   $key  = str_pad($key, $b, chr(0x00));   $ipad = str_pad('', $b, chr(0x36));   $opad = str_pad('', $b, chr(0x5c));   $k_ipad = $key ^ $ipad ;   $k_opad = $key ^ $opad;   return md5($k_opad  . pack("H*",md5($k_ipad . $data)));}// end code from lance (resume authorize.net code)// Calculate and return fingerprint// Use when you need control on the HTML outputfunction CalculateFP ($loginid, $txnkey, $amount, $sequence, $tstamp, $currency = "") {  return ($this->hmac ($txnkey, $loginid . "^" . $sequence . "^" . $tstamp . "^" . $amount . "^" . $currency));}// Inserts the hidden variables in the HTML FORM required for SIM// Invokes hmac function to calculate fingerprint.function InsertFP ($loginid, $txnkey, $amount, $sequence, $currency = "") {  $tstamp = time ();  $fingerprint = $this->hmac ($txnkey, $loginid . "^" . $sequence . "^" . $tstamp . "^" . $amount . "^" . $currency);  $str = tep_draw_hidden_field('x_fp_sequence', $sequence) .         tep_draw_hidden_field('x_fp_timestamp', $tstamp) .         tep_draw_hidden_field('x_fp_hash', $fingerprint);  return $str;}// end authorize.net code// class methods    function update_status() {      global $order;      if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_AUTHORIZENET_ZONE > 0) ) {        $check_flag = false;        $check_query = tep_db_query("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . MODULE_PAYMENT_AUTHORIZENET_ZONE . "' and zone_country_id = '" . $order->billing['country']['id'] . "' order by zone_id");        while ($check = tep_db_fetch_array($check_query)) {          if ($check['zone_id'] < 1) {            $check_flag = true;            break;          } elseif ($check['zone_id'] == $order->billing['zone_id']) {            $check_flag = true;            break;          }        }        if ($check_flag == false) {          $this->enabled = false;        }      }    }    function javascript_validation() {      $js = '  if (payment_value == "' . $this->code . '") {' . "\n" .            '    var cc_owner = document.checkout_payment.authorizenet_cc_owner.value;' . "\n" .            '    var cc_number = document.checkout_payment.authorizenet_cc_number.value;' . "\n" .            '    if (cc_owner == "" || cc_owner.length < ' . CC_OWNER_MIN_LENGTH . ') {' . "\n" .            '      error_message = error_message + "' . MODULE_PAYMENT_AUTHORIZENET_TEXT_JS_CC_OWNER . '";' . "\n" .            '      error = 1;' . "\n" .            '    }' . "\n" .            '    if (cc_number == "" || cc_number.length < ' . CC_NUMBER_MIN_LENGTH . ') {' . "\n" .            '      error_message = error_message + "' . MODULE_PAYMENT_AUTHORIZENET_TEXT_JS_CC_NUMBER . '";' . "\n" .            '      error = 1;' . "\n" .            '    }' . "\n" .            '  }' . "\n";      return $js;    }    function selection() {      global $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)));      }      $selection = array('id' => $this->code,

⌨️ 快捷键说明

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