Example #1
0
 /**
  * Prepare recurring payments from the session
  *
  * @return void
  */
 protected function _prepareLastRecurringPayments()
 {
     $paymentIds = $this->_checkoutSession->getLastRecurringPaymentIds();
     if ($paymentIds && is_array($paymentIds)) {
         $collection = $this->_recurringPaymentCollectionFactory->create()->addFieldToFilter('payment_id', array('in' => $paymentIds));
         $payments = array();
         foreach ($collection as $payment) {
             $payments[] = $payment;
         }
         if ($payments) {
             $this->setRecurringPayments($payments);
             if ($this->_customerSession->isLoggedIn()) {
                 $this->setCanViewPayments(true);
             }
         }
     }
 }
Example #2
0
 /**
  * Is valid session?
  *
  * @param \Magento\Checkout\Model\Session $checkoutSession
  * @return bool
  */
 public function isValid(\Magento\Checkout\Model\Session $checkoutSession)
 {
     if (!$checkoutSession->getLastSuccessQuoteId()) {
         return false;
     }
     if (!$checkoutSession->getLastQuoteId() || !$checkoutSession->getLastOrderId() && count($checkoutSession->getLastRecurringPaymentIds()) == 0) {
         return false;
     }
     return true;
 }