Skip to content
This repository was archived by the owner on Apr 29, 2019. It is now read-only.

Commit 803dbe4

Browse files
author
olysenko
committed
Merge remote-tracking branch 'mainline/2.3-develop' into MAGETWO-89382
2 parents d5381fa + d2a037f commit 803dbe4

File tree

201 files changed

+5096
-1917
lines changed

Some content is hidden

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

201 files changed

+5096
-1917
lines changed

.travis.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ services:
1616
- elasticsearch
1717
language: php
1818
php:
19-
- 7.0
2019
- 7.1
2120
env:
2221
global:
@@ -33,16 +32,6 @@ env:
3332
- TEST_SUITE=integration INTEGRATION_INDEX=2
3433
- TEST_SUITE=integration INTEGRATION_INDEX=3
3534
- TEST_SUITE=functional
36-
matrix:
37-
exclude:
38-
- php: 7.0
39-
env: TEST_SUITE=static
40-
- php: 7.0
41-
env: TEST_SUITE=js GRUNT_COMMAND=spec
42-
- php: 7.0
43-
env: TEST_SUITE=js GRUNT_COMMAND=static
44-
- php: 7.0
45-
env: TEST_SUITE=functional
4635
cache:
4736
apt: true
4837
directories:
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Backend\Ui\Component\Control;
9+
10+
use Magento\Framework\App\RequestInterface;
11+
use Magento\Framework\Escaper;
12+
use Magento\Framework\UrlInterface;
13+
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
14+
15+
/**
16+
* Represents delete button with pre-configured options
17+
* Provide an ability to show confirmation message on click on the "Delete" button
18+
*
19+
* @api
20+
*/
21+
class DeleteButton implements ButtonProviderInterface
22+
{
23+
/**
24+
* @var RequestInterface
25+
*/
26+
private $request;
27+
28+
/**
29+
* @var UrlInterface
30+
*/
31+
private $urlBuilder;
32+
33+
/**
34+
* @var Escaper
35+
*/
36+
private $escaper;
37+
38+
/**
39+
* @var string
40+
*/
41+
private $confirmationMessage;
42+
43+
/**
44+
* @var string
45+
*/
46+
private $idFieldName;
47+
48+
/**
49+
* @var string
50+
*/
51+
private $deleteRoutePath;
52+
53+
/**
54+
* @var int
55+
*/
56+
private $sortOrder;
57+
58+
/**
59+
* @param RequestInterface $request
60+
* @param UrlInterface $urlBuilder
61+
* @param Escaper $escaper
62+
* @param string $confirmationMessage
63+
* @param string $idFieldName
64+
* @param string $deleteRoutePath
65+
* @param int $sortOrder
66+
*/
67+
public function __construct(
68+
RequestInterface $request,
69+
UrlInterface $urlBuilder,
70+
Escaper $escaper,
71+
string $confirmationMessage,
72+
string $idFieldName,
73+
string $deleteRoutePath,
74+
int $sortOrder
75+
) {
76+
$this->request = $request;
77+
$this->urlBuilder = $urlBuilder;
78+
$this->escaper = $escaper;
79+
$this->confirmationMessage = $confirmationMessage;
80+
$this->idFieldName = $idFieldName;
81+
$this->deleteRoutePath = $deleteRoutePath;
82+
$this->sortOrder = $sortOrder;
83+
}
84+
85+
/**
86+
* {@inheritdoc}
87+
*/
88+
public function getButtonData()
89+
{
90+
$data = [];
91+
$fieldId = $this->escaper->escapeJs($this->escaper->escapeHtml($this->request->getParam($this->idFieldName)));
92+
if (null !== $fieldId) {
93+
$url = $this->urlBuilder->getUrl($this->deleteRoutePath);
94+
$escapedMessage = $this->escaper->escapeJs($this->escaper->escapeHtml($this->confirmationMessage));
95+
$data = [
96+
'label' => __('Delete'),
97+
'class' => 'delete',
98+
'on_click' => "deleteConfirm('{$escapedMessage}', '{$url}', {data:{{$this->idFieldName}:{$fieldId}}})",
99+
'sort_order' => $this->sortOrder,
100+
];
101+
}
102+
return $data;
103+
}
104+
}

