Skip to content

Commit 6b180a8

Browse files
committed
Resolved Paypal merge Conflicts
2 parents b8b5964 + 0934c4b commit 6b180a8

File tree

6 files changed

+163
-29
lines changed

6 files changed

+163
-29
lines changed

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

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ class SdkUrl
4242
private $queryParams = [];
4343

4444
/**
45-
*
4645
* @var array
4746
*/
4847
private $disallowedFundingMap;
@@ -54,13 +53,19 @@ class SdkUrl
5453
*/
5554
private $unsupportedPaymentMethods;
5655

56+
/**
57+
* These payment methods will be added as parameters to the SDK url to enable them.
58+
*
59+
* @var array
60+
*/
61+
private $supportedPaymentMethods;
62+
5763
/**
5864
* @var ResolverInterface
5965
*/
6066
private $localeResolver;
6167

6268
/**
63-
*
6469
* @var string
6570
*/
6671
private $url;
@@ -72,14 +77,16 @@ class SdkUrl
7277
* @param StoreManagerInterface $storeManager
7378
* @param array $disallowedFundingMap
7479
* @param array $unsupportedPaymentMethods
80+
* @param array $supportedPaymentMethods
7581
*/
7682
public function __construct(
7783
ResolverInterface $localeResolver,
7884
ConfigFactory $configFactory,
7985
ScopeConfigInterface $scopeConfig,
8086
StoreManagerInterface $storeManager,
8187
$disallowedFundingMap = [],
82-
$unsupportedPaymentMethods = []
88+
$unsupportedPaymentMethods = [],
89+
$supportedPaymentMethods = []
8390
) {
8491
$this->localeResolver = $localeResolver;
8592
$this->config = $configFactory->create();
@@ -88,6 +95,7 @@ public function __construct(
8895
$this->storeManager = $storeManager;
8996
$this->disallowedFundingMap = $disallowedFundingMap;
9097
$this->unsupportedPaymentMethods = $unsupportedPaymentMethods;
98+
$this->supportedPaymentMethods = $supportedPaymentMethods;
9199
}
92100

93101
/**
@@ -104,6 +112,7 @@ public function getUrl(): string
104112
'locale' => $this->localeResolver->getLocale(),
105113
'currency' => $this->storeManager->getStore()->getBaseCurrencyCode(),
106114
'buyer-country' => $this->getBuyerCountry(),
115+
'enable-funding' => $this->getAllowedFunding(),
107116
];
108117

109118
if ($this->areMessagesEnabled()) {
@@ -207,6 +216,23 @@ private function getDisallowedFunding()
207216
return implode(',', $result);
208217
}
209218

219+
/**
220+
* Returns allowed funding from configuration after validating
221+
*
222+
* @return string
223+
*/
224+
private function getAllowedFunding(): string
225+
{
226+
$payLaterActive = (bool)$this->config->getPayLaterConfigValue('experience_active');
227+
228+
// If Pay Later is disabled, paylater parameter will be removed from enable-funding parameter list
229+
if (!$payLaterActive) {
230+
unset($this->supportedPaymentMethods['paylater']);
231+
232+
}
233+
return implode(',', $this->supportedPaymentMethods);
234+
}
235+
210236
/**
211237
* Returns if is allowed PayPal Guest Checkout.
212238
*

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

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ protected function setUp(): void
7575
$scopeConfigMock,
7676
$storeManagerMock,
7777
$this->getDisallowedFundingMap(),
78-
$this->getUnsupportedPaymentMethods()
78+
$this->getUnsupportedPaymentMethods(),
79+
$this->getSupportedPaymentMethods()
7980
);
8081
}
8182

@@ -115,6 +116,11 @@ public function testGetConfig(
115116
],
116117
]
117118
);
119+
120+
$this->configMock->method('getPayLaterConfigValue')
121+
->with('experience_active')
122+
->willReturn(true);
123+
118124
self::assertEquals($expected['sdkUrl'], $this->model->getUrl());
119125
}
120126

@@ -152,14 +158,27 @@ private function getDisallowedFundingMap()
152158
private function getUnsupportedPaymentMethods()
153159
{
154160
return [
155-
'venmo' => 'venmo',
156161
'bancontact' => 'bancontact',
157162
'eps' => 'eps',
158163
'giropay' => 'giropay',
159164
'ideal' => 'ideal',
160165
'mybank' => 'mybank',
161166
'p24' => 'p24',
162-
'sofort' => 'sofort'
167+
'sofort' => 'sofort',
168+
];
169+
}
170+
171+
/**
172+
* Get supported payment methods
173+
* See app/code/Magento/Paypal/etc/frontend/di.xml
174+
*
175+
* @return string[]
176+
*/
177+
private function getSupportedPaymentMethods()
178+
{
179+
return [
180+
'venmo'=> 'venmo',
181+
'paylater'=> 'paylater',
163182
];
164183
}
165184
}

