Skip to content

Commit d490812

Browse files
committed
Merge pull request #410 from magento-mpi/MAGETWO-32744
[MPI] Changes in PayPal configuration and move it back to CE
2 parents 1e3c29a + f9368c5 commit d490812

File tree

570 files changed

+58127
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

570 files changed

+58127
-2
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Paypal\Block\Adminhtml\Billing;
7+
8+
/**
9+
* Adminhtml billing agreement grid container
10+
*/
11+
class Agreement extends \Magento\Backend\Block\Widget\Grid\Container
12+
{
13+
/**
14+
* Initialize billing agreements grid container
15+
*
16+
* @return void
17+
*/
18+
protected function _construct()
19+
{
20+
$this->_controller = 'adminhtml_billing_agreement';
21+
$this->_blockGroup = 'Magento_Paypal';
22+
$this->_headerText = __('Billing Agreements');
23+
parent::_construct();
24+
$this->buttonList->remove('add');
25+
}
26+
}
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Paypal\Block\Adminhtml\Billing\Agreement;
7+
8+
/**
9+
* Adminhtml billing agreements grid
10+
*/
11+
class Grid extends \Magento\Backend\Block\Widget\Grid\Extended
12+
{
13+
/**
14+
* @var \Magento\Paypal\Helper\Data
15+
*/
16+
protected $_helper = null;
17+
18+
/**
19+
* @var \Magento\Paypal\Model\Resource\Billing\Agreement\CollectionFactory
20+
*/
21+
protected $_agreementFactory;
22+
23+
/**
24+
* @var \Magento\Paypal\Model\Billing\Agreement
25+
*/
26+
protected $_agreementModel;
27+
28+
/**
29+
* @param \Magento\Backend\Block\Template\Context $context
30+
* @param \Magento\Backend\Helper\Data $backendHelper
31+
* @param \Magento\Paypal\Helper\Data $helper
32+
* @param \Magento\Paypal\Model\Resource\Billing\Agreement\CollectionFactory $agreementFactory
33+
* @param \Magento\Paypal\Model\Billing\Agreement $agreementModel
34+
* @param array $data
35+
*/
36+
public function __construct(
37+
\Magento\Backend\Block\Template\Context $context,
38+
\Magento\Backend\Helper\Data $backendHelper,
39+
\Magento\Paypal\Helper\Data $helper,
40+
\Magento\Paypal\Model\Resource\Billing\Agreement\CollectionFactory $agreementFactory,
41+
\Magento\Paypal\Model\Billing\Agreement $agreementModel,
42+
array $data = []
43+
) {
44+
$this->_helper = $helper;
45+
$this->_agreementFactory = $agreementFactory;
46+
$this->_agreementModel = $agreementModel;
47+
parent::__construct($context, $backendHelper, $data);
48+
}
49+
50+
/**
51+
* Set grid params
52+
*
53+
* @return void
54+
*/
55+
protected function _construct()
56+
{
57+
parent::_construct();
58+
$this->setId('billing_agreements');
59+
$this->setUseAjax(true);
60+
$this->setDefaultSort('agreement_id');
61+
$this->setDefaultDir('DESC');
62+
$this->setSaveParametersInSession(true);
63+
}
64+
65+
/**
66+
* Retrieve grid url
67+
*
68+
* @return string
69+
*/
70+
public function getGridUrl()
71+
{
72+
return $this->getUrl('paypal/billing_agreement/grid', ['_current' => true]);
73+
}
74+
75+
/**
76+
* Retrieve row url
77+
*
78+
* @param object $item
79+
* @return string
80+
*/
81+
public function getRowUrl($item)
82+
{
83+
return $this->getUrl('paypal/billing_agreement/view', ['agreement' => $item->getAgreementId()]);
84+
}
85+
86+
/**
87+
* Prepare collection for grid
88+
*
89+
* @return $this
90+
*/
91+
protected function _prepareCollection()
92+
{
93+
/** @var \Magento\Paypal\Model\Resource\Billing\Agreement\Collection $collection */
94+
$collection = $this->_agreementFactory->create()->addCustomerDetails();
95+
$this->setCollection($collection);
96+
return parent::_prepareCollection();
97+
}
98+
99+
/**
100+
* Add columns to grid
101+
*
102+
* @return $this
103+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
104+
*/
105+
protected function _prepareColumns()
106+
{
107+
$this->addColumn(
108+
'agreement_id',
109+
[
110+
'header' => __('ID'),
111+
'index' => 'agreement_id',
112+
'type' => 'text',
113+
'header_css_class' => 'col-id',
114+
'column_css_class' => 'col-id'
115+
]
116+
);
117+
118+
$this->addColumn(
119+
'customer_email',
120+
[
121+
'header' => __('Email'),
122+
'index' => 'customer_email',
123+
'type' => 'text',
124+
'header_css_class' => 'col-mail',
125+
'column_css_class' => 'col-mail'
126+
]
127+
);
128+
129+
$this->addColumn(
130+
'customer_firstname',
131+
[
132+
'header' => __('First Name'),
133+
'index' => 'customer_firstname',
134+
'type' => 'text',
135+
'escape' => true,
136+
'header_css_class' => 'col-name',
137+
'column_css_class' => 'col-name'
138+
]
139+
);
140+
141+
$this->addColumn(
142+
'customer_lastname',
143+
[
144+
'header' => __('Last Name'),
145+
'index' => 'customer_lastname',
146+
'type' => 'text',
147+
'escape' => true,
148+
'header_css_class' => 'col-last-name',
149+
'column_css_class' => 'col-last-name'
150+
]
151+
);
152+
153+
$this->addColumn(
154+
'reference_id',
155+
[
156+
'header' => __('Reference ID'),
157+
'index' => 'reference_id',
158+
'type' => 'text',
159+
'header_css_class' => 'col-reference',
160+
'column_css_class' => 'col-reference'
161+
]
162+
);
163+
164+
$this->addColumn(
165+
'status',
166+
[
167+
'header' => __('Status'),
168+
'index' => 'status',
169+
'type' => 'options',
170+
'options' => $this->_agreementModel->getStatusesArray(),
171+
'header_css_class' => 'col-status',
172+
'column_css_class' => 'col-status'
173+
]
174+
);
175+
176+
$this->addColumn(
177+
'created_at',
178+
[
179+
'header' => __('Created'),
180+
'index' => 'created_at',
181+
'type' => 'datetime',
182+
'align' => 'center',
183+
'default' => __('N/A'),
184+
'html_decorators' => ['nobr'],
185+
'header_css_class' => 'col-period',
186+
'column_css_class' => 'col-period'
187+
]
188+
);
189+
190+
$this->addColumn(
191+
'updated_at',
192+
[
193+
'header' => __('Updated'),
194+
'index' => 'updated_at',
195+
'type' => 'datetime',
196+
'align' => 'center',
197+
'default' => __('N/A'),
198+
'html_decorators' => ['nobr'],
199+
'header_css_class' => 'col-period',
200+
'column_css_class' => 'col-period'
201+
]
202+
);
203+
204+
return parent::_prepareColumns();
205+
}
206+
}
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Paypal\Block\Adminhtml\Billing\Agreement;
7+
8+
/**
9+
* Adminhtml billing agreement view
10+
*/
11+
class View extends \Magento\Backend\Block\Widget\Form\Container
12+
{
13+
/**
14+
* Core registry
15+
*
16+
* @var \Magento\Framework\Registry
17+
*/
18+
protected $_coreRegistry = null;
19+
20+
/**
21+
* @param \Magento\Backend\Block\Widget\Context $context
22+
* @param \Magento\Framework\Registry $registry
23+
* @param array $data
24+
*/
25+
public function __construct(
26+
\Magento\Backend\Block\Widget\Context $context,
27+
\Magento\Framework\Registry $registry,
28+
array $data = []
29+
) {
30+
$this->_coreRegistry = $registry;
31+
parent::__construct($context, $data);
32+
}
33+
34+
/**
35+
* Initialize view container
36+
*
37+
* @return void
38+
*/
39+
protected function _construct()
40+
{
41+
$this->_objectId = 'agreement';
42+
$this->_controller = 'adminhtml_billing_agreement';
43+
$this->_mode = 'view';
44+
$this->_blockGroup = 'Magento_Paypal';
45+
46+
parent::_construct();
47+
48+
if (!$this->_isAllowed('Magento_Paypal::actions_manage')) {
49+
$this->buttonList->remove('delete');
50+
}
51+
$this->buttonList->remove('reset');
52+
$this->buttonList->remove('save');
53+
$this->setId('billing_agreement_view');
54+
55+
$this->buttonList->add(
56+
'back',
57+
[
58+
'label' => __('Back'),
59+
'onclick' => 'setLocation(\'' . $this->getBackUrl() . '\')',
60+
'class' => 'back'
61+
],
62+
-1
63+
);
64+
65+
$agreement = $this->_getBillingAgreement();
66+
if ($agreement && $agreement->canCancel() && $this->_isAllowed('Magento_Paypal::actions_manage')) {
67+
$confirmText = __('Are you sure you want to do this?');
68+
$this->buttonList->add(
69+
'cancel',
70+
[
71+
'label' => __('Cancel'),
72+
'onclick' => "confirmSetLocation(" . "'{$confirmText}', '{$this->_getCancelUrl()}'" . ")",
73+
'class' => 'cancel'
74+
],
75+
-1
76+
);
77+
}
78+
}
79+
80+
/**
81+
* Retrieve header text
82+
*
83+
* @return \Magento\Framework\Phrase
84+
*/
85+
public function getHeaderText()
86+
{
87+
return __('Billing Agreement #%1', $this->_getBillingAgreement()->getReferenceId());
88+
}
89+
90+
/**
91+
* Retrieve cancel billing agreement url
92+
*
93+
* @return string
94+
*/
95+
protected function _getCancelUrl()
96+
{
97+
return $this->getUrl('*/*/cancel', ['agreement' => $this->_getBillingAgreement()->getAgreementId()]);
98+
}
99+
100+
/**
101+
* Retrieve billing agreement model
102+
*
103+
* @return \Magento\Paypal\Model\Billing\Agreement
104+
*/
105+
protected function _getBillingAgreement()
106+
{
107+
return $this->_coreRegistry->registry('current_billing_agreement');
108+
}
109+
110+
/**
111+
* Check current user permissions for specified action
112+
*
113+
* @param string $resourceId
114+
* @return bool
115+
*/
116+
protected function _isAllowed($resourceId)
117+
{
118+
return $this->_authorization->isAllowed($resourceId);
119+
}
120+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Paypal\Block\Adminhtml\Billing\Agreement\View;
7+
8+
/**
9+
* Adminhtml billing agreement view plane
10+
*/
11+
class Form extends \Magento\Backend\Block\Template
12+
{
13+
/**
14+
* @var string
15+
*/
16+
protected $_template = 'billing/agreement/view/form.phtml';
17+
}

0 commit comments

Comments
 (0)