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 {
16  const ADMIN_RESOURCE = 'Magento_Paypal::actions_manage';
17 
23  public function execute()
24  {
25  $agreementModel = $this->_initBillingAgreement();
26 
27  if ($agreementModel && $agreementModel->canCancel()) {
28  try {
29  $agreementModel->cancel();
30  $this->messageManager->addSuccessMessage(
31  __('You canceled the billing agreement.')
32  );
33  $this->_redirect('paypal/*/view', ['_current' => true]);
34  return;
35  } catch (\Magento\Framework\Exception\LocalizedException $e) {
36  $this->messageManager->addExceptionMessage(
37  $e,
38  $e->getMessage()
39  );
40  } catch (\Exception $e) {
41  $this->messageManager->addExceptionMessage(
42  $e,
43  __('We can\'t cancel the billing agreement.')
44  );
45  }
46  $this->_redirect('paypal/*/view', ['_current' => true]);
47  }
48  return $this->_redirect('paypal/*/');
49  }
50 }
__()
Definition: __.php:13