class_gw_authorizenet.php

来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 443 行 · 第 1/2 页

PHP
443
字号
		//--------------------------------------				if ( GW_TEST_MODE_ON )		{			if ( ! is_array( $_POST ) or ! count( $_POST ) )			{				$_POST = $_GET;			}		}				//--------------------------------------		// Check hash		//--------------------------------------				list( $fp_time, $fp_seq, $currency_code, )             = explode( '-', $_REQUEST['x_invoice_num'] );		list( $purchase_package_id, $member_id, $cur_sub_id, ) = explode( 'x', trim($_REQUEST['x_cust_id']) );				$in_hash          = $_REQUEST['x_md5_hash'] ? $_REQUEST['x_md5_hash'] : $_REQUEST['x_MD5_Hash'];		$txn_key          = $extra['company_email'];								 		$fp_hash          = $this->my_calculatefp( $extra['vendor_id'], $txn_key, $_REQUEST['x_amount'], intval($fp_seq), intval($fp_time), trim($currency_code) );		$an_response_code = $_REQUEST['x_response_code'];		$test_hash        = strtoupper( md5( $extra['vendor_id'] . $_REQUEST['x_trans_id'] . $_REQUEST['x_amount']) );				if ( $in_hash != $test_hash )		{			$an_response_code = 0;		}				//--------------------------------------		// Check...		//--------------------------------------				if ( $an_response_code != 1 AND ! GW_TEST_MODE_ON )		{			$this->error = 'not_valid';			return array( 'verified' => FALSE );		}				//--------------------------------------		// Populate return array		//--------------------------------------							    $return = array( 'currency_code'      => trim($currency_code),						 'payment_amount'     => $_REQUEST['x_amount'],						 'member_unique_id'   => intval($member_id),						 'purchase_package_id'=> intval($purchase_package_id),						 'current_package_id' => intval($cur_sub_id),						 'verified'           => TRUE,						 'subscription_id'    => '0-'.intval($member_id),						 'transaction_id'     => $_REQUEST['x_trans_id'] );				//--------------------------------------		// Sort out payment status		//--------------------------------------				$return['payment_status'] = 'ONEOFF';				//--------------------------------------		// Pass back to handler		//--------------------------------------				return $return;	}		/*-------------------------------------------------------------------------*/	// Process recurring payment check	// Return: array( 'amount_paid', 'state' [ PAID, DEAD, FAILED, PENDING ]	/*-------------------------------------------------------------------------*/		function gw_do_normal_payment_check( $balance_to_pay=0, $total_package_cost=0, $upgrade=0 )	{		$this->gateway->error = "";				//--------------------------------------		// INIT		//--------------------------------------				$return = array();				//--------------------------------------		// Completed		//--------------------------------------			if ( $upgrade )		{			//--------------------------------------			// Completed			//--------------------------------------					$return['amount_paid'] = $balance_to_pay;			$return['state']       = 'PAID';		}		else		{			//--------------------------------------			// Completed			//--------------------------------------					$return['amount_paid'] = $total_package_cost;			$return['state']       = 'PAID';		}				return $return;	}		/*-------------------------------------------------------------------------*/	// Process recurring payment check	// Return: array( 'amount_paid', 'state' [ PAID, DEAD, FAILED, PENDING ]	/*-------------------------------------------------------------------------*/		function gw_do_recurring_payment_check( $balance_to_pay=0, $total_package_cost=0 )	{		$this->gateway->error = "";				//--------------------------------------		// INIT		//--------------------------------------				$return = array();				return $return;	}		/*-------------------------------------------------------------------------*/	// INSTALL Gateway...	/*-------------------------------------------------------------------------*/		function install_gateway()	{		//--------------------------------------		// DB queries		//--------------------------------------				$this->db_info = array( 'human_title'         => 'Authorize.net',								'human_desc'		  => 'All major credit cards accepted',								'module_name'         => $this->i_am,								'allow_creditcards'   => 1,								'allow_auto_validate' => 1,								'default_currency'    => 'USD' );							   				$this->install_lang = array( 'gw_'.$this->i_am => 'Click the button below to complete this order via our secure online payment page.' );	}		//---------------------------------------	// Return ACP Package  Variables	//	// Returns names for the package custom	// fields, etc	//---------------------------------------		function acp_return_package_variables()	{			$return = array(						  'subextra_custom_1' => array( 'used' => 0, 'varname' => '' ),						  'subextra_custom_2' => array( 'used' => 0, 'varname' => '' ),						  'subextra_custom_3' => array( 'used' => 0, 'varname' => '' ),						  'subextra_custom_4' => array( 'used' => 0, 'varname' => '' ),						  'subextra_custom_5' => array( 'used' => 0, 'varname' => '' ),					   );					   		return $return;		}		//---------------------------------------	// Return ACP Method Variables	//	// Returns names for the package custom	// fields, etc	//---------------------------------------		function acp_return_method_variables()	{			$return = array(						  'submethod_custom_1' => array( 'used' => 0, 'varname' => '' ),						  'submethod_custom_2' => array( 'used' => 0, 'varname' => '' ),						  'submethod_custom_3' => array( 'used' => 0, 'varname' => '' ),						  'submethod_custom_4' => array( 'used' => 0, 'varname' => '' ),						  'submethod_custom_5' => array( 'used' => 0, 'varname' => '' ),					   );					   		return $return;		}		function my_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)));	}		function my_calculatefp($loginid, $txnkey, $amount, $sequence, $tstamp, $currency = "")	{  		return $this->my_hmac($txnkey, $loginid . "^" . $sequence . "^" . $tstamp . "^" . $amount . "^" . $currency);	}		} ?>

⌨️ 快捷键说明

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