Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Cancel.php
Go to the documentation of this file.
1 <?php
8 
10 {
17  public function execute()
18  {
19  $agreement = $this->_initAgreement();
20  if (!$agreement) {
21  return;
22  }
23  if ($agreement->canCancel()) {
24  try {
25  $agreement->cancel();
26  $this->messageManager->addNoticeMessage(
27  __('The billing agreement "%1" has been canceled.', $agreement->getReferenceId())
28  );
29  } catch (\Magento\Framework\Exception\LocalizedException $e) {
30  $this->messageManager->addExceptionMessage($e, $e->getMessage());
31  } catch (\Exception $e) {
32  $this->messageManager->addExceptionMessage($e, __('We can\'t cancel the billing agreement.'));
33  }
34  }
35  $this->_redirect('*/*/view', ['_current' => true]);
36  }
37 }
_redirect($path, $arguments=[])
Definition: Action.php:167
__()
Definition: __.php:13