/**
  * Returns customer credit cards if applicable
  * 
  * @return \Braintree_Customer|boolean
  */
 public function getLoggedInCustomerCards()
 {
     $applicableCards = [];
     $useVault = (bool) (int) $this->scopeConfig->getValue(self::CONFIG_PATH_VAULT, ScopeConfigInterface::SCOPE_TYPE_DEFAULT, $this->sessionQuote->getStoreId());
     if ($useVault) {
         $storedCards = false;
         if ($this->sessionQuote->getCustomerId()) {
             $customerId = $this->paymentHelper->generateCustomerId($this->sessionQuote->getCustomerId(), $this->sessionQuote->getQuote()->getCustomerEmail());
             try {
                 $storedCards = $this->braintreeCustomerAdapter->find($customerId)->creditCards;
             } catch (\Braintree_Exception $e) {
                 $this->_logger->critical($e);
             }
         }
         if ($storedCards) {
             $country = $this->sessionQuote->getQuote()->getBillingAddress()->getCountryId();
             $cardTypes = $this->paymentHelper->getCcAvailableCardTypes($country);
             $applicableCards = [];
             foreach ($storedCards as $card) {
                 if (isset($cardTypes[$this->paymentHelper->getCcTypeCodeByName($card->cardType)])) {
                     $applicableCards[] = $card;
                 }
             }
         }
     }
     return $applicableCards;
 }
Beispiel #2
0
 /**
  * Constructor
  *
  * @return void
  */
 protected function _construct()
 {
     $this->_objectId = 'order_id';
     $this->_controller = 'order';
     $this->_mode = 'create';
     parent::_construct();
     $this->setId('sales_order_create');
     $customerId = $this->_sessionQuote->getCustomerId();
     $storeId = $this->_sessionQuote->getStoreId();
     $this->buttonList->update('save', 'label', __('Submit Order'));
     $this->buttonList->update('save', 'onclick', 'order.submit()');
     $this->buttonList->update('save', 'class', 'primary');
     // Temporary solution, unset button widget. Will have to wait till jQuery migration is complete
     $this->buttonList->update('save', 'data_attribute', array());
     $this->buttonList->update('save', 'id', 'submit_order_top_button');
     if (is_null($customerId) || !$storeId) {
         $this->buttonList->update('save', 'style', 'display:none');
     }
     $this->buttonList->update('back', 'id', 'back_order_top_button');
     $this->buttonList->update('back', 'onclick', 'setLocation(\'' . $this->getBackUrl() . '\')');
     $this->buttonList->update('reset', 'id', 'reset_order_top_button');
     if (is_null($customerId)) {
         $this->buttonList->update('reset', 'style', 'display:none');
     } else {
         $this->buttonList->update('back', 'style', 'display:none');
     }
     $confirm = __('Are you sure you want to cancel this order?');
     $this->buttonList->update('reset', 'label', __('Cancel'));
     $this->buttonList->update('reset', 'class', 'cancel');
     $this->buttonList->update('reset', 'onclick', 'deleteConfirm(\'' . $confirm . '\', \'' . $this->getCancelUrl() . '\')');
     $pageTitle = $this->getLayout()->createBlock('Magento\\Sales\\Block\\Adminhtml\\Order\\Create\\Header')->toHtml();
     if (is_object($this->getLayout()->getBlock('page-title'))) {
         $this->getLayout()->getBlock('page-title')->setPageTitle($pageTitle);
     }
 }
Beispiel #3
0
 /**
  * Constructor
  *
  * @return void
  */
 protected function _construct()
 {
     $this->_objectId = 'order_id';
     $this->_controller = 'order';
     $this->_mode = 'create';
     parent::_construct();
     $this->setId('sales_order_create');
     $customerId = $this->_sessionQuote->getCustomerId();
     $storeId = $this->_sessionQuote->getStoreId();
     $this->buttonList->update('save', 'label', __('Submit Order'));
     $this->buttonList->update('save', 'onclick', 'order.submit()');
     $this->buttonList->update('save', 'class', 'primary');
     // Temporary solution, unset button widget. Will have to wait till jQuery migration is complete
     $this->buttonList->update('save', 'data_attribute', []);
     $this->buttonList->update('save', 'id', 'submit_order_top_button');
     if ($customerId === null || !$storeId) {
         $this->buttonList->update('save', 'style', 'display:none');
     }
     $this->buttonList->update('back', 'id', 'back_order_top_button');
     $this->buttonList->update('back', 'onclick', 'setLocation(\'' . $this->getBackUrl() . '\')');
     $this->buttonList->update('reset', 'id', 'reset_order_top_button');
     if ($customerId === null) {
         $this->buttonList->update('reset', 'style', 'display:none');
     } else {
         $this->buttonList->update('back', 'style', 'display:none');
     }
     $confirm = __('Are you sure you want to cancel this order?');
     $this->buttonList->update('reset', 'label', __('Cancel'));
     $this->buttonList->update('reset', 'class', 'cancel');
     $this->buttonList->update('reset', 'onclick', 'deleteConfirm(\'' . $confirm . '\', \'' . $this->getCancelUrl() . '\')');
 }
Beispiel #4
0
 /**
  * @return array
  */
 public function getOneClickCards()
 {
     $customerId = $this->_sessionQuote->getCustomerId();
     $storeId = $this->_sessionQuote->getStoreId();
     $grandTotal = $this->_sessionQuote->getQuote()->getGrandTotal();
     // For backend only allow recurring payments
     $recurringType = \Adyen\Payment\Model\RecurringType::RECURRING;
     $cards = $this->_adyenHelper->getOneClickPaymentMethods($customerId, $storeId, $grandTotal, $recurringType);
     return $cards;
 }