1 | <?php |
||
2 | namespace DigitalOrigin\Pmt\Controller\Payment; |
||
3 | |||
4 | use Magento\Framework\App\Action\Action; |
||
5 | use Magento\Framework\View\Element\BlockInterface; |
||
6 | |||
7 | class Iframe extends Action |
||
8 | { |
||
9 | /** |
||
10 | * @var \Magento\Framework\View\Result\PageFactory |
||
11 | */ |
||
12 | protected $_pageFactory; |
||
13 | |||
14 | public function __construct( |
||
15 | \Magento\Framework\App\Action\Context $context, |
||
16 | \Magento\Framework\View\Result\PageFactory $pageFactory, |
||
17 | \DigitalOrigin\Pmt\Helper\Config $pmtconfig |
||
18 | ) { |
||
19 | $this->_pageFactory = $pageFactory; |
||
20 | $this->config = $pmtconfig->getConfig(); |
||
21 | return parent::__construct($context); |
||
22 | } |
||
23 | |||
24 | /** |
||
25 | * @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface|\Magento\Framework\View\Result\Page |
||
26 | */ |
||
27 | public function execute() |
||
28 | { |
||
29 | try { |
||
30 | $resultPage = $this->_pageFactory->create(); |
||
31 | $orderId = $this->getRequest()->getParam('orderId'); |
||
32 | if ($orderId == '') { |
||
33 | throw new \Exception('Empty orderId'); |
||
34 | } |
||
35 | |||
36 | if ($this->config['public_key'] == '' || $this->config['secret_key'] == '') { |
||
37 | throw new \Exception('Public and Secret Key not found'); |
||
38 | } |
||
39 | |||
40 | $orderClient = new \PagaMasTarde\OrdersApiClient\Client( |
||
41 | $this->config['public_key'], |
||
42 | $this->config['secret_key'] |
||
43 | ); |
||
44 | |||
45 | $order = $orderClient->getOrder($orderId); |
||
46 | |||
47 | /** @var \DigitalOrigin\Pmt\Block\Payment\Iframe $block */ |
||
48 | $block = $resultPage->getLayout()->getBlock('paylater_payment_iframe'); |
||
49 | $block |
||
50 | ->setEmail($order->getUser()->getEmail()) |
||
51 | ->setOrderUrl($order->getActionUrls()->getForm()) |
||
52 | ->setCheckoutUrl($order->getConfiguration()->getUrls()->getCancel()) |
||
53 | ; |
||
54 | |||
55 | return $resultPage; |
||
56 | } catch (\Exception $exception) { |
||
57 | $this->logger->info(__METHOD__.'=>'.$exception->getMessage()); |
||
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
58 | die($exception->getMessage()); |
||
59 | } |
||
60 | } |
||
61 | } |
||
62 |