Source for file Common.php
Documentation is available at Common.php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 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 |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Ian Eure <ieure@php.net> |
// | Joe Stump <joe@joestump.net> |
// +----------------------------------------------------------------------+
// $Id: Common.php,v 1.19 2004/04/01 18:25:42 jstump Exp $
require_once 'Payment/Process.php';
require_once 'Payment/Process/Type.php';
* @author Joe Stump <joe@joestump.net>
* @var mixed $_typeFieldMap
* An internal reference to the Payment_Process_Type that is currently
* @author Joe Stump <joe@joestump.net>
* @var mixed $_payment Instance of Payment_Type
* @see Payment_Process_Common::setPayment()
* Validate data before processing.
* This function may be overloaded by the processor.
* @return boolean true if validation succeeded, PEAR_Error if it failed.
$func = '_validate'. ucfirst($field);
// Don't validate unset optional fields
if (PEAR ::isError ($res)) {
} elseif (is_bool($res) && $res == false ) {
* Process the transaction.
* This function should be overloaded by the processor.
* Get transaction result.
* This function should be overloaded by the processor.
* Validate transaction type.
* @return boolean true on success, false on failure.
return $this->_isDefinedConst ($this->type, 'type');
* Validate transaction acion.
* @return boolean true on success, false on failure.
function _validateAction ()
return (isset ($GLOBALS['_Payment_Process_'. $this->_driver][$this->action]));
* Validate transaction source.
* @return boolean true on success, false on failure.
function _validateSource ()
* Validate the charge amount.
* Charge amount must be 8 characters long, double-precision.
* Current min/max are rather arbitrarily set to $0.99 and $99999.99,
* @return boolean true on success, false otherwise
function _validateAmount ()
return Validate ::number ($this->amount, array (
* This function handles translating the data set in the front-end to the
* format needed by the back-end. The prepared data is stored in
* $this->_data. If a '_handleField' method exists in this class (e.g.
* '_handleCardNumber()'), that function is called and /must/ set
* $this->_data correctly. If no field-handler function exists, the data
* from the front-end is mapped into $_data using $this->_fieldMap.
* @return array Data to POST
if ($this->_options['debug']) {
echo '----------- PREPARE A ----------'. "\n";
echo '----------- PREPARE A ----------'. "\n";
* 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
* to do something more than simple mapping.
foreach ($this->_fieldMap as $generic => $specific) {
$func = '_handle'. ucfirst($generic);
$result = $this->$func();
if (PEAR ::isError ($result)) {
// 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,
if (!isset ($this->_data[$specific])) {
$this->_data[$specific] = $this->$generic;
// Form of payments data overrides those set in the
// Payment_Process_Common.
$this->_data[$specific] = $this->_payment->$generic;
if ($this->_options['debug']) {
echo '----------- PREPARE ----------'. "\n";
echo '----------- PREPARE ----------'. "\n";
* Returns false if payment could not be set. This usually means the
* payment type is not valid or that the payment type is valid, but did
* not validate. It could also mean that the payment type is not supported
* by the given processor.
* @author Joe Stump <joe@joestump.net>
* @param mixed $payment Object of Payment_Process_Type
// Map over the payment specific fiels. Check out
// $_typeFieldMap for more information.
$paymentType = $payment->getType ();
if(!isset ($this->_data[$val])) {
$this->_data[$val] = $this->_payment->$key;
* Actions are defined in $GLOBALS['_Payment_Process_DriverName'] and then
* handled here. We may decide to abstract the defines in the driver.
* @author Joe Stump <joe@joestump.net>
$this->_data[$this->_fieldMap['action']] = $GLOBALS['_Payment_Process_'. $this->_driver][$this->action];
* This will only print the message if 'debug' is set in the Processor
* @param string $msg Message to print
* @author Ian Eure <ieure@php.net>
if ($this->_options['debug']) {
Documentation generated on Mon, 11 Mar 2019 13:51:26 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|