77
88namespace 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,35 +96,47 @@ 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 }
137105
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+ $ logoType = $ logoPosition = $ textColor = $ textSize = null ;
115+ $ color = $ ratio = null ;
116+ $ styleLayout = $ this ->config ->getPayLaterConfigValue ("$ {sectionName}_stylelayout " );
117+ if ($ styleLayout === 'text ' ) {
118+ $ logoType = $ this ->config ->getPayLaterConfigValue ("$ {sectionName}_logotype " );
119+ if ($ logoType === 'primary ' || $ logoType === 'alternative ' ) {
120+ $ logoPosition = $ this ->config ->getPayLaterConfigValue ("$ {sectionName}_logoposition " );
121+ }
122+ $ textColor = $ this ->config ->getPayLaterConfigValue ("$ {sectionName}_textcolor " );
123+ $ textSize = $ this ->config ->getPayLaterConfigValue ("$ {sectionName}_textsize " );
124+ } elseif ($ styleLayout === 'flex ' ) {
125+ $ color = $ this ->config ->getPayLaterConfigValue ("$ {sectionName}_color " );
126+ $ ratio = $ this ->config ->getPayLaterConfigValue ("$ {sectionName}_ratio " );
127+ }
128+
129+ return [
130+ 'data-pp-style-layout ' => $ styleLayout ,
131+ 'data-pp-style-logo-type ' => $ logoType ,
132+ 'data-pp-style-logo-position ' => $ logoPosition ,
133+ 'data-pp-style-text-color ' => $ textColor ,
134+ 'data-pp-style-text-size ' => $ textSize ,
135+ 'data-pp-style-color ' => $ color ,
136+ 'data-pp-style-ratio ' => $ ratio
137+ ];
138+ }
139+
138140 /**
139141 * Check if billing agreement is enabled
140142 *
0 commit comments