Skip to content

Commit 37bbfd1

Browse files
committed
ACQE-8545: Create partial refund for order paid with PayPal Billing Agreement
- New automation test file has been added
1 parent a8cf637 commit 37bbfd1

File tree

3 files changed

+132
-0
lines changed

3 files changed

+132
-0
lines changed

app/code/Magento/Paypal/Test/Mftf/Data/PaypalData.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,5 +324,7 @@
324324
<data key="status">void</data>
325325
<data key="label">Voided</data>
326326
<data key="cancelled_note">Canceled order online Amount: $15.00.</data>
327+
<data key="refund_status">Refunded</data>
328+
<data key="refund_note">We refunded $25.00 offline.</data>
327329
</entity>
328330
</entities>

app/code/Magento/Paypal/Test/Mftf/Section/CheckoutPaymentSection.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,7 @@
7676
<element name="productCharged" type="text" selector="//tr[@class='grand totals']//span[@class='price' and contains(text(),'HK$')]"/>
7777
<element name="reviewOrder" type="button" selector="//button[.//span[normalize-space(text())='Review Order']]"/>
7878
<element name="checkoutWithPaypal" type="button" selector="(//div[@class='cart-container']//input[@data-action='checkout-form-submit'])[1]" timeout="30"/>
79+
<element name="status" type="input" selector="//*[@class='admin__table-secondary creditmemo-information-table']//*[text()='{{action}}']" parameterized="true"/>
80+
<element name="creditMemoView" type="text" selector="#sales_order_view_tabs_order_creditmemos_content > div > div.admin__data-grid-wrap > table > tbody > tr > td.data-grid-actions-cell > a"/>
7981
</section>
8082
</sections>
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright 2025 Adobe
5+
* All Rights Reserved.
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="AdminRefundSalesOrderPartiallyWithPaypalBillingAgreementTest">
12+
<annotations>
13+
<features value="PayPal"/>
14+
<stories value="Partial Refund Order with billing agreement"/>
15+
<title value="Partial Refund order placed within Billing Agreement"/>
16+
<description value="Place an order with billing agreement as payment method and Refund Partially the Order"/>
17+
<severity value="MAJOR"/>
18+
<testCaseId value="AC-5289"/>
19+
<group value="3rd_party_integration"/>
20+
</annotations>
21+
<before>
22+
<!-- Simple product is created -->
23+
<createData entity="SimpleProduct" stepKey="createProduct">
24+
<field key="price">15</field>
25+
</createData>
26+
<!-- US Customer is created -->
27+
<createData entity="Simple_US_Customer_CA" stepKey="createCustomer"/>
28+
<!-- Set Billing Agreement value to Auto -->
29+
<magentoCLI command="config:set {{BillingAgreement.path}} {{BillingAgreement.value}}" stepKey="enableAutoBilling"/>
30+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
31+
<!-- Configure PayPal Express Checkout -->
32+
<actionGroup ref="AdminPayPalExpressCheckoutEnableActionGroup" stepKey="ConfigPayPalExpress">
33+
<argument name="credentials" value="SamplePaypalExpressConfig2"/>
34+
</actionGroup>
35+
<actionGroup ref="AdminPayPalExpressCheckoutEnableBillingAgreementActionGroup" stepKey="enableBillingAgreement">
36+
<argument name="countryCode" value="{{MerchantUnitedStates.value}}"/>
37+
</actionGroup>
38+
<!-- Precondition Step 1: Order is placed within PayPal Billing Agreement -->
39+
<actionGroup ref="LoginToStorefrontActionGroup" stepKey="storefrontCustomerLogin">
40+
<argument name="Customer" value="$$createCustomer$$"/>
41+
</actionGroup>
42+
<!-- Add product to cart -->
43+
<actionGroup ref="StorefrontAddSimpleProductWithQtyActionGroup" stepKey="addProductToCart">
44+
<argument name="product" value="$$createProduct$$"/>
45+
<argument name="quantity" value="2"/>
46+
</actionGroup>
47+
<!-- Go to Checkout Page -->
48+
<actionGroup ref="StorefrontOpenCheckoutPageActionGroup" stepKey="goToCheckout"/>
49+
<actionGroup ref="CheckoutSelectFlatRateShippingMethodActionGroup" stepKey="selectFlatRateShipping"/>
50+
<actionGroup ref="StorefrontCheckoutClickNextOnShippingStepActionGroup" stepKey="clickNext"/>
51+
<!-- Click on PayPal payment radio button -->
52+
<waitForElementClickable selector="{{CheckoutPaymentSection.PayPalPaymentRadio}}" stepKey="waitForPayPalRadioButton"/>
53+
<click selector="{{CheckoutPaymentSection.PayPalPaymentRadio}}" stepKey="selectPaypalPayment"/>
54+
<actionGroup ref="SwitchToPayPalGroupBtnActionGroup" stepKey="clickPayPalBtn"/>
55+
<!-- Login to Paypal in-context-->
56+
<actionGroup ref="DummyDataActionGroup" stepKey="loginToPayPal"/>
57+
<!-- Click PayPal button and go back to Magento site -->
58+
<actionGroup ref="StorefrontPaypalSwitchBackToMagentoFromCheckoutPageActionGroup" stepKey="confirmPaymentAndGoBackToMagento"/>
59+
</before>
60+
<after>
61+
<actionGroup ref="AdminPayPalExpressCheckoutDisableActionGroup" stepKey="disablePaypalExpressCheckout"/>
62+
<!-- Login to Paypal in-context-->
63+
<actionGroup ref="AdminClearPayPalExpressCheckoutDataActionGroup" stepKey="clearPaypalExpressCheckoutFields"/>
64+
<actionGroup ref="AdminPayPalExpressCheckoutDisableBillingAgreementActionGroup" stepKey="disableBillingAgreement">
65+
<argument name="countryCode" value="{{MerchantUnitedStates.value}}"/>
66+
</actionGroup>
67+
<!-- Set Billing Agreement value to default -->
68+
<magentoCLI command="config:set {{BillingAgreement.path}} {{BillingAgreement.default}}" stepKey="disableAutoBilling"/>
69+
<actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="logoutCustomer"/>
70+
<!-- Delete Data -->
71+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
72+
<deleteData createDataKey="createProduct" stepKey="deleteProduct"/>
73+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
74+
</after>
75+
<actionGroup ref="AssertStorefrontCheckoutSuccessActionGroup" stepKey="assertOrderSuccess"/>
76+
<grabTextFrom selector="{{CheckoutSuccessMainSection.orderNumber22}}" stepKey="orderNumber"/>
77+
<waitForElementVisible selector="{{CheckoutSuccessMainSection.billingAgreement}}" stepKey="waitForBillingAgreement"/>
78+
<grabTextFrom selector="{{CheckoutSuccessMainSection.billingAgreement}}" stepKey="billingAgreement"/>
79+
<assertNotEmpty stepKey="assertOrderIdIsNotEmpty">
80+
<actualResult type="const">$orderNumber</actualResult>
81+
</assertNotEmpty>
82+
<assertNotEmpty stepKey="assertBillingAgreementIsNotEmpty">
83+
<actualResult type="const">$billingAgreement</actualResult>
84+
</assertNotEmpty>
85+
<!-- Step 2&3: Go to Sales > Orders & Open the Order from preconditions -->
86+
<actionGroup ref="OpenOrderByIdActionGroup" stepKey="openOrder">
87+
<argument name="orderId" value="{$orderNumber}"/>
88+
</actionGroup>
89+
<!-- Step 4&5: Refund created order & Click OK button-->
90+
<actionGroup ref="AdminCreateInvoiceActionGroup" stepKey="createInvoice"/>
91+
<!--Create Credit Memo-->
92+
<click selector="{{AdminOrderDetailsMainActionsSection.creditMemo}}" stepKey="clickCreditMemo"/>
93+
<waitForElementClickable selector="{{AdminConfirmationModalSection.ok}}" stepKey="waitForOkButtonToBeClicked"/>
94+
<click selector="{{AdminConfirmationModalSection.ok}}" stepKey="confirmCreditMemo"/>
95+
<waitForElementVisible selector="{{AdminCreditMemoItemsSection.itemQtyToRefund('1')}}" stepKey="waitToItemToRefundTextField"/>
96+
<fillField selector="{{AdminCreditMemoItemsSection.itemQtyToRefund('1')}}" userInput="1" stepKey="partialRefund"/>
97+
<waitForElementClickable selector="{{AdminCreditMemoItemsSection.updateQty}}" stepKey="waitToClickUpdateQuantity"/>
98+
<click selector="{{AdminCreditMemoItemsSection.updateQty}}" stepKey="updateQuantityToRefund"/>
99+
<!--Step 6: Create Refund Button -->
100+
<waitForElementVisible selector="{{AdminCreditMemoItemsSection.refundbtn}}" stepKey="waitForSuccesMessagea"/>
101+
<click selector="{{AdminCreditMemoItemsSection.refundbtn}}" stepKey="clickRefundOffline"/>
102+
<actionGroup ref="AdminOrderViewCheckStatusActionGroup" stepKey="checkOrderStatus">
103+
<argument name="status" value="Processing"/>
104+
</actionGroup>
105+
<actionGroup ref="AdminOpenOrderCommentsHistoryActionGroup" stepKey="clickOnCommentsHistoryTab"/>
106+
<waitForText selector="{{AdminOrderCommentsTabSection.orderComments}}" userInput="{{BillingAgreement.refund_note}}" stepKey="seeOrderHistoryPrice"/>
107+
<!--Step 7: Go to Credit Memo Tab -->
108+
<click selector="{{AdminOrderDetailsOrderViewSection.creditMemos}}" stepKey="clickCreditMemoTab"/>
109+
<waitForElementVisible selector="{{CheckoutPaymentSection.creditMemoView}}" stepKey="seeCreditMemoViewButton"/>
110+
<click selector="{{CheckoutPaymentSection.creditMemoView}}" stepKey="clickCreditMemoViewButton"/>
111+
<waitForElementVisible selector="{{CheckoutPaymentSection.status(BillingAgreement.refund_status)}}" stepKey="waitForStatusInCreditMemo"/>
112+
<waitForText selector="{{AdminOrderTotalSection.grandTotal}}" userInput="$25.00" stepKey="checkOrderTotalInBackend"/>
113+
<waitForElementClickable selector="{{AdminProductFormActionSection.backButton}}" stepKey="waitForBackButtonToBeClicked"/>
114+
<click selector="{{AdminProductFormActionSection.backButton}}" stepKey="clickBackButton"/>
115+
<!--Step 8: Go to Transaction Tab -->
116+
<waitForElementClickable selector="{{AdminTransactionsGridSection.transactionsSectionBtn}}" stepKey="waitForTransactionsTabToBeClicked"/>
117+
<click selector="{{AdminTransactionsGridSection.transactionsSectionBtn}}" stepKey="clickTransactionsTab"/>
118+
<actionGroup ref="AdminAssertTransitionTypeStatusNewActionGroup" stepKey="assertTransactionTypeStatusForAuthorization">
119+
<argument name="transactionType" value="authorization"/>
120+
<argument name="transitionTypeStatus" value="Yes"/>
121+
</actionGroup>
122+
<actionGroup ref="AdminAssertTransitionTypeStatusNewActionGroup" stepKey="assertTransactionTypeStatusForCapture">
123+
<argument name="transactionType" value="capture"/>
124+
<argument name="transitionTypeStatus" value="No"/>
125+
</actionGroup>
126+
</test>
127+
</tests>
128+

0 commit comments

Comments
 (0)