diff --git a/projects/magento/pageObjects/plugin/PaymentDetails.page.js b/projects/magento/pageObjects/plugin/PaymentDetails.page.js index 36a900c..c964547 100644 --- a/projects/magento/pageObjects/plugin/PaymentDetails.page.js +++ b/projects/magento/pageObjects/plugin/PaymentDetails.page.js @@ -49,7 +49,7 @@ export class PaymentDetailsPage { await this.paymentMethodSaveCheckBox.click(); } - async selectVault(lastFourDigits) { + async selectVaultCC(lastFourDigits) { // Not ideal way of selecting saved card due to vault UI structure lastFourDigits != undefined ? await this.page.locator(`text=Ending ${lastFourDigits} ( expires: 3/2030 )`).click() @@ -57,6 +57,13 @@ export class PaymentDetailsPage { await this.waitForPaymentMethodReady(); } + async selectVaultSepaDirectDebit() { + const d = new Date(); + const formattedDate = d.toISOString().split('T')[0]; + await this.page.locator(`text=SEPA Direct Debit token created on ${formattedDate}`).first().click(); + await this.waitForPaymentMethodReady(); + } + async selectCreditCard() { await this.creditCardRadioButton.click(); await this.waitForPaymentMethodReady(); diff --git a/projects/magento/tests/loggedIn/StoredCardPayment.js b/projects/magento/tests/loggedIn/StoredCardPayment.js index fd734cd..6a2682c 100644 --- a/projects/magento/tests/loggedIn/StoredCardPayment.js +++ b/projects/magento/tests/loggedIn/StoredCardPayment.js @@ -14,6 +14,7 @@ import { ThreeDS2PaymentPage } from "../../../common/redirect/ThreeDS2PaymentPag const paymentResources = new PaymentResources(); const magentoSampleUser = paymentResources.sampleRegisteredUser; const users = paymentResources.guestUser; +const ibanDetails = paymentResources.sepaDirectDebit.nl; /* No parallelism due to usage of same user account since it will cause the cart to reset */ @@ -43,7 +44,7 @@ test.describe("Payment via stored credit card", () => { await goToShippingWithFullCart(page); await proceedToPaymentAs(page, undefined, false); - await makeVaultPayment(page, paymentResources.masterCard3DS2, paymentResources.cvc); + await makeCCVaultPayment(page, paymentResources.masterCard3DS2, paymentResources.cvc); await new ThreeDS2PaymentPage(page).validate3DS2( paymentResources.threeDSCorrectPassword ); @@ -80,12 +81,28 @@ test.describe("Payment via stored credit card", () => { await goToShippingWithFullCart(page); await proceedToPaymentAs(page, undefined, false); - await makeVaultPayment(page, paymentResources.masterCardWithout3D, paymentResources.cvc); + await makeCCVaultPayment(page, paymentResources.masterCardWithout3D, paymentResources.cvc); await verifySuccessfulPayment(page); }); }); +test.describe('Payment via stored SEPA token', () => { + test.beforeEach(async ({ page }) => { + await loginAs(page, magentoSampleUser); + }); + + test('should succeed', async ({ page }) => { + await goToShippingWithFullCart(page); + await proceedToPaymentAs(page, undefined, false); + await makeSepaDirectDebitPayment(page, ibanDetails); + + await goToShippingWithFullCart(page); + await proceedToPaymentAs(page, undefined, false); + await makeSepaDirectDebitVaultPayment(page); + }); +}); + async function makeCreditCardPayment( page, user, @@ -112,9 +129,29 @@ async function makeCreditCardPayment( await placeOrder(page); } -async function makeVaultPayment(page, creditCardNumber, cvc) { - await new PaymentDetailsPage(page).selectVault(creditCardNumber.slice(-4)); +async function makeCCVaultPayment(page, creditCardNumber, cvc) { + await new PaymentDetailsPage(page).selectVaultCC(creditCardNumber.slice(-4)); await new CreditCardComponentsMagento(page.locator(".payment-method._active")).fillCVC(cvc); await placeOrder(page); } + +async function makeSepaDirectDebitPayment(page, ibanDetails) { + const paymentDetailsPage = new PaymentDetailsPage(page); + const sepaPaymentSection = await paymentDetailsPage.selectSepaDirectDebit(); + await sepaPaymentSection.fillSepaDirectDebitInfo( + ibanDetails.accountName, + ibanDetails.iban + ); + await placeOrder(page); + + await verifySuccessfulPayment(page); +} + +async function makeSepaDirectDebitVaultPayment(page) { + await new PaymentDetailsPage(page).selectVaultSepaDirectDebit(); + + await placeOrder(page); + + await verifySuccessfulPayment(page); +}