app/code/Magento/Paypal/Test/Unit/Model/_files/expected_url_config.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ function generateExpectedPaypalSdkUrl(array $params) : String
2828
'client-id' => 'sb',
2929
'locale' => 'es_MX',
3030
'currency' => 'USD',
31+
'enable-funding' => implode(',', ['venmo', 'paylater']),
3132
'commit' => 'false',
3233
'intent' => 'authorize',
3334
'merchant-id' => 'merchant',
@@ -37,7 +38,6 @@ function generateExpectedPaypalSdkUrl(array $params) : String
3738
'credit',
3839
'sepa',
3940
'card',
40-
'venmo',
4141
'bancontact',
4242
'eps',
4343
'giropay',
@@ -64,12 +64,13 @@ function generateExpectedPaypalSdkUrl(array $params) : String
6464
'client-id' => 'sb',
6565
'locale' => 'en_BR',
6666
'currency' => 'USD',
67+
'enable-funding' => implode(',', ['venmo', 'paylater']),
6768
'commit' => 'false',
6869
'intent' => 'capture',
6970
'merchant-id' => 'merchant',
7071
'disable-funding' => implode(
7172
',',
72-
['venmo', 'bancontact', 'eps', 'giropay', 'ideal', 'mybank', 'p24', 'sofort']
73+
['bancontact', 'eps', 'giropay', 'ideal', 'mybank', 'p24', 'sofort']
7374
),
7475
'components' => implode(',', ['messages', 'buttons']),
7576
]
@@ -88,12 +89,13 @@ function generateExpectedPaypalSdkUrl(array $params) : String
8889
'client-id' => 'sb',
8990
'locale' => 'en_US',
9091
'currency' => 'USD',
92+
'enable-funding' => implode(',', ['venmo', 'paylater']),
9193
'commit' => 'false',
9294
'intent' => 'order',
9395
'merchant-id' => 'merchant',
9496
'disable-funding' => implode(
9597
',',
96-
['venmo', 'bancontact', 'eps', 'giropay', 'ideal', 'mybank', 'p24', 'sofort']
98+
['bancontact', 'eps', 'giropay', 'ideal', 'mybank', 'p24', 'sofort']
9799
),
98100
'components' => implode(',', ['messages', 'buttons']),
99101
]
@@ -112,6 +114,7 @@ function generateExpectedPaypalSdkUrl(array $params) : String
112114
'client-id' => 'sb',
113115
'locale' => 'en_BR',
114116
'currency' => 'USD',
117+
'enable-funding' => implode(',', ['venmo', 'paylater']),
115118
'commit' => 'false',
116119
'intent' => 'authorize',
117120
'merchant-id' => 'merchant',
@@ -121,7 +124,6 @@ function generateExpectedPaypalSdkUrl(array $params) : String
121124
'credit',
122125
'sepa',
123126
'card',
124-
'venmo',
125127
'bancontact',
126128
'eps',
127129
'giropay',
@@ -148,12 +150,13 @@ function generateExpectedPaypalSdkUrl(array $params) : String
148150
'client-id' => 'sb',
149151
'locale' => 'en_BR',
150152
'currency' => 'USD',
153+
'enable-funding' => implode(',', ['venmo', 'paylater']),
151154
'commit' => 'false',
152155
'intent' => 'authorize',
153156
'merchant-id' => 'merchant',
154157
'disable-funding' => implode(
155158
',',
156-
['credit', 'sepa', 'venmo', 'bancontact', 'eps', 'giropay', 'ideal', 'mybank', 'p24', 'sofort']
159+
['credit', 'sepa', 'bancontact', 'eps', 'giropay', 'ideal', 'mybank', 'p24', 'sofort']
157160
),
158161
'components' => implode(',', ['messages', 'buttons']),
159162
]

