From 906374126859b4f1fa57226ddf5c87cfa45554a6 Mon Sep 17 00:00:00 2001 From: Matt Caimi Date: Wed, 21 Feb 2024 16:23:26 -0500 Subject: [PATCH] SSR-1063 hop payment method constants --- src/constants/payment-method-constants.js | 8 +++- .../payment-method/payment-method.spec.js | 2 +- src/layouts/payment-method/payment-method.vue | 2 +- src/layouts/payment-page/payment-page.spec.js | 16 +++---- src/layouts/payment-page/payment-page.vue | 44 +++++++------------ src/router/index.js | 8 ++++ src/store/index.js | 2 +- src/store/store.spec.js | 2 +- vue.config.js | 2 +- 9 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/constants/payment-method-constants.js b/src/constants/payment-method-constants.js index 0af1a4de..48aa5008 100644 --- a/src/constants/payment-method-constants.js +++ b/src/constants/payment-method-constants.js @@ -1,3 +1,9 @@ +const hopPaymentMethods = Object.freeze({ + CREDIT_CARD: 'cc', + PAYPAL: 'pp', + AFTERPAY: 'ap' +}); + const paymentMethods = Object.freeze({ NONE: null, PAY_AT_TIME_OF_SERVICE: 'PayAtTimeOfService', @@ -6,4 +12,4 @@ const paymentMethods = Object.freeze({ AFTERPAY: 'Afterpay' }); -export default paymentMethods; +export { hopPaymentMethods, paymentMethods }; diff --git a/src/layouts/payment-method/payment-method.spec.js b/src/layouts/payment-method/payment-method.spec.js index dc31f064..01e06a1e 100644 --- a/src/layouts/payment-method/payment-method.spec.js +++ b/src/layouts/payment-method/payment-method.spec.js @@ -5,7 +5,7 @@ import paymentMethod from '@/layouts/payment-method/payment-method.vue'; import { shallowMount } from '@vue/test-utils'; import { getMountOptions } from '@/helpers/unit-test-helper.js'; import { useMainStore } from '@/store'; -import paymentMethods from '@/constants/payment-method-constants'; +import { paymentMethods } from '@/constants/payment-method-constants'; function setupMocks() { const mountOptions = getMountOptions(); diff --git a/src/layouts/payment-method/payment-method.vue b/src/layouts/payment-method/payment-method.vue index 71c1579c..b08cb685 100644 --- a/src/layouts/payment-method/payment-method.vue +++ b/src/layouts/payment-method/payment-method.vue @@ -52,7 +52,7 @@ import paymentMethodQuestion from '@/layouts/payment-method/payment-method-quest import settleAllPromises from '@/helpers/layout-helper'; import { useMainStore } from '@/store'; import { fetchCmsContentForPage } from '@/helpers/cms-content-helper'; -import paymentMethods from '@/constants/payment-method-constants'; +import { paymentMethods } from '@/constants/payment-method-constants'; import globalRules from '@/constants/global-rules'; import { Form } from 'vee-validate'; diff --git a/src/layouts/payment-page/payment-page.spec.js b/src/layouts/payment-page/payment-page.spec.js index c7e66af8..1b46819f 100644 --- a/src/layouts/payment-page/payment-page.spec.js +++ b/src/layouts/payment-page/payment-page.spec.js @@ -5,7 +5,7 @@ import payment from '@/layouts/payment-page/payment-page.vue'; import { shallowMount } from '@vue/test-utils'; import { getMountOptions } from '@/helpers/unit-test-helper'; import { useMainStore } from '@/store'; -import paymentMethods from '@/constants/payment-method-constants' +import { paymentMethods, hopPaymentMethods } from '@/constants/payment-method-constants.js'; // Constants const parts = { @@ -305,7 +305,7 @@ describe('payment-page.vue', () => { describe('payment type mapping', () => { describe('getPaymentType', () => { - test('Maps AFTERPAY -> ap', () => { + test('Maps AFTERPAY -> hopPaymentMethods.AFTERPAY', () => { // Arrange useMainStore().order.payment.payInAdvanceType = paymentMethods.AFTERPAY; const wrapper = setupMocks({}); @@ -314,10 +314,10 @@ describe('payment-page.vue', () => { const mapped = wrapper.vm.getPaymentType(); // Assert - expect(mapped).toBe('ap'); + expect(mapped).toBe(hopPaymentMethods.AFTERPAY); }); - test('Maps CREDIT_CARD -> cc', () => { + test('Maps CREDIT_CARD -> hopPaymentMethods.CREDIT_CARD', () => { // Arrange useMainStore().order.payment.payInAdvanceType = paymentMethods.CREDIT_CARD; const wrapper = setupMocks({}); @@ -326,10 +326,10 @@ describe('payment-page.vue', () => { const mapped = wrapper.vm.getPaymentType(); // Assert - expect(mapped).toBe('cc'); + expect(mapped).toBe(hopPaymentMethods.CREDIT_CARD); }); - test('Maps PAYPAL -> pp', () => { + test('Maps PAYPAL -> hopPaymentMethods.PAYPAL', () => { // Arrange useMainStore().order.payment.payInAdvanceType = paymentMethods.PAYPAL; const wrapper = setupMocks({}); @@ -338,7 +338,7 @@ describe('payment-page.vue', () => { const mapped = wrapper.vm.getPaymentType(); // Assert - expect(mapped).toBe('pp'); + expect(mapped).toBe(hopPaymentMethods.PAYPAL); }); test('Maps other values to self', () => { @@ -362,7 +362,7 @@ describe('payment-page.vue', () => { // Act const preVal = wrapper.vm.isPaypal; - wrapper.vm.paymentType = 'pp'; + wrapper.vm.paymentType = hopPaymentMethods.PAYPAL; await wrapper.vm.$nextTick(); const postVal = wrapper.vm.isPaypal; diff --git a/src/layouts/payment-page/payment-page.vue b/src/layouts/payment-page/payment-page.vue index 15e43070..da98875f 100644 --- a/src/layouts/payment-page/payment-page.vue +++ b/src/layouts/payment-page/payment-page.vue @@ -23,7 +23,7 @@ @@ -170,11 +170,11 @@ import settleAllPromises from '@/helpers/layout-helper'; import { Form } from 'vee-validate'; import BaseFormMixin from '@/mixins/base-form-mixin.js'; import { useMainStore } from '@/store'; -import iframeResize from '../../../node_modules/iframe-resizer/js/iframeResizer.js'; +import iframeResize from '@/../node_modules/iframe-resizer/js/iframeResizer.js'; import externalUrls from '@/router/router-constants/externalUrl-values.js'; import widgetFields from '@/constants/cms-widget-fields.js'; -import paymentMethods from '@/constants/payment-method-constants'; -import { AppointmentTypeStrings } from '@/constants/schedule-constants'; +import { hopPaymentMethods, paymentMethods } from '@/constants/payment-method-constants.js'; +import { AppointmentTypeStrings } from '@/constants/schedule-constants.js'; export default { name: 'payment-page', @@ -282,7 +282,7 @@ export default { return ''; }, isPaypal() { - if (this.paymentType === 'pp') { + if (this.paymentType === hopPaymentMethods.PAYPAL) { return true; } return false; @@ -359,7 +359,6 @@ export default { return items[1]; } } - //this.backButtonAction(); return undefined; }, getInvoiceNumber() { @@ -367,42 +366,31 @@ export default { if (workOrderNumber) { return workOrderNumber.replace('-', ''); } - //this.backButtonAction(); return undefined; }, getAddress1() { - return useMainStore().order.serviceLocation.address - ? useMainStore().order.serviceLocation.address - : useMainStore().order.serviceLocation.provider.address.streetAddress; + return useMainStore().order.serviceLocation.address ?? useMainStore().order.serviceLocation.provider.address.streetAddress; }, getAddress2() { - return useMainStore().order.serviceLocation.address2 - ? useMainStore().order.serviceLocation.address2 - : null; + return useMainStore().order.serviceLocation.address2; }, getCity() { - return useMainStore().order.serviceLocation.city - ? useMainStore().order.serviceLocation.city - : useMainStore().order.serviceLocation.provider.address.city; + return useMainStore().order.serviceLocation.city ?? useMainStore().order.serviceLocation.provider.address.city; }, getState() { - return useMainStore().order.serviceLocation.state - ? useMainStore().order.serviceLocation.state - : useMainStore().order.serviceLocation.provider.address.state; + return useMainStore().order.serviceLocation.state ?? useMainStore().order.serviceLocation.provider.address.state; }, getZipCode() { - return useMainStore().order.serviceLocation.zipCode - ? useMainStore().order.serviceLocation.zipCode - : useMainStore().order.serviceLocation.provider.address.zipCode; + return useMainStore().order.serviceLocation.zipCode ?? useMainStore().order.serviceLocation.provider.address.zipCode; }, getPaymentType() { switch (useMainStore().order.payment.payInAdvanceType) { case paymentMethods.AFTERPAY: - return 'ap'; + return hopPaymentMethods.AFTERPAY; case paymentMethods.CREDIT_CARD: - return 'cc'; + return hopPaymentMethods.CREDIT_CARD; case paymentMethods.PAYPAL: - return 'pp'; + return hopPaymentMethods.PAYPAL; default: return useMainStore().payment.payInAdvanceType; } @@ -428,9 +416,9 @@ export default { if (iframe) { iframe.onload = () => { if (iframe.contentWindow) { - if (this.paymentType === 'cc') { + if (this.paymentType === hopPaymentMethods.CREDIT_CARD) { iframe.contentWindow.postMessage('CreditCardChosen', '*'); - } else if (this.paymentType === 'ap') { + } else if (this.paymentType === hopPaymentMethods.AFTERPAY) { iframe.contentWindow.postMessage('afterpay', '*'); } } @@ -466,8 +454,6 @@ export default { }, forwardButtonAction() { this.$router.navigate(this.navigationScenarios.CLICKED_FORWARD, this.$route); - }, - navigateForward() { } } }; diff --git a/src/router/index.js b/src/router/index.js index bef88b03..4cd2dc45 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -129,6 +129,14 @@ router.beforeEach(async (to, from) => { showIssLoadingModal(true); } + const isInIframe = fromQueryPage === IssPageValues.PAYMENT_PAGE; + if (isInIframe) { + // need to set window.top.location.href directly when navigating out of an iframe + // especially when navigating with browser buttons + const newUrl = `${window.top.location.origin}${to.href}`; + window.top.location.href = newUrl; + } + const store = useMainStore(); // Prevent navigating backwards if we enter a bailout that we are not allowed to go back on if (store.isBailout && from.name === IssPageValues.BAILOUT_PAGE && to.name !== 'root' && to.name !== IssPageValues.CONTACT_CONFIRMATION diff --git a/src/store/index.js b/src/store/index.js index 1b963902..3daecdfc 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -13,7 +13,7 @@ import damageLocationsSelected from '@/constants/damage-locations-selected'; import coverageStatuses from '@/constants/coverage-statuses'; import { AppointmentTypeStrings, PREMIUM_FEE_PART_TYPE } from '@/constants/schedule-constants'; import { convertDateStringToDate, getDateDifferenceInDays, militaryToTwelveHourTime } from '@/helpers/date-helper'; -import paymentMethods from '@/constants/payment-method-constants'; +import { paymentMethods } from '@/constants/payment-method-constants'; const storeId = 'main'; diff --git a/src/store/store.spec.js b/src/store/store.spec.js index 108b5900..98f2fd09 100644 --- a/src/store/store.spec.js +++ b/src/store/store.spec.js @@ -3,7 +3,7 @@ import { useMainStore } from '@/store/index.js'; import globalMethods from '@/global-methods.js'; import { getRandomString, getRandomGuid, getRandomInt, getRandomBoolean } from '@/helpers/data-generation.js'; import coverageStatuses from '@/constants/coverage-statuses.js'; -import paymentMethods from '@/constants/payment-method-constants'; +import { paymentMethods } from '@/constants/payment-method-constants'; import { endpoints } from '@/constants/endpoints'; import { AppointmentTypeStrings } from '@/constants/schedule-constants'; diff --git a/vue.config.js b/vue.config.js index 24f2d771..0a7711e6 100644 --- a/vue.config.js +++ b/vue.config.js @@ -2,7 +2,7 @@ process.env.VUE_APP_CONSUMER_CF_DISTRO = 'https://digitalapi.dev.safelite.io'; process.env.VUE_APP_CURRENT_ENVIRONMENT = 'Localhost'; process.env.VUE_APP_GOOGLE_PLACES_API_KEY = 'AIzaSyCuLhQcDdZTTb4JzpUFms1OCch2dk5lHF0'; -process.env.VUE_APP_SAFELITE_HOP = 'https://sv2-safelitehop-sys.safelite.com/fmgCheckoutEmbedded.aspx'; +process.env.VUE_APP_SAFELITE_HOP = 'https://iss-hop-sys.glassclaim.com/fmgCheckoutEmbedded.aspx'; // GA & GTM // NOTE: Using the old ISS site GTM Cotnainer ID for now, will create a new one soon.