/**
  * Sets the requested amount
  * @param float $amount
  */
 public final function setRequestedAmount($amount)
 {
     $max = Doctrine_Core::getTable('Currency')->convertAmount($this->Payment->approved_amount, $this->Payment->currency, $this->currency);
     if (jmsPaymentNumberUtil::compareFloats($amount, $max) !== 0) {
         throw new InvalidArgumentException('$amount must be equal to ' . $max . ', given: ' . $amount . '.');
     }
     parent::setRequestedAmount($amount);
 }
 protected final function canBePerformedOn(Payment $payment)
 {
     return $payment->state === Payment::STATE_NEW || $payment->state === Payment::STATE_APPROVING && jmsPaymentNumberUtil::compareFloats($payment->approved_amount, $payment->target_amount) < 0;
 }
コード例 #3
0
 /**
  * Sets the requested amount of this transaction
  * @param mixed $amount Any value that is correctly converted to a float
  */
 public function setRequestedAmount($amount)
 {
     if ($this->state !== self::STATE_NEW) {
         throw new RuntimeException('The requested amount cannot be changed on not NEW transactions.');
     }
     if (jmsPaymentNumberUtil::compareFloats($amount, 0.0) <= 0) {
         throw new InvalidArgumentException('$amount cannot be smaller or equal to 0.');
     }
     $this->_set('requested_amount', $amount);
 }