Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Payflow.php
Go to the documentation of this file.
1 <?php
7 
12 {
16  protected $_checkoutSession;
17 
21  protected $_orderFactory;
22 
26  protected $_logger;
27 
32 
36  protected $_checkoutHelper;
37 
42  protected $_redirectBlockName = 'payflow.link.iframe';
43 
47  private $paymentFailures;
48 
58  public function __construct(
59  \Magento\Framework\App\Action\Context $context,
60  \Magento\Checkout\Model\Session $checkoutSession,
61  \Magento\Sales\Model\OrderFactory $orderFactory,
62  \Magento\Paypal\Model\PayflowlinkFactory $payflowModelFactory,
63  \Magento\Paypal\Helper\Checkout $checkoutHelper,
64  \Psr\Log\LoggerInterface $logger,
65  \Magento\Sales\Api\PaymentFailuresInterface $paymentFailures = null
66  ) {
67  parent::__construct($context);
68 
69  $this->_checkoutSession = $checkoutSession;
70  $this->_orderFactory = $orderFactory;
71  $this->_logger = $logger;
72  $this->_payflowModelFactory = $payflowModelFactory;
73  $this->_checkoutHelper = $checkoutHelper;
74  $this->paymentFailures = $paymentFailures ?: $this->_objectManager->get(
75  \Magento\Sales\Api\PaymentFailuresInterface::class
76  );
77  }
78 
85  protected function _cancelPayment($errorMsg = '')
86  {
87  $errorMsg = trim(strip_tags($errorMsg));
88  $order = $this->_checkoutSession->getLastRealOrder();
89  if ($order->getId()) {
90  $this->paymentFailures->handle((int)$order->getQuoteId(), $errorMsg);
91  }
92 
93  $gotoSection = false;
94  $this->_checkoutHelper->cancelCurrentOrder($errorMsg);
95  if ($this->_checkoutSession->restoreQuote()) {
96  //Redirect to payment step
97  $gotoSection = 'paymentMethod';
98  }
99 
100  return $gotoSection;
101  }
102 }
__construct(\Magento\Framework\App\Action\Context $context, \Magento\Checkout\Model\Session $checkoutSession, \Magento\Sales\Model\OrderFactory $orderFactory, \Magento\Paypal\Model\PayflowlinkFactory $payflowModelFactory, \Magento\Paypal\Helper\Checkout $checkoutHelper, \Psr\Log\LoggerInterface $logger, \Magento\Sales\Api\PaymentFailuresInterface $paymentFailures=null)
Definition: Payflow.php:58
$order
Definition: order.php:55
$logger