Skip to content

Commit cf8ed0f

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-53714' into MPI-BUGFIXES
2 parents 7811a54 + 6dd03c2 commit cf8ed0f

File tree

6 files changed

+43
-23
lines changed

6 files changed

+43
-23
lines changed

app/code/Magento/Paypal/Model/AbstractConfig.php

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@
55
*/
66
namespace Magento\Paypal\Model;
77

8+
use Magento\Framework\App\ProductMetadataInterface;
89
use Magento\Payment\Model\Method\ConfigInterface;
910
use Magento\Payment\Model\MethodInterface;
1011
use Magento\Store\Model\ScopeInterface;
1112
use Magento\Paypal\Model\Config;
13+
use Magento\Framework\App\ObjectManager;
1214

1315
/**
1416
* Class AbstractConfig
@@ -49,6 +51,16 @@ abstract class AbstractConfig implements ConfigInterface
4951
*/
5052
protected $pathPattern;
5153

54+
/**
55+
* @var ProductMetadataInterface
56+
*/
57+
protected $productMetadata;
58+
59+
/**
60+
* @var string
61+
*/
62+
private static $bnCode = 'Magento_Cart_%s';
63+
5264
/**
5365
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
5466
*/
@@ -323,10 +335,20 @@ public function isMethodSupportedForCountry($method = null, $countryCode = null)
323335
*/
324336
public function getBuildNotationCode()
325337
{
326-
return $this->_scopeConfig->getValue(
327-
'paypal/bncode',
328-
ScopeInterface::SCOPE_STORE,
329-
$this->_storeId
330-
);
338+
return sprintf(self::$bnCode, $this->getProductMetadata()->getEdition());
339+
}
340+
341+
/**
342+
* The getter function to get the ProductMetadata
343+
*
344+
* @return ProductMetadataInterface
345+
* @deprecated
346+
*/
347+
protected function getProductMetadata()
348+
{
349+
if ($this->productMetadata === null) {
350+
$this->productMetadata = ObjectManager::getInstance()->get(ProductMetadataInterface::class);
351+
}
352+
return $this->productMetadata;
331353
}
332354
}

app/code/Magento/Paypal/Model/Payflowpro.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ public function buildBasicRequest()
623623
$request->setPartner($this->getConfigData('partner'));
624624
$request->setPwd($this->getConfigData('pwd'));
625625
$request->setVerbosity($this->getConfigData('verbosity'));
626-
$request->setData('BNCODE', $config->getBuildNotationCode());
626+
$request->setData('BUTTONSOURCE', $config->getBuildNotationCode());
627627
$request->setTender(self::TENDER_CC);
628628

629629
return $request;

app/code/Magento/Paypal/Test/Unit/Model/AbstractConfigTest.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
use Magento\Framework\App\Config\ScopeConfigInterface;
99
use Magento\Store\Model\ScopeInterface as ModelScopeInterface;
1010
use Magento\Payment\Model\MethodInterface;
11+
use Magento\Framework\App\ProductMetadataInterface;
12+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
1113

1214
/**
1315
* Class AbstractConfigTest
@@ -290,10 +292,18 @@ public function testIsMethodActive()
290292

291293
public function testGetBuildNotationCode()
292294
{
293-
$this->scopeConfigMock->expects($this->once())
294-
->method('getValue')
295-
->with('paypal/bncode');
295+
$productMetadata = $this->getMock(ProductMetadataInterface::class, [], [], '', false);
296+
$productMetadata->expects($this->once())
297+
->method('getEdition')
298+
->will($this->returnValue('SomeEdition'));
299+
300+
$objectManagerHelper = new ObjectManagerHelper($this);
301+
$objectManagerHelper->setBackwardCompatibleProperty(
302+
$this->config,
303+
'productMetadata',
304+
$productMetadata
305+
);
296306

297-
$this->config->getBuildNotationCode();
307+
$this->assertEquals('Magento_Cart_SomeEdition', $this->config->getBuildNotationCode());
298308
}
299309
}

app/code/Magento/Paypal/Test/Unit/Model/ConfigTest.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,17 +99,6 @@ public function testGetCountryMethods()
9999
$this->assertNotContains(Config::METHOD_WPP_BML, $this->model->getCountryMethods('DE'));
100100
}
101101

102-
public function testGetBuildNotationCode()
103-
{
104-
$this->model->setMethod('payflow_direct');
105-
$this->model->setStoreId(123);
106-
$this->scopeConfig->expects($this->once())
107-
->method('getValue')
108-
->with('paypal/bncode', ScopeInterface::SCOPE_STORE, 123)
109-
->will($this->returnValue('some BN code'));
110-
$this->assertEquals('some BN code', $this->model->getBuildNotationCode());
111-
}
112-
113102
public function testIsMethodActive()
114103
{
115104
$this->assertFalse($this->model->isMethodActive('payflow_direct'));

app/code/Magento/Paypal/Test/Unit/Model/PayflowlinkTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function testInitialize()
146146
'partner' => null,
147147
'pwd' => null,
148148
'verbosity' => null,
149-
'BNCODE' => 'build notation code',
149+
'BUTTONSOURCE' => 'build notation code',
150150
'tender' => 'C',
151151
],
152152
$this->returnSelf()

app/code/Magento/Paypal/etc/config.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd">
99
<default>
1010
<paypal>
11-
<bncode>Magento_Cart_Community</bncode>
1211
<style>
1312
<logo></logo>
1413
</style>

0 commit comments

Comments
 (0)