/** * Sets payment * * 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. * * @param mixed $payment Object of Payment_Process2_Type * * @return bool * @access public * @author Joe Stump <*****@*****.**> */ function setPayment(Payment_Process2_Type $payment) { if (isset($this->_typeFieldMap[$payment->getType()]) && is_array($this->_typeFieldMap[$payment->getType()])) { $payment->validate(); $this->_payment = $payment; // Map over the payment specific fields. Check out // $_typeFieldMap for more information. $paymentType = $payment->getType(); foreach ($this->_typeFieldMap[$paymentType] as $generic => $specific) { $func = '_handle' . ucfirst($generic); if (method_exists($this, $func)) { $this->{$func}(); } 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. if (!isset($this->_data[$specific])) { if (isset($this->_payment->{$generic})) { $this->_data[$specific] = $this->_payment->{$generic}; } } } } return true; } throw new Payment_Process2_Exception('Invalid type field map'); }