Skip to content

Commit a8135e9

Browse files
committed
MAGETWO-70870: Braintree online refund not working for two websites using individual Braintree accounts
1 parent bc776ad commit a8135e9

37 files changed

+101
-81
lines changed

app/code/Magento/Braintree/Controller/Adminhtml/Payment/GetClientToken.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
use Magento\Braintree\Model\Adapter\BraintreeAdapterFactory;
1414
use Magento\Framework\Controller\ResultFactory;
1515

16+
/**
17+
* Retrieve client token controller.
18+
*/
1619
class GetClientToken extends Action
1720
{
1821
const ADMIN_RESOURCE = 'Magento_Braintree::get_client_token';

app/code/Magento/Braintree/Gateway/Command/GetPaymentNonceCommand.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
namespace Magento\Braintree\Gateway\Command;
88

9-
use Exception;
109
use Magento\Braintree\Gateway\SubjectReader;
1110
use Magento\Braintree\Gateway\Validator\PaymentNonceResponseValidator;
1211
use Magento\Braintree\Model\Adapter\BraintreeAdapterFactory;
@@ -76,7 +75,7 @@ public function execute(array $commandSubject)
7675
$customerId = $this->subjectReader->readCustomerId($commandSubject);
7776
$paymentToken = $this->tokenManagement->getByPublicHash($publicHash, $customerId);
7877
if (!$paymentToken) {
79-
throw new Exception('No available payment tokens');
78+
throw new \Exception('No available payment tokens');
8079
}
8180

8281
$storeId = $this->subjectReader->readStoreId($commandSubject);
@@ -85,7 +84,7 @@ public function execute(array $commandSubject)
8584
$result = $this->responseValidator->validate(['response' => ['object' => $data]]);
8685

8786
if (!$result->isValid()) {
88-
throw new Exception(__(implode("\n", $result->getFailsDescription())));
87+
throw new \Exception(__(implode("\n", $result->getFailsDescription())));
8988
}
9089

9190
return $this->resultFactory->create(['array' => ['paymentMethodNonce' => $data->paymentMethodNonce->nonce]]);

app/code/Magento/Braintree/Gateway/Config/Config.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,6 @@ public function getEnvironment($storeId = null)
188188
*
189189
* @param int|null $storeId
190190
* @return string
191-
* @internal param null $storeId
192191
*/
193192
public function getKountMerchantId($storeId = null)
194193
{

app/code/Magento/Braintree/Model/Adapter/BraintreeAdapter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct($merchantId, $publicKey, $privateKey, $environment)
3737
$this->publicKey($publicKey);
3838
$this->privateKey($privateKey);
3939

40-
if ($environment == Environment::ENVIRONMENT_PRODUCTION) {
40+
if ($environment === Environment::ENVIRONMENT_PRODUCTION) {
4141
$this->environment(Environment::ENVIRONMENT_PRODUCTION);
4242
} else {
4343
$this->environment(Environment::ENVIRONMENT_SANDBOX);

app/code/Magento/Braintree/Model/Adapter/BraintreeAdapterFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct(ObjectManagerInterface $objectManager, Config $confi
3636
/**
3737
* Creates instance of Braintree Adapter.
3838
*
39-
* @param int $storeId if null is provided as an argument, then current scope will be resolved
39+
* @param int|null $storeId if null is provided as an argument, then current scope will be resolved
4040
* by \Magento\Framework\App\Config\ScopeCodeResolver (useful for most cases) but for adminhtml area the store
4141
* should be provided as the argument for correct config settings loading.
4242
* @return BraintreeAdapter
@@ -49,7 +49,7 @@ public function create($storeId = null)
4949
'merchantId' => $this->config->getMerchantId($storeId),
5050
'publicKey' => $this->config->getValue(Config::KEY_PUBLIC_KEY, $storeId),
5151
'privateKey' => $this->config->getValue(Config::KEY_PRIVATE_KEY, $storeId),
52-
'environment' => $this->config->getEnvironment($storeId)
52+
'environment' => $this->config->getEnvironment($storeId),
5353
]
5454
);
5555
}

app/code/Magento/Braintree/Model/Ui/ConfigProvider.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ public function getConfig()
7979
'kountMerchantId' => $this->config->getKountMerchantId($storeId),
8080
'hasFraudProtection' => $this->config->hasFraudProtection($storeId),
8181
'merchantId' => $this->config->getMerchantId($storeId),
82-
'ccVaultCode' => self::CC_VAULT_CODE
82+
'ccVaultCode' => self::CC_VAULT_CODE,
8383
],
8484
Config::CODE_3DSECURE => [
8585
'enabled' => $this->config->isVerify3DSecure($storeId),
8686
'thresholdAmount' => $this->config->getThresholdAmount($storeId),
87-
'specificCountries' => $this->config->get3DSecureSpecificCountries($storeId)
87+
'specificCountries' => $this->config->get3DSecureSpecificCountries($storeId),
8888
],
89-
]
89+
],
9090
];
9191
}
9292

app/code/Magento/Braintree/Test/Unit/Block/FormTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Magento\Payment\Helper\Data;
1515
use Magento\Payment\Model\Config;
1616
use Magento\Vault\Model\VaultPaymentInterface;
17-
use PHPUnit_Framework_MockObject_MockObject as MockObject;
17+
use PHPUnit\Framework\MockObject\MockObject;
1818

1919
/**
2020
* Tests \Magento\Braintree\Block\Form.
@@ -60,6 +60,9 @@ class FormTest extends \PHPUnit\Framework\TestCase
6060
*/
6161
private $paymentDataHelperMock;
6262

63+
/**
64+
* @var string
65+
*/
6366
private $storeId = '1';
6467

6568
protected function setUp()

app/code/Magento/Braintree/Test/Unit/Controller/Adminhtml/Payment/GetClientTokenTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
use Magento\Framework\Controller\ResultFactory;
1515
use Magento\Framework\Controller\ResultInterface;
1616
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
17-
use PHPUnit_Framework_MockObject_MockObject as MockObject;
17+
use PHPUnit\Framework\MockObject\MockObject;
1818

1919
/**
2020
* Tests \Magento\Braintree\Controller\Adminhtml\Payment\GetClientToken

app/code/Magento/Braintree/Test/Unit/Controller/Payment/GetNonceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1616
use Magento\Framework\Webapi\Exception;
1717
use Magento\Payment\Gateway\Command\ResultInterface as CommandResultInterface;
18-
use PHPUnit_Framework_MockObject_MockObject as MockObject;
18+
use PHPUnit\Framework\MockObject\MockObject;
1919
use Psr\Log\LoggerInterface;
2020

2121
/**

app/code/Magento/Braintree/Test/Unit/Gateway/Command/CaptureStrategyCommandTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
use Magento\Sales\Api\TransactionRepositoryInterface;
2222
use Magento\Sales\Model\Order\Payment;
2323
use Magento\Sales\Model\ResourceModel\Order\Payment\Transaction\CollectionFactory;
24-
use PHPUnit_Framework_MockObject_MockObject as MockObject;
24+
use PHPUnit\Framework\MockObject\MockObject;
2525

2626
/**
2727
* Tests \Magento\Braintree\Gateway\Command\CaptureStrategyCommand.
@@ -99,11 +99,11 @@ protected function setUp()
9999
$this->braintreeAdapterMock = $this->getMockBuilder(BraintreeAdapter::class)
100100
->disableOriginalConstructor()
101101
->getMock();
102-
/** @var BraintreeAdapterFactory|MockObject $adapterFactory */
103-
$adapterFactory = $this->getMockBuilder(BraintreeAdapterFactory::class)
102+
/** @var BraintreeAdapterFactory|MockObject $adapterFactoryMock */
103+
$adapterFactoryMock = $this->getMockBuilder(BraintreeAdapterFactory::class)
104104
->disableOriginalConstructor()
105105
->getMock();
106-
$adapterFactory->expects(self::any())
106+
$adapterFactoryMock->expects(self::any())
107107
->method('create')
108108
->willReturn($this->braintreeAdapterMock);
109109

@@ -115,7 +115,7 @@ protected function setUp()
115115
$this->filterBuilderMock,
116116
$this->searchCriteriaBuilderMock,
117117
$this->subjectReaderMock,
118-
$adapterFactory,
118+
$adapterFactoryMock,
119119
$this->braintreeSearchAdapter
120120
);
121121
}
@@ -339,12 +339,12 @@ private function getPaymentDataObjectMock()
339339
->method('getPayment')
340340
->willReturn($this->paymentMock);
341341

342-
$order = $this->getMockBuilder(OrderAdapterInterface::class)
342+
$orderMock = $this->getMockBuilder(OrderAdapterInterface::class)
343343
->disableOriginalConstructor()
344344
->getMock();
345345

346346
$mock->method('getOrder')
347-
->willReturn($order);
347+
->willReturn($orderMock);
348348

349349
return $mock;
350350
}

0 commit comments

Comments
 (0)