Example #1
0
 /**
  * {@inheritdoc}
  */
 public function getLastPayment($state = BasePaymentInterface::STATE_NEW)
 {
     if ($this->payments->isEmpty()) {
         return false;
     }
     return $this->payments->filter(function (BasePaymentInterface $payment) use($state) {
         return $payment->getState() === $state;
     })->last();
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function getLastNewPayment()
 {
     if ($this->payments->isEmpty()) {
         return null;
     }
     $payment = $this->payments->filter(function (BasePaymentInterface $payment) {
         return $payment->getState() === BasePaymentInterface::STATE_NEW;
     })->last();
     return $payment !== false ? $payment : null;
 }
Example #3
0
 /**
  * @param string|null $state
  *
  * @return BasePaymentInterface|null
  */
 public function getLastPayment($state = null)
 {
     if ($this->payments->isEmpty()) {
         return null;
     }
     $payment = $this->payments->filter(function (BasePaymentInterface $payment) use($state) {
         return null === $state || $payment->getState() === $state;
     })->last();
     return $payment !== false ? $payment : null;
 }