-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/PLUG-3755
- Loading branch information
Showing
50 changed files
with
3,005 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace Paynl\Payment\Block\Adminhtml\Render; | ||
|
||
use Magento\Backend\Block\Template\Context; | ||
use Magento\Config\Block\System\Config\Form\Field; | ||
use Magento\Framework\Data\Form\Element\AbstractElement; | ||
use Magento\Framework\UrlInterface; | ||
|
||
class CacheButton extends Field | ||
{ | ||
/** | ||
* @var UrlInterface | ||
*/ | ||
protected $urlInterface; | ||
|
||
/** | ||
* constructor. | ||
* @param Context $context | ||
* @param UrlInterface $urlInterface | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
UrlInterface $urlInterface | ||
) { | ||
$this->urlInterface = $urlInterface; | ||
parent::__construct($context); | ||
} | ||
|
||
/** | ||
* Render block: extension version | ||
* | ||
* @param AbstractElement $element | ||
* | ||
* @return string | ||
*/ | ||
public function render(AbstractElement $element) | ||
{ | ||
$currentUrl = $this->urlInterface->getCurrentUrl(); | ||
$payUrl = str_replace("system_config/edit/section/paynl_paymentmethods", "cache", $currentUrl); | ||
|
||
$text = __('When updating this setting, please flush Magento\'s cache afterwards ') . ' <a href="' . $payUrl . '">' . __('here') . '</a>.'; | ||
$html = '<tr id="row_' . $element->getHtmlId() . '" class="PaynlCacheButton">'; | ||
$html .= '<td></td><td class="value">' . $text . '</td>'; | ||
$html .= '</tr>'; | ||
return $html; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Paynl\Payment\Block\Checkout; | ||
|
||
use Magento\Catalog\Block\Product\Context; | ||
use Magento\Catalog\Block\Product\ProductList\Item\Block; | ||
use Magento\Framework\View\Page\Config; | ||
|
||
class FastCheckout extends Block | ||
{ | ||
/** | ||
* @param Context $context | ||
* @param Config $page | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
Config $page, | ||
array $data = [] | ||
) { | ||
$page->addPageAsset('Paynl_Payment::css/payFastCheckout.css'); | ||
parent::__construct($context, $data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
<?php | ||
|
||
namespace Paynl\Payment\Block\Page; | ||
|
||
use Magento\Checkout\Model\Cart; | ||
use Magento\Framework\App\CacheInterface; | ||
use Magento\Framework\App\Request\Http as Request; | ||
use Magento\Framework\App\Response\Http as Response; | ||
use Magento\Framework\Message\ManagerInterface; | ||
use Magento\Framework\View\Element\Template\Context; | ||
use Magento\Framework\View\Page\Config; | ||
|
||
class FastCheckoutFallback extends \Magento\Framework\View\Element\Template | ||
{ | ||
/** | ||
* @var Request | ||
*/ | ||
protected $request; | ||
|
||
/** | ||
* @var Response | ||
*/ | ||
private $response; | ||
|
||
/** | ||
* @var Cart | ||
*/ | ||
private $cart; | ||
|
||
/** | ||
* @var CacheInterface | ||
*/ | ||
public $cache; | ||
|
||
/** | ||
* @var ManagerInterface | ||
*/ | ||
public $messageManager; | ||
|
||
/** | ||
* @param Context $context | ||
* @param Request $request | ||
* @param Response $response | ||
* @param Cart $cart | ||
* @param CacheInterface $cache | ||
* @param Config $page | ||
* @param ManagerInterface $messageManager | ||
* @param array $data | ||
*/ | ||
public function __construct( | ||
Context $context, | ||
Request $request, | ||
Response $response, | ||
Cart $cart, | ||
CacheInterface $cache, | ||
Config $page, | ||
ManagerInterface $messageManager, | ||
array $data = [] | ||
) { | ||
$page->addPageAsset('Paynl_Payment::css/payFastCheckout.css'); | ||
parent::__construct($context, $data); | ||
$this->cart = $cart; | ||
$this->request = $request; | ||
$this->response = $response; | ||
$this->cache = $cache; | ||
$this->messageManager = $messageManager; | ||
} | ||
|
||
/** | ||
* Initialize data and prepare it for output | ||
* | ||
* @return string | ||
*/ | ||
protected function _beforeToHtml() // phpcs:ignore | ||
{ | ||
return parent::_beforeToHtml(); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getShippingMethods() | ||
{ | ||
$cacheName = 'shipping_methods_' . $this->cart->getQuote()->getId(); | ||
$shippingMethodJson = $this->cache->load($cacheName); | ||
|
||
if (empty($shippingMethodJson)) { | ||
$this->messageManager->addNoticeMessage(__('Unfortunately fast checkout is currently not possible.')); | ||
$this->response->setRedirect('/checkout/cart'); | ||
} else { | ||
return json_decode($shippingMethodJson); | ||
} | ||
} | ||
|
||
/** | ||
* @param string $param | ||
* @return string|null | ||
*/ | ||
public function getParam($param) | ||
{ | ||
$params = $this->request->getParams(); | ||
return (isset($params[$param])) ? $params[$param] : null; | ||
} | ||
} |
Oops, something went wrong.