Skip to content

Commit 30b974a

Browse files
committed
Merge branch 'ACP2E-3163' of https://github.com/adobe-commerce-tier-4/magento2ce into Tier4-09-12-2024
2 parents 0f767ef + 9dacb8a commit 30b974a

File tree

5 files changed

+145
-1
lines changed

5 files changed

+145
-1
lines changed

app/code/Magento/Paypal/Model/Express/Checkout.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,7 @@ public function setCustomerWithAddressChange(
481481
*/
482482
public function start($returnUrl, $cancelUrl, $button = null)
483483
{
484+
$this->_quote->setPayment($this->_quote->getPayment());
484485
$this->_quote->collectTotals();
485486

486487
if (!$this->_quote->getGrandTotal()) {
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright 2024 Adobe
5+
* All Rights Reserved.
6+
*/
7+
-->
8+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="StorefrontPaypalExpressCheckoutPaymentMethodDiscountTest">
11+
<annotations>
12+
<features value="PayPal"/>
13+
<stories value="Paypal express checkout with discount"/>
14+
<title value="Paypal Express Checkout with payment method discount"/>
15+
<description value="Place an order with discount for using paypal express checkout as payment method applied"/>
16+
<severity value="CRITICAL"/>
17+
<testCaseId value="AC-12676"/>
18+
<useCaseId value="ACP2E-3163"/>
19+
<group value="3rd_party_integration"/>
20+
<group value="paypalExpress"/>
21+
<group value="pr_exclude"/>
22+
</annotations>
23+
<before>
24+
<!-- Simple product is created -->
25+
<createData entity="SimpleProduct" stepKey="createProduct"/>
26+
<!-- US Customer is created -->
27+
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
28+
<!-- Create new cart price rule -->
29+
<createData entity="SalesRuleDiscountOnPayPalExpressCheckoutAsPaymentMethod" stepKey="createCartPriceRule"/>
30+
<!-- Admin login -->
31+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
32+
<!-- Search Cart Price Rule and go to edit Cart Price Rule -->
33+
<actionGroup ref="AdminOpenCartPriceRulesPageActionGroup" stepKey="amOnCartPriceList"/>
34+
<fillField selector="{{AdminCartPriceRulesSection.filterByNameInput}}" userInput="$$createCartPriceRule.name$$"
35+
stepKey="fillFieldFilterByName"/>
36+
<click selector="{{AdminCartPriceRulesSection.searchButton}}" stepKey="clickSearchButton"/>
37+
<see selector="{{AdminCartPriceRulesSection.nameColumns}}" userInput="$$createCartPriceRule.name$$"
38+
stepKey="seeRuleName"/>
39+
<click selector="{{AdminCartPriceRulesSection.rowContainingText($$createCartPriceRule.name$$)}}"
40+
stepKey="goToEditRule"/>
41+
<actionGroup ref="AdminCartPriceRuleFillPaymentConditionActionGroup" stepKey="setCartAttributeConditionForCartPriceRule">
42+
<argument name="paymentMethodName" value="PayPal Express Checkout"/>
43+
</actionGroup>
44+
<actionGroup ref="AdminCartPriceRuleSaveActionGroup" stepKey="saveCartPriceRule"/>
45+
</before>
46+
<after>
47+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
48+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
49+
<!-- Delete Cart Price Rule -->
50+
<deleteData createDataKey="createCartPriceRule" stepKey="deleteCartPriceRule"/>
51+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
52+
</after>
53+
<!-- Login to StoreFront -->
54+
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="storefrontCustomerLogin">
55+
<argument name="Customer" value="$$createCustomer$$"/>
56+
</actionGroup>
57+
<!-- Add product to cart -->
58+
<actionGroup ref="AddSimpleProductToCartActionGroup" stepKey="addProductToCart">
59+
<argument name="product" value="$$createProduct$$"/>
60+
</actionGroup>
61+
<!-- Goto Checkout Page -->
62+
<actionGroup ref="StorefrontOpenCheckoutPageActionGroup" stepKey="goToCheckout"/>
63+
<actionGroup ref="CheckoutSelectFlatRateShippingMethodActionGroup" stepKey="selectFlatRateShipping" />
64+
<actionGroup ref="StorefrontCheckoutClickNextOnShippingStepActionGroup" stepKey="clickNext"/>
65+
<!-- Assert order total before applying selecting payment method -->
66+
<actionGroup ref="AssertStorefrontCheckoutPaymentSummaryTotalActionGroup" stepKey="assertSummaryTotalBeforeDiscount">
67+
<argument name="orderTotal" value="$128.00"/>
68+
</actionGroup>
69+
<!-- Click on PayPal payment radio button -->
70+
<waitForElementClickable selector="{{CheckoutPaymentSection.PayPalPaymentRadio}}" stepKey="waitForPayPalRadioButton"/>
71+
<click selector="{{CheckoutPaymentSection.PayPalPaymentRadio}}" stepKey="selectPaypalPayment"/>
72+
<!-- Assert order total before applying selecting payment method -->
73+
<actionGroup ref="AssertStorefrontCheckoutPaymentSummaryTotalActionGroup" stepKey="assertSummaryTotalAfterDiscount">
74+
<argument name="orderTotal" value="$91.10"/>
75+
</actionGroup>
76+
<actionGroup ref="SwitchToPayPalGroupBtnActionGroup" stepKey="clickPayPalBtn"/>
77+
<!-- Login to Paypal in-context and verify order total on paypal page-->
78+
<actionGroup ref="StorefrontLoginToPayPalPaymentAccountTwoStepActionGroup" stepKey="loginToPayPal"/>
79+
<waitForText selector="{{PayPalPaymentSection.orderTotalOnPaypalCheckout}}" userInput="$91.10" stepKey="verifyOrderTotalOnPaypalPage"/>
80+
<!-- Click PayPal button and go back to Magento site -->
81+
<actionGroup ref="StorefrontPaypalSwitchBackToMagentoFromCheckoutPageActionGroup" stepKey="confirmPaymentAndGoBackToMagento"/>
82+
<!-- I see order successful Page -->
83+
<actionGroup ref="AssertStorefrontCheckoutSuccessActionGroup" stepKey="assertOrderSuccess"/>
84+
<grabTextFrom selector="{{CheckoutSuccessMainSection.orderNumber22}}" stepKey="orderNumber"/>
85+
<assertNotEmpty stepKey="assertOrderIdIsNotEmpty">
86+
<actualResult type="const">$orderNumber</actualResult>
87+
</assertNotEmpty>
88+
</test>
89+
</tests>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright 2024 Adobe
5+
* All Rights Reserved.
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="AdminCartPriceRuleFillPaymentConditionActionGroup">
12+
<annotations>
13+
<description>Sets the provided Cart Attribute Payment method condition type on the Admin Cart Price Rule creation/edit page.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="paymentMethodName" type="string" defaultValue="Check / Money order"/>
17+
</arguments>
18+
<click selector="{{AdminCartPriceRulesFormSection.conditionsHeader}}" stepKey="openConditionsSection" />
19+
<click selector="{{AdminCartPriceRulesFormSection.addCondition('1')}}" stepKey="addCondition"/>
20+
<selectOption selector="{{AdminCartPriceRulesFormSection.conditionSelectDropdown('1')}}" userInput="Payment Method" stepKey="specifyCondition"/>
21+
<waitForPageLoad stepKey="waitForConditionLoad"/>
22+
<click selector="{{AdminCartPriceRulesFormSection.targetEllipsis}}" stepKey="clickEllipsis"/>
23+
<selectOption selector="{{AdminCartPriceRulesFormSection.ruleFieldByIndex('1--1')}}" userInput="{{paymentMethodName}}" stepKey="selectPaymentMethod"/>
24+
</actionGroup>
25+
</actionGroups>

app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleAddressConditionsData.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<data key="base_subtotal_total_incl_tax">Magento\SalesRule\Model\Rule\Condition\Address|base_subtotal_total_incl_tax</data>
1414
<data key="totalItemsQty">Magento\SalesRule\Model\Rule\Condition\Address|total_qty</data>
1515
<data key="totalWeight">Magento\SalesRule\Model\Rule\Condition\Address|weight</data>
16+
<data key="paymentMethod">Magento\SalesRule\Model\Rule\Condition\Address|payment_method</data>
1617
<data key="shippingMethod">Magento\SalesRule\Model\Rule\Condition\Address|shipping_method</data>
1718
<data key="shippingPostCode">Magento\SalesRule\Model\Rule\Condition\Address|postcode</data>
1819
<data key="shippingRegion">Magento\SalesRule\Model\Rule\Condition\Address|region</data>

app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleData.xml

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,34 @@
486486
<data key="defaultRuleLabelAllStoreViews">Product attribute combination - Category</data>
487487
<data key="defaultStoreView">Product attribute combination - Category</data>
488488
</entity>
489+
490+
<entity name="SalesRuleDiscountOnPayPalExpressCheckoutAsPaymentMethod" type="SalesRule">
491+
<data key="name" unique="suffix">PaymentConditionSalesRule</data>
492+
<data key="description">Sales Rule Description</data>
493+
<array key="website_ids">
494+
<item>1</item>
495+
</array>
496+
<array key="customer_group_ids">
497+
<item>1</item>
498+
</array>
499+
<data key="uses_per_customer">0</data>
500+
<data key="is_active">true</data>
501+
<data key="stop_rules_processing">false</data>
502+
<data key="is_advanced">true</data>
503+
<data key="sort_order">1</data>
504+
<data key="simple_action">by_percent</data>
505+
<data key="discount_amount">30</data>
506+
<data key="discount_qty">0</data>
507+
<data key="discount_step">0</data>
508+
<data key="apply_to_shipping">false</data>
509+
<data key="times_used">0</data>
510+
<data key="is_rss">false</data>
511+
<data key="coupon_type">NO_COUPON</data>
512+
<data key="use_auto_generation">false</data>
513+
<data key="uses_per_coupon">0</data>
514+
<data key="simple_free_shipping">0</data>
515+
</entity>
516+
489517
<entity name="RetailerCartPriceRule" type="SalesRule">
490518
<data key="name" unique="suffix">Cart Price Rule</data>
491519
<data key="websites">Main Website</data>
@@ -669,4 +697,4 @@
669697
<data key="uses_per_coupon">2</data>
670698
<data key="simple_free_shipping">0</data>
671699
</entity>
672-
</entities>
700+
</entities>

0 commit comments

Comments
 (0)