Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
StartWizard.php
Go to the documentation of this file.
1 <?php
8 
10 {
16  public function execute()
17  {
18  $agreement = $this->_objectManager->create(\Magento\Paypal\Model\Billing\Agreement::class);
19  $paymentCode = $this->getRequest()->getParam('payment_method');
20  if ($paymentCode) {
21  try {
22  $agreement->setStoreId(
23  $this->_objectManager->get(\Magento\Store\Model\StoreManager::class)->getStore()->getId()
24  )->setMethodCode(
25  $paymentCode
26  )->setReturnUrl(
27  $this->_objectManager->create(
28  \Magento\Framework\UrlInterface::class
29  )->getUrl('*/*/returnWizard', ['payment_method' => $paymentCode])
30  )->setCancelUrl(
31  $this->_objectManager->create(\Magento\Framework\UrlInterface::class)
32  ->getUrl('*/*/cancelWizard', ['payment_method' => $paymentCode])
33  );
34 
35  return $this->getResponse()->setRedirect($agreement->initToken());
36  } catch (\Magento\Framework\Exception\LocalizedException $e) {
37  $this->messageManager->addExceptionMessage($e, $e->getMessage());
38  } catch (\Exception $e) {
39  $this->messageManager->addExceptionMessage(
40  $e,
41  __('We can\'t start the billing agreement wizard.')
42  );
43  }
44  }
45  $this->_redirect('*/*/');
46  }
47 }
_redirect($path, $arguments=[])
Definition: Action.php:167
__()
Definition: __.php:13