app/code/Magento/Braintree/Block/Form.php

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
use Magento\Braintree\Gateway\Config\Config as GatewayConfig;
1010
use Magento\Braintree\Model\Adminhtml\Source\CcType;
1111
use Magento\Braintree\Model\Ui\ConfigProvider;
12-
use Magento\Framework\App\ObjectManager;
1312
use Magento\Framework\View\Element\Template\Context;
1413
use Magento\Payment\Block\Form\Cc;
1514
use Magento\Payment\Helper\Data;
@@ -21,7 +20,6 @@
2120
*/
2221
class Form extends Cc
2322
{
24-
2523
/**
2624
* @var Quote
2725
*/
@@ -48,6 +46,7 @@ class Form extends Cc
4846
* @param Quote $sessionQuote
4947
* @param GatewayConfig $gatewayConfig
5048
* @param CcType $ccType
49+
* @param Data $paymentDataHelper
5150
* @param array $data
5251
*/
5352
public function __construct(
@@ -56,12 +55,14 @@ public function __construct(
5655
Quote $sessionQuote,
5756
GatewayConfig $gatewayConfig,
5857
CcType $ccType,
58+
Data $paymentDataHelper,
5959
array $data = []
6060
) {
6161
parent::__construct($context, $paymentConfig, $data);
6262
$this->sessionQuote = $sessionQuote;
6363
$this->gatewayConfig = $gatewayConfig;
6464
$this->ccType = $ccType;
65+
$this->paymentDataHelper = $paymentDataHelper;
6566
}
6667

6768
/**
@@ -81,7 +82,7 @@ public function getCcAvailableTypes()
8182
*/
8283
public function useCvv()
8384
{
84-
return $this->gatewayConfig->isCvvEnabled();
85+
return $this->gatewayConfig->isCvvEnabled($this->sessionQuote->getStoreId());
8586
}
8687

8788
/**
@@ -90,9 +91,8 @@ public function useCvv()
9091
*/
9192
public function isVaultEnabled()
9293
{
93-
$storeId = $this->_storeManager->getStore()->getId();
9494
$vaultPayment = $this->getVaultPayment();
95-
return $vaultPayment->isActive($storeId);
95+
return $vaultPayment->isActive($this->sessionQuote->getStoreId());
9696
}
9797

9898
/**
@@ -102,7 +102,10 @@ public function isVaultEnabled()
102102
private function getConfiguredCardTypes()
103103
{
104104
$types = $this->ccType->getCcTypeLabelMap();
105-
$configCardTypes = array_fill_keys($this->gatewayConfig->getAvailableCardTypes(), '');
105+
$configCardTypes = array_fill_keys(
106+
$this->gatewayConfig->getAvailableCardTypes($this->sessionQuote->getStoreId()),
107+
''
108+
);
106109

107110
return array_intersect_key($types, $configCardTypes);
108111
}
@@ -116,7 +119,11 @@ private function getConfiguredCardTypes()
116119
private function filterCardTypesForCountry(array $configCardTypes, $countryId)
117120
{
118121
$filtered = $configCardTypes;
119-
$countryCardTypes = $this->gatewayConfig->getCountryAvailableCardTypes($countryId);
122+
$countryCardTypes = $this->gatewayConfig->getCountryAvailableCardTypes(
123+
$countryId,
124+
$this->sessionQuote->getStoreId()
125+
);
126+
120127
// filter card types only if specific card types are set for country
121128
if (!empty($countryCardTypes)) {
122129
$availableTypes = array_fill_keys($countryCardTypes, '');
@@ -131,19 +138,6 @@ private function filterCardTypesForCountry(array $configCardTypes, $countryId)
131138
*/
132139
private function getVaultPayment()
133140
{
134-
return $this->getPaymentDataHelper()->getMethodInstance(ConfigProvider::CC_VAULT_CODE);
135-
}
136-
137-
/**
138-
* Get payment data helper instance
139-
* @return Data
140-
* @deprecated 100.1.0
141-
*/
142-
private function getPaymentDataHelper()
143-
{
144-
if ($this->paymentDataHelper === null) {
145-
$this->paymentDataHelper = ObjectManager::getInstance()->get(Data::class);
146-
}
147-
return $this->paymentDataHelper;
141+
return $this->paymentDataHelper->getMethodInstance(ConfigProvider::CC_VAULT_CODE);
148142
}
149143
}

app/code/Magento/Braintree/Block/Payment.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ public function getPaymentConfig()
4848
$payment = $this->config->getConfig()['payment'];
4949
$config = $payment[$this->getCode()];
5050
$config['code'] = $this->getCode();
51+
$config['clientTokenUrl'] = $this->_urlBuilder->getUrl(
52+
'braintree/payment/getClientToken',
53+
['_secure' => true]
54+
);
5155
return json_encode($config, JSON_UNESCAPED_SLASHES);
5256
}
5357

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Braintree\Controller\Adminhtml\Payment;
7+
8+
use Magento\Backend\App\Action;
9+
use Magento\Backend\App\Action\Context;
10+
use Magento\Backend\Model\Session\Quote;
11+
use Magento\Braintree\Gateway\Config\Config;
12+
use Magento\Braintree\Gateway\Request\PaymentDataBuilder;
13+
use Magento\Braintree\Model\Adapter\BraintreeAdapterFactory;
14+
use Magento\Framework\Controller\ResultFactory;
15+
16+
/**
17+
* Retrieves client token.
18+
*/
19+
class GetClientToken extends Action
20+
{
21+
const ADMIN_RESOURCE = 'Magento_Braintree::get_client_token';
22+
23+
/**
24+
* @var Config
25+
*/
26+
private $config;
27+
28+
/**
29+
* @var BraintreeAdapterFactory
30+
*/
31+
private $adapterFactory;
32+
33+
/**
34+
* @var Quote
35+
*/
36+
private $quoteSession;
37+
38+
/**
39+
* @param Context $context
40+
* @param Config $config
41+
* @param BraintreeAdapterFactory $adapterFactory
42+
* @param Quote $quoteSession
43+
*/
44+
public function __construct(
45+
Context $context,
46+
Config $config,
47+
BraintreeAdapterFactory $adapterFactory,
48+
Quote $quoteSession
49+
) {
50+
parent::__construct($context);
51+
$this->config = $config;
52+
$this->adapterFactory = $adapterFactory;
53+
$this->quoteSession = $quoteSession;
54+
}
55+
56+
/**
57+
* @inheritdoc
58+
*/
59+
public function execute()
60+
{
61+
$params = [];
62+
$response = $this->resultFactory->create(ResultFactory::TYPE_JSON);
63+
64+
$storeId = $this->quoteSession->getStoreId();
65+
$merchantAccountId = $this->config->getMerchantAccountId($storeId);
66+
if (!empty($merchantAccountId)) {
67+
$params[PaymentDataBuilder::MERCHANT_ACCOUNT_ID] = $merchantAccountId;
68+
}
69+
70+
$clientToken = $this->adapterFactory->create($storeId)
71+
->generate($params);
72+
$response->setData(['clientToken' => $clientToken]);
73+
74+
return $response;
75+
}
76+
}

app/code/Magento/Braintree/Controller/Payment/GetNonce.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ public function execute()
6262
try {
6363
$publicHash = $this->getRequest()->getParam('public_hash');
6464
$customerId = $this->session->getCustomerId();
65-
$result = $this->command->execute(['public_hash' => $publicHash, 'customer_id' => $customerId])->get();
65+
$result = $this->command->execute(
66+
['public_hash' => $publicHash, 'customer_id' => $customerId, 'store_id' => $this->session->getStoreId()]
67+
)
68+
->get();
6669
$response->setData(['paymentMethodNonce' => $result['paymentMethodNonce']]);
6770
} catch (\Exception $e) {
6871
$this->logger->critical($e);

0 commit comments

Comments
 (0)