_initBillingAgreement(); if ($agreementModel) { try { $agreementModel->delete(); $this->messageManager->addSuccessMessage( __('You deleted the billing agreement.') ); $this->_redirect('paypal/*/'); return; } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->messageManager->addExceptionMessage( $e, $e->getMessage() ); } catch (\Exception $e) { $this->messageManager->addExceptionMessage( $e, __('We can\'t delete the billing agreement.') ); } $this->_redirect('paypal/*/view', ['_current' => true]); } $this->_redirect('paypal/*/'); } }