Skip to content

Commit 9950ea5

Browse files
MC-42358: Flex attributes are sent to PayPal even though Text style was configured for Message
1 parent 45a40fd commit 9950ea5

File tree

1 file changed

+36
-35
lines changed

1 file changed

+36
-35
lines changed

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

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
namespace Magento\Paypal\Model;
99

10-
use Magento\Framework\App\Config\ScopeConfigInterface;
11-
1210
/**
1311
* Provides configuration values for PayPal PayLater Banners
1412
*/
@@ -34,25 +32,17 @@ class PayLaterConfig
3432
*/
3533
private $config;
3634

37-
/**
38-
* @var ScopeConfigInterface
39-
*/
40-
private $scopeConfig;
41-
4235
/**
4336
* @var array
4437
*/
4538
private $configData = [];
4639

4740
/**
48-
* @param ScopeConfigInterface $scopeConfig
4941
* @param ConfigFactory $configFactory
5042
*/
5143
public function __construct(
52-
ScopeConfigInterface $scopeConfig,
5344
ConfigFactory $configFactory
5445
) {
55-
$this->scopeConfig = $scopeConfig;
5646
$this->config = $configFactory->create();
5747
}
5848

@@ -76,9 +66,9 @@ public function isEnabled(string $placement): bool
7666
/**
7767
* Check that PayPal Credit enabled with any PayPal express method
7868
*
79-
* @return
69+
* @return bool
8070
*/
81-
private function isPPCreditEnabled()
71+
private function isPPCreditEnabled(): bool
8272
{
8373
$isEnabled = false;
8474
if ($this->config->setMethod(Config::METHOD_EXPRESS)->getValue('in_context')) {
@@ -106,32 +96,43 @@ public function getSectionConfig(string $section, string $key)
10696
$this->configData[$section] = [
10797
'display' => (boolean)$this->config->getPayLaterConfigValue("${sectionName}_display"),
10898
'position' => $this->config->getPayLaterConfigValue("${sectionName}_position"),
109-
'style' => [
110-
'data-pp-style-layout' => $this->config->getPayLaterConfigValue(
111-
"${sectionName}_stylelayout"
112-
),
113-
'data-pp-style-logo-type' => $this->config->getPayLaterConfigValue(
114-
"${sectionName}_logotype"
115-
),
116-
'data-pp-style-logo-position' => $this->config->getPayLaterConfigValue(
117-
"${sectionName}_logoposition"
118-
),
119-
'data-pp-style-text-color' => $this->config->getPayLaterConfigValue(
120-
"${sectionName}_textcolor"
121-
),
122-
'data-pp-style-text-size' => $this->config->getPayLaterConfigValue(
123-
"${sectionName}_textsize"
124-
),
125-
'data-pp-style-color' => $this->config->getPayLaterConfigValue(
126-
"${sectionName}_color"
127-
),
128-
'data-pp-style-ratio' => $this->config->getPayLaterConfigValue(
129-
"${sectionName}_ratio"
130-
)
131-
]
99+
'style' => $this->getConfigStyles($sectionName)
132100
];
133101
}
134102

135103
return $this->configData[$section][$key];
136104
}
105+
106+
/**
107+
* Get only the config styles that are needed
108+
*
109+
* @param string $sectionName
110+
* @return array
111+
*/
112+
private function getConfigStyles(string $sectionName): array
113+
{
114+
$styleLayout = $this->config->getPayLaterConfigValue("${sectionName}_stylelayout");
115+
$logoType = $styleLayout === 'text'
116+
? $this->config->getPayLaterConfigValue("${sectionName}_logotype") : null;
117+
$logoPosition = $styleLayout === 'text' && ($logoType === 'primary' || $logoType === 'alternative')
118+
? $this->config->getPayLaterConfigValue("${sectionName}_logoposition") : null;
119+
$textColor = $styleLayout === 'text'
120+
? $this->config->getPayLaterConfigValue("${sectionName}_textcolor") : null;
121+
$textSize = $styleLayout === 'text'
122+
? $this->config->getPayLaterConfigValue("${sectionName}_textsize") : null;
123+
$color = $styleLayout === 'flex'
124+
? $this->config->getPayLaterConfigValue("${sectionName}_color") : null;
125+
$ratio = $styleLayout === 'flex'
126+
? $this->config->getPayLaterConfigValue("${sectionName}_ratio") : null;
127+
128+
return [
129+
'data-pp-style-layout' => $styleLayout,
130+
'data-pp-style-logo-type' => $logoType,
131+
'data-pp-style-logo-position' => $logoPosition,
132+
'data-pp-style-text-color' => $textColor,
133+
'data-pp-style-text-size' => $textSize,
134+
'data-pp-style-color' => $color,
135+
'data-pp-style-ratio' => $ratio
136+
];
137+
}
137138
}

0 commit comments

Comments
 (0)