Пример #1
0
 public function testIsShortcutCheckoutEnabled()
 {
     $isEnabled = 1;
     $prefix = 'payment/braintree_paypal/';
     $this->scopeConfigMock->expects($this->once())->method('getValue')->with($prefix . PayPal::KEY_DISPLAY_ON_SHOPPING_CART, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, null)->willReturn($isEnabled);
     $this->assertEquals(true, $this->model->isShortcutCheckoutEnabled());
 }
Пример #2
0
 /**
  * Check whether payment method is enabled
  *
  * @param RequestInterface $request
  * @return \Magento\Framework\Controller\Result\Redirect|\Magento\Framework\App\ResponseInterface
  */
 public function dispatch(RequestInterface $request)
 {
     if (!$this->braintreePayPalConfig->isActive() || !$this->braintreePayPalConfig->isShortcutCheckoutEnabled()) {
         $this->_actionFlag->set('', self::FLAG_NO_DISPATCH, true);
         /** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
         $resultRedirect = $this->resultRedirectFactory->create();
         $resultRedirect->setPath('noRoute');
         return $resultRedirect;
     }
     return parent::dispatch($request);
 }
 /**
  * Add Braintree PayPal shortcut buttons
  *
  * @param \Magento\Framework\Event\Observer $observer
  * @return void
  */
 public function execute(\Magento\Framework\Event\Observer $observer)
 {
     //Don't display shortcut on product view page
     if (!$this->methodPayPal->isActive() || !$this->paypalConfig->isShortcutCheckoutEnabled()) {
         return;
     }
     /** @var \Magento\Catalog\Block\ShortcutButtons $shortcutButtons */
     $shortcutButtons = $observer->getEvent()->getContainer();
     /** @var Shortcut $shortcut */
     $shortcut = $shortcutButtons->getLayout()->createBlock(self::PAYPAL_SHORTCUT_BLOCK, '', ['data' => [Shortcut::MINI_CART_FLAG_KEY => !$observer->getEvent()->getIsCatalogProduct()]]);
     if ($shortcut->skipShortcutForGuest()) {
         return;
     }
     $shortcut->setShowOrPosition($observer->getEvent()->getOrPosition());
     $shortcutButtons->addShortcut($shortcut);
 }