Skip to content

Commit e4b9de6

Browse files
committed
Merge remote-tracking branch 'origin/AC-1226' into GL_Mainline_PR_25112021
2 parents f8ca08c + 1dca719 commit e4b9de6

File tree

8 files changed

+260
-29
lines changed

8 files changed

+260
-29
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Paypal\Block\Adminhtml\System\Config;
10+
11+
use Magento\Backend\Block\Template\Context;
12+
use Magento\Config\Block\System\Config\Form\Field;
13+
use Magento\Framework\App\Config\ScopeConfigInterface;
14+
use Magento\Framework\Data\Form\Element\AbstractElement;
15+
use Magento\Store\Model\ScopeInterface;
16+
17+
class PayLaterLink extends Field
18+
{
19+
/**
20+
* Location of the PayPal's "Merchant Country" config param
21+
*/
22+
private const XML_PATH_PAYPAL_MERCHANT_COUNTRY = 'paypal/general/merchant_country';
23+
24+
/**
25+
* Default country is set as US.
26+
*/
27+
private const DEFAULT_COUNTRY = 'US';
28+
29+
/**
30+
* @var array.
31+
*/
32+
private const ARRAY_PAYLATER_SUPPORTED_COUNTRIES = ['US','GB','DE','FR','AU'];
33+
34+
/**
35+
* @var ScopeConfigInterface
36+
*/
37+
private $scopeConfig;
38+
39+
/**
40+
* @param Context $context
41+
* @param ScopeConfigInterface $scopeConfig
42+
* @param array $data
43+
*/
44+
public function __construct(
45+
Context $context,
46+
ScopeConfigInterface $scopeConfig,
47+
array $data = []
48+
) {
49+
parent::__construct($context, $data);
50+
$this->scopeConfig = $scopeConfig;
51+
}
52+
53+
/**
54+
* @inheritdoc
55+
*/
56+
public function _getElementHtml(AbstractElement $element): string
57+
{
58+
$html = parent::_getElementHtml($element);
59+
$html .= $this->getPayLaterCommentHtml();
60+
$country = $this->getPayLaterCountry();
61+
62+
return (in_array($country, self::ARRAY_PAYLATER_SUPPORTED_COUNTRIES)) ?
63+
sprintf($html, strtolower($country)) : sprintf($html, strtolower(self::DEFAULT_COUNTRY));
64+
}
65+
66+
/**
67+
* Get pay later merchant country
68+
*
69+
* @return string
70+
*/
71+
private function getPayLaterCountry(): string
72+
{
73+
return $this->getRequest()->getParam('paypal_country') ?: ($this->scopeConfig->getValue(
74+
self::XML_PATH_PAYPAL_MERCHANT_COUNTRY,
75+
ScopeInterface::SCOPE_STORES
76+
) ?: self::DEFAULT_COUNTRY);
77+
}
78+
79+
/**
80+
* Get pay later comment html
81+
*
82+
* @return string
83+
*/
84+
private function getPayLaterCommentHtml(): string
85+
{
86+
return '<p class="note">
87+
Displays Pay Later messaging for available offers. Restrictions apply. Click
88+
<a href="https://developer.paypal.com/docs/business/pay-later/%s/commerce-platforms/magento2/magento-paypal/"
89+
target="_blank">here</a> to learn more</p>';
90+
}
91+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminPayPalRegionalLinkActionGroup">
12+
<annotations>
13+
<description>Expands the 'PAYPAL EXPRESS CHECKOUT PAYMENT SOLUTIONS' tab on the Admin Configuration page. Enables the provided PayPal Config type for the provided Country Code.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="payPalConfigType"/>
17+
<argument name="countryCode" type="string" defaultValue="us"/>
18+
</arguments>
19+
<click selector="{{payPalConfigType.configureBtn(countryCode)}}" stepKey="clickPayPalConfigureBtn"/>
20+
<waitForPageLoad stepKey="waitForPageLoad"/>
21+
<grabAttributeFrom userInput="href" selector="{{PayPalRegionalCommentSection.country(countryCode)}}" stepKey="grabCommentText"/>
22+
<assertStringContainsString stepKey="verifyCommentLink">
23+
<expectedResult type="string">https://developer.paypal.com/docs/business/pay-later/{{countryCode}}/commerce-platforms/magento2/magento-paypal/</expectedResult>
24+
<actualResult type="string">$grabCommentText</actualResult>
25+
</assertStringContainsString>
26+
</actionGroup>
27+
</actionGroups>
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="AdminPayPalRegionalLinkOtherActionGroup">
12+
<annotations>
13+
<description>Expands the 'PAYPAL EXPRESS CHECKOUT PAYMENT SOLUTIONS' tab on the Admin Configuration page. Enables the provided PayPal Config type for the provided Country Code.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="payPalConfigType"/>
17+
<argument name="countryCode" type="string" defaultValue="us"/>
18+
</arguments>
19+
<click selector="{{payPalConfigType.configureBtn(countryCode)}}" stepKey="clickPayPalConfigureBtn"/>
20+
<waitForPageLoad stepKey="waitForPageLoad"/>
21+
<grabAttributeFrom userInput="href" selector="{{PayPalRegionalCommentSection.other(countryCode)}}" stepKey="grabCommentText"/>
22+
<assertStringContainsString stepKey="verifyCommentLink">
23+
<expectedResult type="string">https://developer.paypal.com/docs/business/pay-later/{{countryCode}}/commerce-platforms/magento2/magento-paypal/</expectedResult>
24+
<actualResult type="string">$grabCommentText</actualResult>
25+
</assertStringContainsString>
26+
</actionGroup>
27+
</actionGroups>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
10+
<section name="PayPalRegionalCommentSection">
11+
<element name="country" type="text" selector="//tr[@id='row_payment_{{countryCode}}_paypal_alternative_payment_methods_express_checkout_{{countryCode}}_express_checkout_required_enable_paypal_paylater_experience']//td //p[@class='note'] //a[text()='here']" parameterized="true"/>
12+
<element name="other" type="text" selector="//tr[@id='row_payment_{{countryCode}}_express_checkout_other_express_checkout_required_enable_paypal_paylater_experience']//td //p[@class='note'] //a[text()='here']" parameterized="true"/>
13+
</section>
14+
</sections>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminRegionalLinkForPayLaterTest">
12+
<annotations>
13+
<features value="Paypal"/>
14+
<stories value="PayLater Comment Regional Link"/>
15+
<title value="Check Regional Comment Link For PayPal PayLater"/>
16+
<description value="Default link country for Paypal Pay Later and for all unsupported countries is US"/>
17+
<severity value="AVERAGE"/>
18+
</annotations>
19+
<before>
20+
<actionGroup ref="AdminLoginActionGroup" stepKey="login"/>
21+
</before>
22+
<after>
23+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/>
24+
</after>
25+
<amOnPage url="{{AdminConfigPaymentMethodsPage.url}}" stepKey="navigateToPaymentConfigurationPage"/>
26+
<selectOption selector="{{PaymentsConfigSection.merchantCountry}}" userInput="United Kingdom" stepKey="setMerchantCountry"/>
27+
<waitForPageLoad stepKey="waitForPageLoad"/>
28+
<actionGroup ref="AdminPayPalRegionalLinkActionGroup" stepKey="verifyPayPalCommentCommentLink">
29+
<argument name="payPalConfigType" value="PayPalExpressCheckoutConfigSection"/>
30+
<argument name="enabledOption" value="Yes"/>
31+
<argument name="countryCode" value="gb"/>
32+
</actionGroup>
33+
<selectOption selector="{{PaymentsConfigSection.merchantCountry}}" userInput="France" stepKey="setMerchantCountry2"/>
34+
<waitForPageLoad stepKey="waitForPageLoad2"/>
35+
<actionGroup ref="AdminPayPalRegionalLinkOtherActionGroup" stepKey="verifyPayPalCommentCommentLink2">
36+
<argument name="payPalConfigType" value="PayPalExpressCheckoutOtherCountryConfigSection"/>
37+
<argument name="enabledOption" value="Yes"/>
38+
<argument name="countryCode" value="fr"/>
39+
</actionGroup>
40+
<selectOption selector="{{PaymentsConfigSection.merchantCountry}}" userInput="United States" stepKey="setMerchantCountry3"/>
41+
<waitForPageLoad stepKey="waitForPageLoa3"/>
42+
<actionGroup ref="AdminPayPalRegionalLinkActionGroup" stepKey="verifyPayPalCommentCommentLink3">
43+
<argument name="payPalConfigType" value="PayPalExpressCheckoutConfigSection"/>
44+
<argument name="enabledOption" value="Yes"/>
45+
<argument name="countryCode" value="us"/>
46+
</actionGroup>
47+
</test>
48+
</tests>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminRegionalLinkWithMerchantCountryFromConfigTest">
12+
<annotations>
13+
<features value="Paypal"/>
14+
<stories value="PayLater Comment Regional Link With Merchant Country From Config"/>
15+
<title value="Check Comment Regional Link With Merchant Country From Config For PayPal PayLater"/>
16+
<description value="Default link country for Paypal Pay Later and for all unsupported countries is US"/>
17+
<severity value="AVERAGE"/>
18+
</annotations>
19+
<before>
20+
<actionGroup ref="AdminLoginActionGroup" stepKey="login"/>
21+
<magentoCLI command="config:set {{MerchantFrance.path}} {{MerchantFrance.value}}" stepKey="setMerchantCountryDefault"/>
22+
</before>
23+
<after>
24+
<magentoCLI command="config:set paypal/general/merchant_country US" stepKey="setMerchantCountry4"/>
25+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logoutFromAdmin"/>
26+
</after>
27+
<amOnPage url="{{AdminConfigPaymentMethodsPage.url}}" stepKey="navigateToPaymentConfigurationPage"/>
28+
<waitForPageLoad stepKey="waitForPageLoad"/>
29+
<actionGroup ref="AdminPayPalRegionalLinkOtherActionGroup" stepKey="verifyPayPalCommentCommentLink">
30+
<argument name="payPalConfigType" value="PayPalExpressCheckoutOtherCountryConfigSection"/>
31+
<argument name="enabledOption" value="Yes"/>
32+
<argument name="countryCode" value="fr"/>
33+
</actionGroup>
34+
<selectOption selector="{{PaymentsConfigSection.merchantCountry}}" userInput="United Kingdom" stepKey="setMerchantCountry2"/>
35+
<waitForPageLoad stepKey="waitForPageLoad2"/>
36+
<actionGroup ref="AdminPayPalRegionalLinkActionGroup" stepKey="verifyPayPalCommentCommentLink2">
37+
<argument name="payPalConfigType" value="PayPalExpressCheckoutConfigSection"/>
38+
<argument name="enabledOption" value="Yes"/>
39+
<argument name="countryCode" value="gb"/>
40+
</actionGroup>
41+
<selectOption selector="{{PaymentsConfigSection.merchantCountry}}" userInput="United States" stepKey="setMerchantCountry3"/>
42+
<waitForPageLoad stepKey="waitForPageLoa3"/>
43+
<actionGroup ref="AdminPayPalRegionalLinkActionGroup" stepKey="verifyPayPalCommentCommentLink3">
44+
<argument name="payPalConfigType" value="PayPalExpressCheckoutConfigSection"/>
45+
<argument name="enabledOption" value="Yes"/>
46+
<argument name="countryCode" value="us"/>
47+
</actionGroup>
48+
</test>
49+
</tests>

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

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,8 @@
155155
<field id="enable_express_checkout_bml" showInDefault="0" showInWebsite="0"/>
156156
<field id="express_checkout_bml_sort_order" showInDefault="0" showInWebsite="0"/>
157157
<group id="advertise_bml" showInDefault="0" showInWebsite="0"/>
158-
<group id="advertise_paylater">
159-
<field id="paylater_enabled" translate="label comment">
160-
<comment>
161-
<![CDATA[Display pay later messaging on your site for offers like Pay in 3,
162-
which lets customers pay with 3 interest- free monthly payments. We’ll show messages
163-
on your site to promote this feature for you. You may not promote pay later offers
164-
with any other content, marketing, or materials.]]>
165-
</comment>
166-
</field>
158+
<group id="advertise_paylater" showInDefault="1" showInWebsite="1">
159+
<field id="paylater_enabled" showInDefault="1" showInWebsite="1"/>
167160
</group>
168161
</group>
169162
</group>
@@ -380,20 +373,7 @@
380373
<group id="express_checkout_required">
381374
<field id="enable_paypal_paylater_experience" showInDefault="1" showInWebsite="1"/>
382375
<group id="advertise_paylater" showInDefault="1" showInWebsite="1">
383-
<field id="paylater_enabled">
384-
<comment>
385-
<![CDATA[Affichez le Paiement en 4X PayPal sur votre site. Le Paiement en 4X PayPal
386-
permet aux consommateurs français de payer en 4 versements égaux. Vous pouvez
387-
promouvoir le Paiement en 4X PayPal uniquement si vous êtes un commerçant basé en
388-
France, avec un site internet en français et une intégration PayPal standard. Les
389-
marchands ayant l’outil Vaulting (coffre-fort numérique) ou une intégration de
390-
paiements récurrents/abonnement, ainsi que ceux présentant certaines activités
391-
(vente de biens numériques / de biens non physiques) ne sont pas éligibles pour
392-
promouvoir le Paiement en 4X PayPal. Nous afficherons des messages sur votre site
393-
pour promouvoir le Paiement en 4X PayPal. Vous ne pouvez pas promouvoir le Paiement
394-
en 4X PayPal avec un autre contenu, quel qu’il soit.]]>
395-
</comment>
396-
</field>
376+
<field id="paylater_enabled" showInDefault="1" showInWebsite="1"/>
397377
</group>
398378
</group>
399379
</group>

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,9 @@
194194
</field>
195195
<field id="enable_paypal_paylater_experience" translate="label comment" type="select" sortOrder="27" showInDefault="1" showInWebsite="1">
196196
<label>Enable PayPal Pay Later Experience</label>
197-
<comment>
198-
<![CDATA[Recommended. <strong>Advertise PayPal Credit</strong> is deprecated.
199-
See PayPal Pay Later details and list of supported regions
200-
<a href="https://developer.paypal.com/docs/business/pay-later/us/#eligibility" target="_blank">
201-
here</a>.]]>
202-
</comment>
203197
<config_path>payment/paypal_paylater/experience_active</config_path>
204198
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
199+
<frontend_model>Magento\Paypal\Block\Adminhtml\System\Config\PayLaterLink</frontend_model>
205200
<attribute type="shared">1</attribute>
206201
</field>
207202
<group id="advertise_bml" translate="label comment" showInDefault="1" showInWebsite="1" sortOrder="30">

0 commit comments

Comments
 (0)