示例#1
0
 /**
  * Set order status by transaction
  *
  * @param \XLite\Model\Payment\Transaction $transaction Transaction which changes status
  *
  * @return void
  */
 public function setPaymentStatusByTransaction(\XLite\Model\Payment\Transaction $transaction)
 {
     if ($this->isPayed()) {
         $status = $transaction->isCaptured() ? \XLite\Model\Order\Status\Payment::STATUS_PAID : \XLite\Model\Order\Status\Payment::STATUS_AUTHORIZED;
     } else {
         if ($transaction->isRefunded()) {
             $paymentTransactionSums = $this->getRawPaymentTransactionSums();
             $refunded = $paymentTransactionSums['refunded'];
             // Check if the whole refunded sum (along with the previous refunded transactions for the order)
             // covers the whole total for order
             $status = $refunded < (double) $this->getTotal() ? \XLite\Model\Order\Status\Payment::STATUS_PAID : \XLite\Model\Order\Status\Payment::STATUS_REFUNDED;
         } elseif ($transaction->isFailed()) {
             $status = \XLite\Model\Order\Status\Payment::STATUS_DECLINED;
         } elseif ($transaction->isVoid()) {
             $status = \XLite\Model\Order\Status\Payment::STATUS_DECLINED;
         } elseif ($transaction->isCaptured()) {
             $status = \XLite\Model\Order\Status\Payment::STATUS_PART_PAID;
         } else {
             $status = \XLite\Model\Order\Status\Payment::STATUS_QUEUED;
         }
     }
     $this->setPaymentStatus($status);
 }
 /**
  * {@inheritDoc}
  */
 public function isRefunded()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'isRefunded', array());
     return parent::isRefunded();
 }