app/code/Magento/Paypal/etc/adminhtml/system.xml

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@
2828
<group id="other_paypal_payment_solutions" translate="label" sortOrder="3" showInDefault="1" showInWebsite="1" showInStore="1">
2929
<label>Other PayPal Payment Solutions:</label>
3030
<fieldset_css>paypal-top-section paypal-other-header</fieldset_css>
31-
<frontend_model>\Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
31+
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
3232
</group>
3333
<group id="other_payment_methods" translate="label" sortOrder="4" showInDefault="1" showInWebsite="1" showInStore="1">
3434
<label>Other Payment Methods:</label>
3535
<attribute type="expanded">1</attribute>
3636
<fieldset_css>paypal-top-section payments-other-header</fieldset_css>
37-
<frontend_model>\Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
37+
<frontend_model>Magento\Config\Block\System\Config\Form\Fieldset</frontend_model>
3838
</group>
3939
</section>
4040
<section id="payment_all_paypal" showInDefault="0" showInWebsite="0" showInStore="0">
@@ -51,8 +51,8 @@
5151
</group>
5252
<group id="payments_pro_hosted_solution_without_bml_and_paylater" extends="payments_pro_hosted_solution_without_bml">
5353
<group id="pphs_required_settings">
54-
<field id="enable_paypal_paylater_experience" showInDefault="0" showInWebsite="0"/>
55-
<group id="pphs_advertise_paylater" showInDefault="0" showInWebsite="0"/>
54+
<field id="enable_paypal_paylater_experience" showInDefault="1" showInWebsite="1"/>
55+
<group id="pphs_advertise_paylater" showInDefault="1" showInWebsite="1"/>
5656
</group>
5757
</group>
5858
<include path="Magento_Paypal::system/payments_pro_hosted_solution_with_express_checkout.xml"/>
@@ -204,9 +204,9 @@
204204
</field>
205205
<field id="enable_express_checkout_bml" showInDefault="0" showInWebsite="0"/>
206206
<field id="express_checkout_bml_sort_order" showInDefault="0" showInWebsite="0"/>
207-
<field id="enable_paypal_paylater_experience" showInDefault="0" showInWebsite="0"/>
207+
<field id="enable_paypal_paylater_experience" showInDefault="1" showInWebsite="1"/>
208208
<group id="advertise_bml" showInDefault="0" showInWebsite="0"/>
209-
<group id="advertise_paylater" showInDefault="0" showInWebsite="0"/>
209+
<group id="advertise_paylater" showInDefault="1" showInWebsite="1"/>
210210
</group>
211211
<group id="settings_ec" translate="label">
212212
<label>Basic Settings - PayPal Website Payments Standard</label>
@@ -247,9 +247,9 @@
247247
<group id="express_checkout_required">
248248
<field id="enable_express_checkout_bml" showInDefault="0" showInWebsite="0"/>
249249
<field id="express_checkout_bml_sort_order" showInDefault="0" showInWebsite="0"/>
250-
<field id="enable_paypal_paylater_experience" showInDefault="0" showInWebsite="0"/>
250+
<field id="enable_paypal_paylater_experience" showInDefault="1" showInWebsite="1"/>
251251
<group id="advertise_bml" showInDefault="0" showInWebsite="0"/>
252-
<group id="advertise_paylater" showInDefault="0" showInWebsite="0"/>
252+
<group id="advertise_paylater" showInDefault="1" showInWebsite="1"/>
253253
</group>
254254
</group>
255255
<group id="paypal_group_all_in_one" translate="label comment" sortOrder="7" showInDefault="1" showInWebsite="1" showInStore="1">
@@ -279,9 +279,9 @@
279279
</field>
280280
<field id="enable_express_checkout_bml" showInDefault="0" showInWebsite="0"/>
281281
<field id="express_checkout_bml_sort_order" showInDefault="0" showInWebsite="0"/>
282-
<field id="enable_paypal_paylater_experience" showInDefault="0" showInWebsite="0"/>
282+
<field id="enable_paypal_paylater_experience" showInDefault="1" showInWebsite="1"/>
283283
<group id="advertise_bml" showInDefault="0" showInWebsite="0"/>
284-
<group id="advertise_paylater" showInDefault="0" showInWebsite="0"/>
284+
<group id="advertise_paylater" showInDefault="1" showInWebsite="1"/>
285285
</group>
286286
<group id="settings_ec">
287287
<label>Basic Settings - PayPal Website Payments Standard</label>
@@ -327,26 +327,26 @@
327327
<config_path>payment/paypal_payment_pro/active</config_path>
328328
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\Field\Enable\Payment</frontend_model>
329329
</field>
330-
<field id="enable_paypal_paylater_experience" showInDefault="0" showInWebsite="0"/>
331-
<group id="paypal_payflow_advertise_paylater" showInDefault="0" showInWebsite="0"/>
330+
<field id="enable_paypal_paylater_experience" showInDefault="1" showInWebsite="1"/>
331+
<group id="paypal_payflow_advertise_paylater" showInDefault="1" showInWebsite="1"/>
332332
</group>
333333
<group id="settings_paypal_payflow">
334334
<label>Basic Settings - PayPal Payments Pro</label>
335335
</group>
336336
</group>
337337
<group id="paypal_payflowpro_ca" extends="payment_all_paypal/paypal_payflowpro" sortOrder="40">
338338
<group id="paypal_payflow_required">
339-
<field id="enable_paypal_paylater_experience" showInDefault="0" showInWebsite="0"/>
340-
<group id="paypal_payflow_advertise_paylater" showInDefault="0" showInWebsite="0"/>
339+
<field id="enable_paypal_paylater_experience" showInDefault="1" showInWebsite="1"/>
340+
<group id="paypal_payflow_advertise_paylater" showInDefault="1" showInWebsite="1"/>
341341
</group>
342342
</group>
343343
<group id="payflow_link_ca" extends="payment_all_paypal/payflow_link" sortOrder="50">
344344
<group id="payflow_link_required">
345345
<field id="enable_express_checkout_bml" showInDefault="0" showInWebsite="0"/>
346346
<field id="express_checkout_bml_sort_order" showInDefault="0" showInWebsite="0"/>
347-
<field id="enable_paypal_paylater_experience" showInDefault="0" showInWebsite="0"/>
347+
<field id="enable_paypal_paylater_experience" showInDefault="1" showInWebsite="1"/>
348348
<group id="payflow_link_advertise_bml" showInDefault="0" showInWebsite="0"/>
349-
<group id="payflow_link_advertise_paylater" showInDefault="0" showInWebsite="0"/>
349+
<group id="payflow_link_advertise_paylater" showInDefault="1" showInWebsite="1"/>
350350
</group>
351351
</group>
352352
</group>

0 commit comments

Comments
 (0)