class_gw_paypal.php

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

PHP
580
字号
			if ( ! GW_TEST_MODE_ON )			{				$this->error = 'not_valid';				return array( 'verified' => FALSE );			}		}				//--------------------------------------		// Fix ticket: #56264 Second POST - we can ignore		//--------------------------------------				if ( ! $_POST['txn_id'] and $_POST['txn_type'] == 'subscr_signup' )		{			exit();		}				//--------------------------------------		// Populate return array		//--------------------------------------				list( $cur_sub_id, ) = explode( 'x', trim($_POST['invoice']) );			    $return = array( 'currency_code'      => $_POST['mc_currency'],						 'payment_amount'     => $_POST['mc_gross'],						 'member_unique_id'   => intval($_POST['custom']),						 'purchase_package_id'=> intval($_POST['item_number']),						 'current_package_id' => intval($cur_sub_id),						 'verified'           => TRUE,						 'subscription_id'    => $_POST['subscr_id'],						 'transaction_id'     => $_POST['txn_id'] );				//--------------------------------------		// Sort out payment status		//--------------------------------------				if ( $_POST['payment_status'] == 'Refunded' OR $_POST['txn_type'] == 'subscr_cancel' )		{			$return['payment_status'] = 'REFUND';		}		else if ( strstr( $_POST['txn_type'], 'subscr_' ) )		{			$return['payment_status'] = 'RECURRING';		}		else if ( $_POST['txn_type'] == 'web_accept' )		{			$return['payment_status'] = 'ONEOFF';		}		else		{			$return['payment_status'] = '';		}				//--------------------------------------		// 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 ( $_POST['payment_status'] == 'Completed' )		{			//--------------------------------------			// Check amount..			//--------------------------------------						if ( $_POST['mc_gross'] == $total_package_cost )			{				//--------------------------------------				// Paid correct amount				//--------------------------------------								$return['amount_paid'] = $_POST['mc_gross'];				$return['state']       = 'PAID';			}			else			{				if ( $upgrade )				{						//--------------------------------------					// Upgrading....					//--------------------------------------										if ( $_POST['mc_gross'] == $balance_to_pay )					{						$return['amount_paid'] = $_POST['mc_gross'];						$return['state']       = 'PAID';					}									}				else				{					//--------------------------------------					// Incorrect amount					//--------------------------------------										$this->error = "Wrong payment amount. Looking for {$total_package_cost}, got {$_POST['mc_gross']}";					return;				}			}					}		else if ( $_POST['payment_status'] == 'Pending' )		{			//-----------------------			// Failed...			//-----------------------						$return['state'] = 'PENDING';		}		else		{			//-----------------------			// End of subscription			//-----------------------						$return['state'] = 'FAILED';		}				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();				//--------------------------------------		// Sign up		//--------------------------------------				if ( $_POST['txn_type'] == 'subscr_signup' OR $_POST['txn_type'] == 'subscr_payment' )		{			//--------------------------------------			// Check amount..			//--------------------------------------						if ( $_POST['amount1'] )			{				//--------------------------------------				// First period, get amount.				//--------------------------------------								if ( $balance_to_pay != $_POST['amount1'] )				{					$this->error = "Wrong upgrade subs amount. Looking for $balance_to_pay, got {$_POST['amount1']}";					return;				}								$return['amount_paid']  = $_POST['amount1'];				$return['state']        = 'PAID';			}			else if ( $_POST['amount3'] )			{				//--------------------------------------				// Real subscription				//--------------------------------------								if ( $total_package_cost != $_POST['amount3'] )				{					$this->error = "Wrong upgrade subs amount. Looking for {$total_package_cost}, got {$_POST['amount3']}";					return;				}								$return['amount_paid']  = $total_package_cost;				$return['state']        = 'PAID';			}			else			{				//--------------------------------------				// If all else fails..				//--------------------------------------								if ( $total_package_cost != $_POST['mc_gross'] AND $_POST['mc_gross'] != $balance_to_pay )				{					$this->error = "Wrong upgrade subs amount. Looking for {$total_package_cost}, got {$_POST['mc_gross']}";					return;				}								$return['amount_paid']  = $_POST['mc_gross'];				$return['state']        = 'PAID';			}					}		else if ( $_POST['txn_type'] == 'subscr_failed' )		{			//--------------------------------------			// Failed...			//--------------------------------------						$return['state'] = 'FAILED';		}		else if ( $_POST['txn_type'] == 'subscr_cancel' )		{			//--------------------------------------			// Dead...			//--------------------------------------						$return['state'] = 'DEAD';		}		else if ( $_POST['txn_type'] == 'subscr_eot' )		{			//--------------------------------------			// End of subscription			//--------------------------------------						$return['state'] = 'DEAD';		}				return $return;	}			//---------------------------------------	// 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;		}		} ?>

⌨️ 快捷键说明

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