Skip to content

Commit

Permalink
Updating web components, new upi config (#1181)
Browse files Browse the repository at this point in the history
  • Loading branch information
zenit2001 authored Oct 7, 2024
1 parent 7aaca5c commit 3b8c818
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,13 @@ function getCardConfig() {
merchantDisplayName: window.merchantAccount,
},
exposeExpiryDate: false,
onChange(state, component) {
onChange(state) {
store.isValid = state.isValid;
const method = state.data.paymentMethod.storedPaymentMethodId
? `storedCard${state.data.paymentMethod.storedPaymentMethodId}`
: store.selectedMethod;
store.updateSelectedPayment(method, 'isValid', store.isValid);
if (state.data?.paymentMethod?.storedPaymentMethodId) {
const { holderName } = component.props;
const { paymentMethod } = state.data;
paymentMethod.holderName = holderName;
store.updateSelectedPayment(method, 'stateData', {
...state.data,
paymentMethod,
});
} else {
store.updateSelectedPayment(method, 'stateData', state.data);
}
store.updateSelectedPayment(method, 'stateData', state.data);
},
onSubmit: () => {
helpers.assignPaymentMethodValue();
Expand Down Expand Up @@ -287,11 +277,7 @@ function getGiftCardConfig() {
}

function handleOnChange(state) {
let { type } = state.data.paymentMethod;
const multipleTxVariantComponents = constants.MULTIPLE_TX_VARIANTS_COMPONENTS;
if (multipleTxVariantComponents.includes(store.selectedMethod)) {
type = store.selectedMethod;
}
const { type } = state.data.paymentMethod;
store.isValid = state.isValid;
if (!store.componentsObj[type]) {
store.componentsObj[type] = {};
Expand Down Expand Up @@ -397,6 +383,29 @@ function getKlarnaConfig() {
return null;
}

function getUpiConfig() {
return {
showPayButton: true,
onSubmit: (state, component) => {
$('#dwfrm_billing').trigger('submit');
helpers.assignPaymentMethodValue();
helpers.paymentFromComponent(state.data, component);
},
onAdditionalDetails: (state) => {
document.querySelector('#additionalDetailsHidden').value = JSON.stringify(
state.data,
);
document.querySelector('#showConfirmationForm').submit();
},
onError: (component) => {
if (component) {
component.setStatus('ready');
}
document.querySelector('#showConfirmationForm').submit();
},
};
}

function setCheckoutConfiguration() {
store.checkoutConfiguration.onChange = handleOnChange;
store.checkoutConfiguration.onAdditionalDetails = handleOnAdditionalDetails;
Expand Down Expand Up @@ -425,6 +434,7 @@ function setCheckoutConfiguration() {
klarna_account: getKlarnaConfig(),
klarna_paynow: getKlarnaConfig(),
cashapp: getCashAppConfig(),
upi: getUpiConfig(),
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ module.exports = {
'amazonpay',
'applepay',
'cashapp',
'upi',
],
MULTIPLE_TX_VARIANTS_COMPONENTS: ['upi'],
};
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports = {
PAYPAL: 'paypal',
},

CAN_SKIP_SUMMARY_PAGE: ['applepay', 'cashapp'],
CAN_SKIP_SUMMARY_PAGE: ['applepay', 'cashapp', 'upi'],

SERVICE: {
PAYMENT: 'AdyenPayment',
Expand Down Expand Up @@ -100,6 +100,6 @@ module.exports = {
APPLE_DOMAIN_URL:
'/.well-known/apple-developer-merchantid-domain-association',

CHECKOUT_COMPONENT_VERSION: '5.65.0',
CHECKOUT_COMPONENT_VERSION: '5.68.0',
VERSION: '24.4.0',
};
3 changes: 0 additions & 3 deletions tests/playwright/fixtures/INR.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,18 @@ for (const environment of environments) {
test('UPI Success', async ({ page }) => {
redirectShopper = new RedirectShopper(page);
await redirectShopper.doUPIPayment('upi_collect');
await checkoutPage.completeCheckout();
await checkoutPage.isPaymentModalShown("upi_collect");
});

test('UPI Failure', async ({ page }) => {
redirectShopper = new RedirectShopper(page);
await redirectShopper.doUPIPayment('upi_collect', false);
await checkoutPage.completeCheckout();
await checkoutPage.expectRefusal();
});

test('UPI QR Success @quick', async ({ page }) => {
redirectShopper = new RedirectShopper(page);
await redirectShopper.doUPIPayment('upi_qr');
await checkoutPage.completeCheckout();
await checkoutPage.isPaymentModalShown("Scan QR code");
});
});
Expand Down
6 changes: 3 additions & 3 deletions tests/playwright/fixtures/USD.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ for (const environment of environments) {
await checkoutPage.expectRefusal();
});

test('PayPal Success @quick', async ({page}) => {
test.skip('PayPal Success @quick', async ({page}) => {
redirectShopper = new RedirectShopper(page);
await redirectShopper.doPayPalPayment(false, false, true);
await checkoutPage.expectSuccess();
Expand All @@ -93,7 +93,7 @@ for (const environment of environments) {
await page.goto(`${environment.urlExtension}`);
});

test('GiftCard Only Success @quick', async () => {
test.skip('GiftCard Only Success @quick', async () => {
await goToBillingWithFullCartGuestUser();
if (environment.name.indexOf('v5') !== -1) {
await checkoutPage.setEmail();
Expand All @@ -103,7 +103,7 @@ for (const environment of environments) {
await checkoutPage.expectSuccess();
});

test('GiftCard & Card Success @quick', async () => {
test.skip('GiftCard & Card Success @quick', async () => {
await goToBillingWithFullCartGuestUser(3);
if (environment.name.indexOf('v5') !== -1) {
await checkoutPage.setEmail();
Expand Down
2 changes: 1 addition & 1 deletion tests/playwright/fixtures/countriesEUR/DE.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ for (const environment of environments) {
}
});

test('Klarna Success @quick', async ({ page }) => {
test.skip('Klarna Success @quick', async ({ page }) => {
redirectShopper = new RedirectShopper(page);
await redirectShopper.doKlarnaPayment();
await checkoutPage.completeCheckout();
Expand Down
2 changes: 1 addition & 1 deletion tests/playwright/fixtures/countriesEUR/FR.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ test.describe.parallel(`${environment.name} EUR FR`, () => {
cards = new Cards(page);
});

test('No 3DS Amazon Pay @quick', async ({ page }) => {
test.skip('No 3DS Amazon Pay @quick', async ({ page }) => {
await checkoutPage.goToCheckoutPageWithFullCart(regionsEnum.EU);
await checkoutPage.setShopperDetails(shopperData.FR);
if (environment.name.indexOf('v5') !== -1) {
Expand Down
2 changes: 1 addition & 1 deletion tests/playwright/fixtures/countriesEUR/NL.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ for (const environment of environments) {
await checkoutPage.expectRefusal();
});

test('SEPA Success @quick', async ({ page }) => {
test.skip('SEPA Success @quick', async ({ page }) => {
pendingPayments = new PendingPayments(page);
await pendingPayments.doSEPAPayment();
await checkoutPage.completeCheckout();
Expand Down
2 changes: 1 addition & 1 deletion tests/playwright/pages/CheckoutPageSFRA5.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export default class CheckoutPageSFRA5 {
this.passwordField = page.locator('#login-form-password');
this.loginButton = page.locator('.login button[type="submit"]');

this.paymentModal = page.locator("#action-modal #adyenModalDialog");
this.paymentModal = page.locator(".additionalFields");

this.donationAmountButton = page.locator('.adyen-checkout__button').nth(0);
this.donationButton = page.locator('.adyen-checkout__button--donate');
Expand Down
2 changes: 1 addition & 1 deletion tests/playwright/pages/CheckoutPageSFRA6.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default class CheckoutPageSFRA {
this.passwordField = page.locator('#login-form-password');
this.loginButton = page.locator('.login button[type="submit"]');

this.paymentModal = page.locator("#action-modal #adyenModalDialog");
this.paymentModal = page.locator(".additionalFields");

this.donationAmountButton = page.locator('.adyen-checkout__button').nth(0);
this.donationButton = page.locator('.adyen-checkout__button--donate');
Expand Down
2 changes: 2 additions & 0 deletions tests/playwright/pages/PaymentMethodsPage.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ export default class PaymentMethodsPage {
};

initiateUPIPayment = async (paymentMethod, success = true) => {
const continueButton = this.page.locator(".adyen-checkout__button--pay");
await this.page.locator(`#rb_upi`).click();
if (paymentMethod == "upi_collect") {
await this.page.locator("#upi-button-vpa").click();
Expand All @@ -179,6 +180,7 @@ export default class PaymentMethodsPage {
if (paymentMethod == "upi_qr") {
await this.page.locator("#upi-button-qrCode").click();
}
await continueButton.click();
};


Expand Down
2 changes: 1 addition & 1 deletion tests/playwright/paymentFlows/redirectShopper.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export class RedirectShopper {
await this.page.fill('input[name="dateOfBirth"]', '1980-01-11');
await this.page.fill('input[name="shopperEmail"]', email);
// There is no static locator to click the checkbox
await this.page.locator('label:has-text("Ich stimme den")').click();
await this.page.locator('label:has-text("Ich bin mit")').click();
};

completeGiropayRedirect = async (success) => {
Expand Down

0 comments on commit 3b8c818

Please sign in to comment.