cvs: pear /Payment_Process Process.php /Payment_Process/Process Bibit.php Common.php Dummy.php /Payment_Process/Process/Type CreditCard.php eCheck.php
[email protected] ("Philippe Jausions") Wed, 07 May 2008 01:01:03 -0000
| Newsgroups | php.pear.cvs |
|---|---|
| Message-ID | <cvsjausions1210122063@cvsserver> |
jausions Wed May 7 01:01:03 2008 UTC
Modified files:
/pear/Payment_Process Process.php
/pear/Payment_Process/Process/Type eCheck.php CreditCard.php
/pear/Payment_Process/Process Dummy.php Bibit.php Common.php
Log:
- Updated license to BSD
- PEAR CS clean up
jausions-20080507010103.txt
(text/plain, 58.8 KB)
http://cvs.php.net/viewvc.cgi/pear/Payment_Process/Process.php?r1=1.55&r2=1.56&diff_format=u Index: pear/Payment_Process/Process.php diff -u pear/Payment_Process/Process.php:1.55 pear/Payment_Process/Process.php:1.56 --- pear/Payment_Process/Process.php:1.55 Tue May 6 18:45:10 2008 +++ pear/Payment_Process/Process.php Wed May 7 01:01:03 2008 @@ -11,29 +11,29 @@ * PHP versions 4 and 5 * * LICENSE: - * + * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this + * + * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation + * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - * 3. The name of the authors may not be used to endorse or promote products + * 3. The name of the authors may not be used to endorse or promote products * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @category Payment @@ -42,24 +42,24 @@ * @author Joe Stump <[email protected]> * @copyright 1997-2008 The PHP Group * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: Process.php,v 1.55 2008/05/06 18:45:10 jausions Exp $ + * @version CVS: $Id: Process.php,v 1.56 2008/05/07 01:01:03 jausions Exp $ * @link http://pear.php.net/package/Payment_Process */ /** - * Include PEAR for error handling + * Include PEAR for error handling */ require_once 'PEAR.php'; /** - * Include Validate + * Include Validate */ require_once 'Validate.php'; /** - * Inclue Validate_Finance_CreditCard for Credit Card number validation + * Inclue Validate_Finance_CreditCard for Credit Card number validation */ require_once 'Validate/Finance/CreditCard.php'; /** - * Include Payment_Process_Type + * Include Payment_Process_Type */ require_once 'Payment/Process/Type.php'; @@ -150,7 +150,7 @@ * * @param string $type Name of the processor * @param array $options Options for the processor - * + * * @return mixed Instance of the processor object, or a PEAR_Error object. */ function &factory($type, $options = false) @@ -173,7 +173,7 @@ * Determine if a field is required. * * @param string $field Field to check - * + * * @return boolean true if required, false if optional. */ function isRequired($field) @@ -185,7 +185,7 @@ * Determines if a field exists. * * @param string $field Field to check - * + * * @return boolean true if field exists, false otherwise * @author Ian Eure <[email protected]> */ @@ -221,7 +221,7 @@ * * @param array $options Options to set * @param array $defaultOptions Default options - * + * * @return void * @author Ian Eure <[email protected]> * */ @@ -235,7 +235,7 @@ * Get an option value. * * @param string $option Option to get - * + * * @return mixed Option value * @access public * @author Ian Eure <[email protected]> @@ -250,7 +250,7 @@ * * @param string $option Option name to set * @param mixed $value Value to set - * + * * @return void * @access public * @author Joe Stump <[email protected]> @@ -270,14 +270,14 @@ * * @param mixed $value Value to check * @param mixed $class Constant class to check - * + * * @return boolean TRUE if it is defined, FALSE otherwise. * @access private */ function _isDefinedConst($value, $class) { $constClass = 'PAYMENT_PROCESS_'.strtoupper($class).'_'; - + $length = strlen($constClass); $consts = get_defined_constants(); $found = false; @@ -295,7 +295,7 @@ * Statically check a Payment_Result class for success * * @param mixed $obj Object to check - * + * * @return bool * @access public * @static @@ -316,7 +316,7 @@ * Statically check a Payment_Result class for error * * @param mixed $obj Object to check - * + * * @return bool * @access public * @author Joe Stump <[email protected]> @@ -522,7 +522,7 @@ * * @param string $rawResponse Raw response * @param mixed $request Request - */ + */ function Payment_Process_Result($rawResponse, $request) { $this->_rawResponse = $rawResponse; @@ -536,7 +536,7 @@ * @param string $type Type * @param string $rawResponse Raw response * @param mixed $request Request - * + * * @return mixed Payment_Process_Result on succes, PEAR_Error on failure * @author Joe Stump <[email protected]> * @author Ian Eure <[email protected]> @@ -682,7 +682,7 @@ { return $this->_avsCodeMap[$this->avsCode]; } - + /** * Returns the AVS message * @@ -693,11 +693,11 @@ return $this->_avsCodeMessages[$this->avsCode]; } - + /** * Return the CVV match code * - * @return integer One of PAYMENT_PROCESS_CVV_* constants + * @return integer One of PAYMENT_PROCESS_CVV_* constants */ function getCvvCode() { @@ -716,14 +716,14 @@ /** * _mapFields - * + * * @param mixed $responseArray Response array - * + * * @return void * @author Joe Stump <[email protected]> * @access private */ - function _mapFields($responseArray) + function _mapFields($responseArray) { foreach ($this->_fieldMap as $key => $val) { $this->$val = (array_key_exists($key, $responseArray)) @@ -736,7 +736,7 @@ * Accept an object * * @param object &$object Object to accept - * + * * @return boolean TRUE if accepted, FALSE otherwise */ function accept(&$object) @@ -753,7 +753,7 @@ * * @param string $message Message to log * @param string $priority Message priority - * + * * @return mixed Return value of Log::log(), or false if no Log instance * has been accepted. */ http://cvs.php.net/viewvc.cgi/pear/Payment_Process/Process/Type/eCheck.php?r1=1.10&r2=1.11&diff_format=u Index: pear/Payment_Process/Process/Type/eCheck.php diff -u pear/Payment_Process/Process/Type/eCheck.php:1.10 pear/Payment_Process/Process/Type/eCheck.php:1.11 --- pear/Payment_Process/Process/Type/eCheck.php:1.10 Tue May 6 18:45:10 2008 +++ pear/Payment_Process/Process/Type/eCheck.php Wed May 7 01:01:03 2008 @@ -7,50 +7,55 @@ * PHP versions 4 and 5 * * LICENSE: - * + * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this + * + * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation + * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - * 3. The name of the authors may not be used to endorse or promote products + * 3. The name of the authors may not be used to endorse or promote products * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. - * + * * @category Payment * @package Payment_Process - * @author Joe Stump <[email protected]> | + * @author Joe Stump <[email protected]> * @author Ian Eure <[email protected]> * @copyright 1997-2008 The PHP Group * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: eCheck.php,v 1.10 2008/05/06 18:45:10 jausions Exp $ + * @version CVS: $Id: eCheck.php,v 1.11 2008/05/07 01:01:03 jausions Exp $ * @link http://pear.php.net/package/Payment_Process */ /** * Payment_Process_Type_eCheck * - * @package Payment_Process - * @author Joe Stump <[email protected]> - * */ + * @category Payment + * @package Payment_Process + * @author Joe Stump <[email protected]> + * @author Ian Eure <[email protected]> + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/Payment_Process + */ class Payment_Process_Type_eCheck extends Payment_Process_Type { - /** + /** * $_type * * @var string $_type @@ -69,11 +74,19 @@ var $driversLicense; var $driversLicenseState; + /** + * Constructor + */ function Payment_Process_Type_eCheck() { } + /** + * Validates an account number + * + * @return boolean + */ function _validateAccountNumber() { if (!isset($this->accountNumber)) { @@ -83,6 +96,11 @@ return true; } + /** + * Validates a routing number + * + * @return boolean + */ function _validateRoutingCode() { if (!isset($this->routingCode)) { @@ -92,6 +110,11 @@ return true; } + /** + * Validates a bank name + * + * @return boolean + */ function _validateBankName() { if (!isset($this->bankName)) { @@ -102,4 +125,4 @@ } } -?> +?> \ No newline at end of file http://cvs.php.net/viewvc.cgi/pear/Payment_Process/Process/Type/CreditCard.php?r1=1.16&r2=1.17&diff_format=u Index: pear/Payment_Process/Process/Type/CreditCard.php diff -u pear/Payment_Process/Process/Type/CreditCard.php:1.16 pear/Payment_Process/Process/Type/CreditCard.php:1.17 --- pear/Payment_Process/Process/Type/CreditCard.php:1.16 Tue May 6 18:45:10 2008 +++ pear/Payment_Process/Process/Type/CreditCard.php Wed May 7 01:01:03 2008 @@ -8,31 +8,31 @@ * PHP versions 4 and 5 * * LICENSE: - * + * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this + * + * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation + * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - * 3. The name of the authors may not be used to endorse or promote products + * 3. The name of the authors may not be used to endorse or promote products * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. - * + * * @category Payment * @package Payment_Process * @author Ian Eure <[email protected]> @@ -40,7 +40,7 @@ * @author Philippe Jausions <[email protected]> * @copyright 1997-2005 The PHP Group * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: CreditCard.php,v 1.16 2008/05/06 18:45:10 jausions Exp $ + * @version CVS: $Id: CreditCard.php,v 1.17 2008/05/07 01:01:03 jausions Exp $ * @link http://pear.php.net/package/Payment_Process * @see Validate_Finance_CreditCard */ @@ -48,8 +48,12 @@ /** * Payment_Process_Type_CreditCard * - * @author Joe Stump <[email protected]> - * @package Payment_Process + * @category Payment + * @package Payment_Process + * @author Joe Stump <[email protected]> + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/Payment_Process */ class Payment_Process_Type_CreditCard extends Payment_Process_Type { @@ -90,12 +94,18 @@ */ var $expDate; + /** + * Class constructor + */ function __construct() { - require_once 'Validate/Finance/CreditCard.php'; + include_once 'Validate/Finance/CreditCard.php'; parent::__construct(); } + /** + * PHP4-style constructor + */ function Payment_Process_Type_CreditCard() { $this->__construct(); @@ -184,15 +194,16 @@ $monthOptions = array('min' => 1, 'max' => 12, 'decimal' => false); + $date = getdate(); - $yearOptions = array('min' => $date['year'], - 'decimal' => false); + $yearOptions = array('min' => $date['year'], + 'decimal' => false); - if (Validate::number($month, $monthOptions) && - Validate::number($year, $yearOptions)) { - if (($month >= $date['mon'] && $year == $date['year']) || - ($year > $date['year'])) { + if (Validate::number($month, $monthOptions) + && Validate::number($year, $yearOptions)) { + if (($month >= $date['mon'] && $year == $date['year']) + || ($year > $date['year'])) { return true; } } @@ -210,24 +221,24 @@ function _mapType() { switch ($this->type) { - case PAYMENT_PROCESS_CC_MASTERCARD: - return 'MasterCard'; - case PAYMENT_PROCESS_CC_VISA: - return 'Visa'; - case PAYMENT_PROCESS_CC_AMEX: - return 'Amex'; - case PAYMENT_PROCESS_CC_DISCOVER: - return 'Discover'; - case PAYMENT_PROCESS_CC_JCB: - return 'JCB'; - case PAYMENT_PROCESS_CC_DINERS: - return 'Diners'; - case PAYMENT_PROCESS_CC_ENROUTE: - return 'EnRoute'; - case PAYMENT_PROCESS_CC_CARTEBLANCHE: - return 'CarteBlanche'; - default: - return false; + case PAYMENT_PROCESS_CC_MASTERCARD: + return 'MasterCard'; + case PAYMENT_PROCESS_CC_VISA: + return 'Visa'; + case PAYMENT_PROCESS_CC_AMEX: + return 'Amex'; + case PAYMENT_PROCESS_CC_DISCOVER: + return 'Discover'; + case PAYMENT_PROCESS_CC_JCB: + return 'JCB'; + case PAYMENT_PROCESS_CC_DINERS: + return 'Diners'; + case PAYMENT_PROCESS_CC_ENROUTE: + return 'EnRoute'; + case PAYMENT_PROCESS_CC_CARTEBLANCHE: + return 'CarteBlanche'; + default: + return false; } } } http://cvs.php.net/viewvc.cgi/pear/Payment_Process/Process/Dummy.php?r1=1.7&r2=1.8&diff_format=u Index: pear/Payment_Process/Process/Dummy.php diff -u pear/Payment_Process/Process/Dummy.php:1.7 pear/Payment_Process/Process/Dummy.php:1.8 --- pear/Payment_Process/Process/Dummy.php:1.7 Tue May 6 18:45:10 2008 +++ pear/Payment_Process/Process/Dummy.php Wed May 7 01:01:03 2008 @@ -6,54 +6,57 @@ * PHP versions 4 and 5 * * LICENSE: - * + * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this + * + * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation + * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - * 3. The name of the authors may not be used to endorse or promote products + * 3. The name of the authors may not be used to endorse or promote products * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. - * - * @category Payment - * @package Payment_Process - * @author Ian Eure <[email protected]> - * @copyright 1997-2005 The PHP Group + * + * @category Payment + * @package Payment_Process + * @author Ian Eure <[email protected]> + * @copyright 1997-2005 The PHP Group * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: Dummy.php,v 1.7 2008/05/06 18:45:10 jausions Exp $ - * @link http://pear.php.net/package/Payment_Process + * @version CVS: $Id: Dummy.php,v 1.8 2008/05/07 01:01:03 jausions Exp $ + * @link http://pear.php.net/package/Payment_Process */ require_once 'Payment/Process/Common.php'; /** - * Payment_PAYMENT_PROCESS_Dummy + * Dummy processor * * A dummy processor for offline testing. It can be made to return different * result codes and messages for testing purposes. * - * @package Payment_Process * @category Payment - * @author Ian Eure <[email protected]> - * @version @version@ + * @package Payment_Process + * @author Ian Eure <[email protected]> + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/Payment_Process */ -class Payment_Process_Dummy extends Payment_Process_Common { +class Payment_Process_Dummy extends Payment_Process_Common +{ /** * Default options for this class. * @@ -96,11 +99,11 @@ if ($this->_options['randomResult']) { srand(microtime()); - $n = rand(0, count($this->_returnValues) - 1); - $code = &$this->_returnValues[$n]['code']; + $n = rand(0, count($this->_returnValues) - 1); + $code = &$this->_returnValues[$n]['code']; $message = &$this->_returnValues[$n]['message']; } else { - $code = &$this->_options['returnCode']; + $code = &$this->_options['returnCode']; $message = &$this->_options['returnMessage']; } @@ -108,9 +111,24 @@ } } -class Payment_Process_Result_Dummy extends Payment_Process_Result { +/** + * Dummy response + * + * @category Payment + * @package Payment_Process + * @author Ian Eure <[email protected]> + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/Payment_Process + */ +class Payment_Process_Result_Dummy extends Payment_Process_Result +{ + /** + * Class constructor + */ function Payment_Process_Result_Dummy() { } } -?> \ No newline at end of file + +?> http://cvs.php.net/viewvc.cgi/pear/Payment_Process/Process/Bibit.php?r1=1.7&r2=1.8&diff_format=u Index: pear/Payment_Process/Process/Bibit.php diff -u pear/Payment_Process/Process/Bibit.php:1.7 pear/Payment_Process/Process/Bibit.php:1.8 --- pear/Payment_Process/Process/Bibit.php:1.7 Tue May 6 18:45:10 2008 +++ pear/Payment_Process/Process/Bibit.php Wed May 7 01:01:03 2008 @@ -1,22 +1,45 @@ <?php /* vim: set expandtab tabstop=4 shiftwidth=4: */ -// +----------------------------------------------------------------------+ -// | PHP version 4 | -// +----------------------------------------------------------------------+ -// | Copyright (c) 1997-2004 The PHP Group | -// +----------------------------------------------------------------------+ -// | This source file is subject to version 3.0 of the PHP license, | -// | that is bundled with this package in the file LICENSE, and is | -// | available through the world-wide-web at | -// | http://www.php.net/license/3_0.txt. | -// | If you did not receive a copy of the PHP license and are unable to | -// | obtain it through the world-wide-web, please send a note to | -// | [email protected] so we can mail you a copy immediately. | -// +----------------------------------------------------------------------+ -// | Authors: Robin Ericsson <[email protected]> | -// +----------------------------------------------------------------------+ -// -// $Id: Bibit.php,v 1.7 2008/05/06 18:45:10 jausions Exp $ + +/** + * Bibit processor + * + * PHP versions 4 and 5 + * + * LICENSE: + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * 3. The name of the authors may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + * @category Payment + * @package Payment_Process + * @author Robin Ericsson <[email protected]> + * @copyright 1997-2005 The PHP Group + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version CVS: $Id: Bibit.php,v 1.8 2008/05/07 01:01:03 jausions Exp $ + * @link http://pear.php.net/package/Payment_Process + */ require_once 'Payment/Process.php'; require_once 'Payment/Process/Common.php'; @@ -47,11 +70,15 @@ * This is BETA code, and hos not been fully tested. It is not recommended * that you use it in a production environment without further testing. * - * @package Payment_Process - * @author Robin Ericsson <[email protected]> - * @version @version@ + * @category Payment + * @package Payment_Process + * @author Robin Ericsson <[email protected]> + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/Payment_Process */ -class Payment_Process_Bibit extends Payment_Process_Common { +class Payment_Process_Bibit extends Payment_Process_Common +{ /** * Front-end -> back-end field map. * @@ -116,7 +143,7 @@ /** * The order amounts exponent - * + * * @access private */ var $exponent = 0; @@ -141,35 +168,35 @@ * @access private */ var $shopper_email_address; - + /** * The unique id of the users session * * @access private */ var $session_id; - + /** * Unique id of the authenticed shopper * * @access private */ var $authenticated_shopper_id; - + /** * Shipping address * * @access private */ var $shipping_address = array(); - + /** * Payment method mask * * @access private */ var $payment_method_mask = array(); - + /** * $_typeFieldMap * @@ -187,8 +214,8 @@ * Constructor. * * @param array $options Class options to set. + * * @see Payment_Process::setOptions() - * @return void */ function __construct($options = false) { @@ -198,6 +225,11 @@ } + /** + * PHP4-style constructor + * + * @param array $options options + */ function Payment_Process_Bibit($options = false) { $this->__construct($options); @@ -212,7 +244,7 @@ { // Sanity check $result = $this->validate(); - if(PEAR::isError($result)) { + if (PEAR::isError($result)) { return $result; } @@ -252,7 +284,7 @@ // Restore error handling PEAR::popErrorHandling(); - $response = &Payment_Process_Result::factory($this->_driver, + $response = &Payment_Process_Result::factory($this->_driver, $this->_responseBody, &$this); if (!PEAR::isError($response)) { @@ -269,10 +301,10 @@ * @return string The query xml */ function _prepareQueryString() - { - $data = array_merge($this->_options,$this->_data); + { + $data = array_merge($this->_options, $this->_data); - $doc = XML_Util::getXMLDeclaration(); + $doc = XML_Util::getXMLDeclaration(); $doc .= '<!DOCTYPE paymentService PUBLIC "-//Bibit//DTD Bibit PaymentService v1//EN" "http://dtd.bibit.com/paymentService_v1.dtd">'; $doc .= XML_Util::createStartElement('paymentService', array('version' => $data['x_version'], 'merchantCode' => $data['x_login'])); @@ -281,26 +313,30 @@ $doc .= XML_Util::createStartElement('orderModification', array('orderCode' => $data['x_ordercode'])); if ($data['x_action'] == PAYMENT_PROCESS_ACTION_BIBIT_CAPTURE) { $doc .= XML_Util::createStartElement('capture'); - + $d = array(); $t = time() - 86400; + $d['dayOfMonth'] = date('d', $t); - $d['month'] = date('m', $t); - $d['year'] = date('Y', $t); - $d['hour'] = date('H', $t); - $d['minute'] = date('i', $t); - $d['second'] = date('s', $t); + $d['month'] = date('m', $t); + $d['year'] = date('Y', $t); + $d['hour'] = date('H', $t); + $d['minute'] = date('i', $t); + $d['second'] = date('s', $t); + $doc .= XML_Util::createTag('date', $d); - $doc .= XML_Util::createTag('amount', array('value' => $data['x_amount'], - 'currencyCode' => $data['x_currency'], - 'exponent' => $data['x_exponent'])); + $doc .= XML_Util::createTag('amount', + array('value' => $data['x_amount'], + 'currencyCode' => $data['x_currency'], + 'exponent' => $data['x_exponent'])); $doc .= XML_Util::createEndElement('capture'); } else if ($data['x_action'] == PAYMENT_PROCESS_ACTION_BIBIT_REFUND) { $doc .= XML_Util::createStartElement('refund'); - $doc .= XML_Util::createTag('amount', array('value' => $data['x_amount'], - 'currencyCode' => $data['x_currency'], - 'exponent' => $data['x_exponent'])); + $doc .= XML_Util::createTag('amount', + array('value' => $data['x_amount'], + 'currencyCode' => $data['x_currency'], + 'exponent' => $data['x_exponent'])); $doc .= XML_Util::createEndElement('refund'); } @@ -308,57 +344,71 @@ $doc .= XML_Util::createEndElement('modify'); } else { $doc .= XML_Util::createStartElement('submit'); - $doc .= XML_Util::createStartElement('order', array('orderCode' => $data['x_ordercode'])); - + $doc .= XML_Util::createStartElement('order', + array('orderCode' => $data['x_ordercode'])); + $doc .= XML_Util::createTag('description', null, $data['x_descr']); - $doc .= XML_Util::createTag('amount', array('value' => $data['x_amount'], - 'currencyCode' => $data['x_currency'], - 'exponent' => $data['x_exponent'])); + $doc .= XML_Util::createTag('amount', + array('value' => $data['x_amount'], + 'currencyCode' => $data['x_currency'], + 'exponent' => $data['x_exponent'])); if (isset($data['x_ordercontent'])) { $doc .= XML_Util::createStartElement('orderContent'); $doc .= XML_Util::createCDataSection($data['x_ordercontent']); $doc .= XML_Util::createEndElement('orderContent'); } - + if ($data['x_action'] == PAYMENT_PROCESS_ACTION_BIBIT_REDIRECT) { - if (is_array($data['paymentMethodMask']) && count($data['paymentMethodMask'] > 0)) { + if (is_array($data['paymentMethodMask']) + && count($data['paymentMethodMask'] > 0)) { $doc .= XML_Util::createStartElement('paymentMethodMask'); - foreach($data['paymentMethodMask']['include'] as $code) { - $doc .= XML_Util::createTag('include', array('code' => $code)); + foreach ($data['paymentMethodMask']['include'] as $code) { + $doc .= XML_Util::createTag('include', + array('code' => $code)); } - foreach($data['paymentMethodMask']['exclude'] as $code) { - $doc .= XML_Util::createTag('exclude', array('code' => $code)); + foreach ($data['paymentMethodMask']['exclude'] as $code) { + $doc .= XML_Util::createTag('exclude', + array('code' => $code)); } $doc .= XML_Util::createEndElement('paymentMethodMask'); } } else if ($data['x_action'] == PAYMENT_PROCESS_ACTION_BIBIT_AUTH) { $doc .= XML_Util::createStartElement('paymentDetails'); switch ($this->_payment->type) { - case PAYMENT_PROCESS_CC_VISA: $cc_type = 'VISA-SSL'; break; - case PAYMENT_PROCESS_CC_MASTERCARD: $cc_type = 'ECMC-SSL'; break; - case PAYMENT_PROCESS_CC_AMEX: $cc_type = 'AMEX-SSL'; break; + case PAYMENT_PROCESS_CC_VISA: + $cc_type = 'VISA-SSL'; + break; + case PAYMENT_PROCESS_CC_MASTERCARD: + $cc_type = 'ECMC-SSL'; + break; + case PAYMENT_PROCESS_CC_AMEX: + $cc_type = 'AMEX-SSL'; + break; } $doc .= XML_Util::createStartElement($cc_type); if (isset($data['x_card_num'])) { - $doc .= XML_Util::createTag('cardNumber', null, $data['x_card_num']); + $doc .= XML_Util::createTag('cardNumber', null, + $data['x_card_num']); } if (isset($data['x_exp_date'])) { $doc .= XML_Util::createStartElement('expiryDate'); - $doc .= XML_Util::createTag('date', array('month' => substr($data['x_exp_date'], 0, 2), - 'year' => substr($data['x_exp_date'], 3, 4))); + $doc .= XML_Util::createTag('date', + array('month' => substr($data['x_exp_date'], 0, 2), + 'year' => substr($data['x_exp_date'], 3, 4))); $doc .= XML_Util::createEndElement('expiryDate'); } if (isset($this->_payment->firstName) && isset($this->_payment->lastName)) { - $doc .= XML_Util::createTag('cardHolderName', null, $this->_payment->firstName.' '.$this->_payment->lastName); + $doc .= XML_Util::createTag('cardHolderName', null, + $this->_payment->firstName.' '.$this->_payment->lastName); } if (isset($data['x_card_code'])) { $doc .= XML_Util::createTag('cvc', null, $data['x_card_code']); } - + $doc .= XML_Util::createEndElement($cc_type); - + if ((isset($data['shopperIPAddress']) || isset($data['sessionId'])) && ($data['shopperIPAddress'] != '' || $data['sessionId'] != '')) { $t = array(); @@ -372,14 +422,14 @@ $doc .= XML_Util::createTag('session', $t); unset($t); } - + $doc .= XML_Util::createEndElement('paymentDetails'); } - - if ((isset($data['shopperEmailAddress']) && $data['shopperEmailAddress'] != '') + + if ((isset($data['shopperEmailAddress']) && $data['shopperEmailAddress'] != '') || (isset($data['authenticatedShopperID']) && $data['authenticatedShopperID'] != '')) { $doc .= XML_Util::createStartElement('shopper'); - + if ($data['shopperEmailAddress'] != '') { $doc .= XML_Util::createTag('shopperEmailAddress', null, $data['shopperEmailAddress']); } @@ -389,10 +439,10 @@ $doc .= XML_Util::createEndElement('shopper'); } - + if (is_array($data['shippingAddress']) && count($data['shippingAddress']) > 0) { $a =& $data['shippingAddress']; - + $doc .= XML_Util::createStartElement('shippingAddress'); $doc .= XML_Util::createStartElement('address'); @@ -401,16 +451,16 @@ 'postalCode', 'city', 'state', 'countryCode', 'telephoneNumber'); - foreach($fields as $field) { + foreach ($fields as $field) { if (isset($a[$field])) { $doc .= XML_Util::createTag($field, null, $a[$field]); } } - + $doc .= XML_Util::createEndElement('address'); $doc .= XML_Util::createEndElement('shippingAddress'); } - + $doc .= XML_Util::createEndElement('order'); $doc .= XML_Util::createEndElement('submit'); } @@ -424,8 +474,9 @@ /** * Prepare the ordercontent * - * Docs says max size is 10k + * Docs says max size is 10k * + * @return void * @access private */ function _handleOrdercontent() @@ -535,14 +586,13 @@ */ function _validateExponent() { - switch ($this->exponent) - { - case 0: - case 2: - case 3: - return true; - default: - return false; + switch ($this->exponent) { + case 0: + case 2: + case 3: + return true; + default: + return false; } } } @@ -550,35 +600,57 @@ /** * Payment_Process_Bibit_Result * - * - * @package Payment_Process - * @author Robin Ericsson <[email protected]> - * @version @version@ + * @category Payment + * @package Payment_Process + * @author Robin Ericsson <[email protected]> + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/Payment_Process */ class Payment_Process_Result_Bibit extends Payment_Process_Result { var $_returnCode = PAYMENT_PROCESS_RESULT_DECLINED; - var $_lastEvent = NULL; - + var $_lastEvent = null; + var $_fieldMap = array( ); + /** + * Class constructor + * + * @param mixed $rawResponse Raw response + */ function Payment_Process_Result_Bibit($rawResponse) { $this->_rawResponse = $rawResponse; } + /** + * Return error code + * + * @return integer + */ function getErrorCode() { return $this->_errorCode; } + /** + * Return response code + * + * @return mixed + */ function getCode() { return $this->_returnCode; } + /** + * Parses response + * + * @return void + */ function parse() { $doc = new XML_XPath(); @@ -586,20 +658,21 @@ $e = $doc->load($this->_rawResponse, 'string'); if (PEAR::isError($e)) { $this->_returnCode = PAYMENT_PROCESS_RESULT_OTHER; - $this->message = 'Error parsing reply: '.$e->getMessage()."\n"; + $this->message = 'Error parsing reply: '.$e->getMessage()."\n"; return; } $e = $doc->evaluate('//reply/error/attribute::code'); if (!PEAR::isError($e) && $e->next()) { $this->_returnCode = PAYMENT_PROCESS_RESULT_OTHER; - $this->_errorCode = $e->getData(); - + $this->_errorCode = $e->getData(); + $e = $doc->evaluate('//reply/error/text()'); + $this->message = $e->getData(); return; } - + $orderType = $this->_request->_data['x_action']; switch ($orderType) { case PAYMENT_PROCESS_ACTION_BIBIT_AUTH: @@ -607,12 +680,12 @@ if (!PEAR::isError($e) && $e->next()) { $this->_lastEvent = $e->getData(); } - + $amount = $doc->evaluate('//reply/orderStatus/payment/amount/attribute::value'); if (!PEAR::isError($amount) && $amount->next()) { - if ($this->_lastEvent == 'AUTHORISED') { + if ($this->_lastEvent == 'AUTHORISED') { $this->_returnCode = PAYMENT_PROCESS_RESULT_APPROVED; - $this->message = ''; + $this->message = ''; return; } } http://cvs.php.net/viewvc.cgi/pear/Payment_Process/Process/Common.php?r1=1.33&r2=1.34&diff_format=u Index: pear/Payment_Process/Process/Common.php diff -u pear/Payment_Process/Process/Common.php:1.33 pear/Payment_Process/Process/Common.php:1.34 --- pear/Payment_Process/Process/Common.php:1.33 Tue May 6 18:45:10 2008 +++ pear/Payment_Process/Process/Common.php Wed May 7 01:01:03 2008 @@ -8,45 +8,59 @@ * PHP versions 4 and 5 * * LICENSE: - * + * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this + * + * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation + * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * - * 3. The name of the authors may not be used to endorse or promote products + * 3. The name of the authors may not be used to endorse or promote products * derived from this software without specific prior written permission. * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO - * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO + * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER - * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. - * + * * @category Payment * @package Payment_Process * @author Ian Eure <[email protected]> * @author Joe Stump <[email protected]> * @copyright 1997-2005 The PHP Group * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: Common.php,v 1.33 2008/05/06 18:45:10 jausions Exp $ + * @version CVS: $Id: Common.php,v 1.34 2008/05/07 01:01:03 jausions Exp $ * @link http://pear.php.net/package/Payment_Process */ -require_once('Payment/Process.php'); -require_once('Payment/Process/Type.php'); +require_once 'Payment/Process.php'; +require_once 'Payment/Process/Type.php'; -class Payment_Process_Common { +/** + * Base class for processor + * + * @category Payment + * @package Payment_Process + * @author Ian Eure <[email protected]> + * @author Joe Stump <[email protected]> + * @copyright 1997-2005 The PHP Group + * @license http://www.opensource.org/licenses/bsd-license.php BSD License + * @version Release: @package_version@ + * @link http://pear.php.net/package/Payment_Process + * @abstract + */ +class Payment_Process_Common +{ // {{{ Private Properties /** * Options. @@ -82,7 +96,7 @@ * @access private */ var $_driver = null; - + /** * PEAR::Log instance * @@ -126,7 +140,7 @@ * @var string */ var $password = ''; - + /** * Processing action. * @@ -142,7 +156,7 @@ * @var string */ var $description = ''; - + /** * The transaction amount. * @@ -156,14 +170,14 @@ * @var mixed string or int */ var $invoiceNumber = ''; - + /** * Customer identifier * * @var mixed string or int */ var $customerId = ''; - + /** * Transaction source. * @@ -179,6 +193,8 @@ * * PHP 5.x constructor * + * @param array $options Options + * * @author Joe Stump <[email protected]> * @access public */ @@ -193,6 +209,8 @@ * * PHP 4.x constructor * + * @param array $options options + * * @author Joe Stump <[email protected]> * @access public */ @@ -210,7 +228,8 @@ * not validate. It could also mean that the payment type is not supported * by the given processor. * - * @param mixed $payment Object of Payment_Process_Type + * @param mixed &$payment Object of Payment_Process_Type + * * @return bool * @access public * @author Joe Stump <[email protected]> @@ -231,7 +250,7 @@ // $_typeFieldMap for more information. $paymentType = $payment->getType(); foreach ($this->_typeFieldMap[$paymentType] as $generic => $specific) { - + $func = '_handle'.ucfirst($generic); if (method_exists($this, $func)) { $result = $this->$func(); @@ -241,7 +260,7 @@ } else { // TODO This may screw things up - the problem is that // CC information is no longer member variables, so we - // can't overwrite it. You could always handle this + // can't overwrite it. You could always handle this // with a _handle funciton. I don't think it will cause // problems, but it could. if (!isset($this->_data[$specific])) { @@ -260,8 +279,9 @@ /** * Set many fields. * - * @param array $where Associative array of data to set, in the format - * 'field' => 'value', + * @param array $where Associative array of data to set, in the format + * 'field' => 'value', + * * @return void */ function setFrom($where) @@ -278,10 +298,13 @@ * Processes the transaction. * * This function should be overloaded by the processor. + * + * @return mixed */ function process() { - return PEAR::raiseError("process() is not implemented in this processor.", PAYMENT_PROCESS_ERROR_NOTIMPLEMENTED); + return PEAR::raiseError("process() is not implemented in this processor.", + PAYMENT_PROCESS_ERROR_NOTIMPLEMENTED); } // }}} // {{{ &processCallback() @@ -305,7 +328,7 @@ /** * validate * - * Validates data before processing. This function may be overloaded by + * Validates data before processing. This function may be overloaded by * the processor. * * @return boolean true if validation succeeded, PEAR_Error if it failed. @@ -341,8 +364,9 @@ * field is not part of the basic set of supported fields, it is set in * $_options. * - * @param string $field The field to set - * @param string $value The value to set + * @param string $field The field to set + * @param string $value The value to set + * * @return void */ function set($field, $value) @@ -358,26 +382,28 @@ /** * Determine if a field is required. * - * @param string $field Field to check + * @param string $field Field to check + * * @return boolean true if required, false if optional. */ function isRequired($field) { return (isset($this->_required[$field])); - } + } // }}} // {{{ fieldExists($field) /** * Determines if a field exists. * + * @param string $field Field to check + * + * @return boolean TRUE if field exists, FALSE otherwise * @author Ian Eure <[email protected]> - * @param string $field Field to check - * @return boolean true if field exists, false otherwise */ function fieldExists($field) { return @in_array($field, $this->getFields()); - } + } // }}} // {{{ getFields() /** @@ -386,9 +412,9 @@ * This function returns an array containing all the possible fields which * may be set. * + * @return array Array of valid fields. * @author Ian Eure <[email protected]> * @access public - * @return array Array of valid fields. */ function getFields() { @@ -396,7 +422,7 @@ foreach ($vars as $idx => $field) { if ($field{0} == '_') { unset($vars[$idx]); - } + } } return $vars; @@ -406,23 +432,26 @@ /** * Set class options. * - * @author Ian Eure <[email protected]> - * @param Array $options Options to set - * @param Array $defaultOptions Default options + * @param array $options Options to set + * @param array $defaultOptions Default options + * * @return void + * @author Ian Eure <[email protected]> */ function setOptions($options = false, $defaultOptions = false) { - $defaultOptions = $defaultOptions ? $defaultOptions : $this->_defaultOptions; $this->_options = @array_merge($defaultOptions, $options); - } + $defaultOptions = $defaultOptions ? $defaultOptions : $this->_defaultOptions; + $this->_options = @array_merge($defaultOptions, $options); + } // }}} // {{{ getOption($option) /** * Get an option value. * + * @param string $option Option to get + * + * @return mixed Option value * @author Ian Eure <[email protected]> - * @param string $option Option to get - * @return mixed Option value */ function getOption($option) { @@ -433,10 +462,12 @@ /** * Set an option value * + * @param string $option Option name to set + * @param mixed $value Value to set + * + * @return mixed * @author Joe Stump <[email protected]> * @access public - * @param string $option Option name to set - * @param mixed $value Value to set */ function setOption($option,$value) { @@ -448,10 +479,14 @@ * Gets transaction result. * * This function should be overloaded by the processor. + * + * @return mixed + * @abstract */ function getResult() { - return PEAR::raiseError("getResult() is not implemented in this processor.", PAYMENT_PROCESS_ERROR_NOTIMPLEMENTED); + return PEAR::raiseError("getResult() is not implemented in this processor.", + PAYMENT_PROCESS_ERROR_NOTIMPLEMENTED); } // }}} // {{{ _isDefinedConstant($value, $class) @@ -463,17 +498,19 @@ * $object->action is one of PAYMENT_PROCESS_ACTION_NORMAL, * PAYMENT_PROCESS_ACTION_AUTHONLY etc. * + * @param mixed $value Value to check + * @param mixed $class Constant class to check + * + * @return boolean TRUE if it is defined, FALSE otherwise. * @access private - * @param mixed $value Value to check - * @param mixed $class Constant class to check - * @return boolean true if it is defined, false otherwise. - */ + */ function _isDefinedConst($value, $class) - { + { $constClass = 'PAYMENT_PROCESS_'.strtoupper($class).'_'; + $length = strlen($constClass); $consts = get_defined_constants(); - $found = false; + $found = false; foreach ($consts as $constant => $constVal) { if (strncmp($constClass, $constant, $length) === 0 && $constVal == $value) { @@ -489,8 +526,9 @@ /** * Mark a field (or fields) as being required. * - * @param string $field Field name - * @param string ... + * @param string $field Field name + * @param string ... + * * @return boolean always true. */ function _makeRequired() @@ -505,23 +543,24 @@ /** * Mark a field as being optional. * - * @param string $field Field name - * @param ... - * @return boolean always true. + * @param string $field Field name + * @param string ... + * + * @return boolean always TRUE. */ function _makeOptional() { foreach (func_get_args() as $field) { unset($this->_required[$field]); - } + } return true; - } + } // }}} // {{{ _validateType() /** * Validates transaction type. * - * @return boolean true on success, false on failure. + * @return boolean TRUE on success, FALSE on failure. * @access private */ function _validateType() @@ -580,6 +619,7 @@ * Actions are defined in $GLOBALS['_Payment_Process_DriverName'] and then * handled here. We may decide to abstract the defines in the driver. * + * @return void * @access private */ function _handleAction() @@ -603,7 +643,7 @@ */ function _prepare() { - /* + /** * FIXME - because this only loops through stuff in the fieldMap, we * can't have handlers for stuff which isn't specified in there. * But the whole point of having a _handler() is that you need @@ -617,11 +657,13 @@ return $result; } } else { - // TODO This may screw things up - the problem is that - // CC information is no longer member variables, so we - // can't overwrite it. You could always handle this with - // a _handle funciton. I don't think it will cause problems, - // but it could. + /** + * @todo This may screw things up - the problem is that + * CC information is no longer member variables, so we + * can't overwrite it. You could always handle this with + * a _handle funciton. I don't think it will cause problems, + * but it could. + */ if (!isset($this->_data[$specific])) { if (isset($this->$generic)) { $this->_data[$specific] = $this->$generic; @@ -641,4 +683,4 @@ // }}} } -?> +?> \ No newline at end of file