diff --git a/src/constants/application-config.js b/src/constants/application-config.js index 93a6f70d8..b739d9ff9 100644 --- a/src/constants/application-config.js +++ b/src/constants/application-config.js @@ -22,6 +22,7 @@ const applicationConfig = { PIA_ERROR_URL: location.protocol + "//" + location.host + "/fmg/payment-pia-return?src=concept-funnel", CONFIRMATION_URL: location.protocol + "//" + location.host + "/fmg/confirmation", + PIA_ADYEN_RETURN_URL: location.protocol + "//" + location.host + "/fmg/virtual/payment/return", GOOGLE_CALENDAR: "https://www.google.com/calendar/render?action=TEMPLATE", YAHOO_CALENDAR: "https://calendar.yahoo.com/?v=60", OUTLOOK_CALENDAR: diff --git a/src/constants/experiments.js b/src/constants/experiments.js index f358fc89f..0ca3987f0 100644 --- a/src/constants/experiments.js +++ b/src/constants/experiments.js @@ -33,6 +33,7 @@ const experimentSettings = { SHOW_PM_MOBILE_DAYS: "Show_PMmobileDays", SHOW_NO_PM_MOBILE_DAYS: "Show_NoPMmobileDays", SHOW_NO_MOBILE_AVAILABLE_DAYS: "Show_NoMobileAvailableDays", + USE_ADYEN_PAYMENT: "UseAdyenPayment", }; const experimentTriggers = { diff --git a/src/layouts/payment-adyen/payment-adyen.vue b/src/layouts/payment-adyen/payment-adyen.vue index a2d7651a2..5e74692d5 100644 --- a/src/layouts/payment-adyen/payment-adyen.vue +++ b/src/layouts/payment-adyen/payment-adyen.vue @@ -49,6 +49,7 @@ import { submitWorkOrder } from "@/helpers/heritage-integration/order-helper.js" import { paymentMethods } from "@/constants/payment-method-constants"; import { createAdyenCheckout } from "@/helpers/adyen-helper"; import { Dropin } from "@adyen/adyen-web/auto"; +import { applicationConfig } from "@/constants/application-config"; export default { name: "payment-adyen", @@ -279,20 +280,29 @@ export default { await this.dispatchStoreAction(storeActions.RESET_SAVE_SESSION_PROMISE); try { await submitWorkOrder({ - pageNameToLog: "payment-adyen", + pageNameToLog: this.pageName, submitAfterSave: true, }); } catch (error) { console.log(`error: response from submit work order: ${error.message}`); // navigate to error page + const errorPayload = { + cause: `Error while submitting work order after Adyen payment.`, + currentPage: this.pageName, + sessionId: this.sessionId, + idempotencyKey: this.idempotencyKey, + }; - //this.$refs.loadingModal.isModalVisible = false; + this.$router.handleSoftError(errorPayload); } - //this.$refs.loadingModal.isModalVisible = false; // clear order - // navigate forward + await baseMixin.methods.dispatchStoreAction(storeActions.CREATE_SUBMITTED_STATE); + this.$router.navigateWithoutSaving( + this.navigationScenarios.CLICKED_FORWARD, + this.pageName + ); }, }, @@ -309,12 +319,12 @@ export default { street: this.splitStreetAddress.street, zipCode: this.locationInfo.zipCode, stateOrProvince: this.locationInfo.state, - returnUrl: "http://localhost:8080/fmg/virtual/payment/return", + returnUrl: applicationConfig.PIA_ADYEN_RETURN_URL, email: this.$store.getters.order.customer.emailAddress, IP: "127.0.0.1", // TODO firstName: this.$store.getters.order.customer.firstName, lastName: this.$store.getters.order.customer.lastName, - idempotencyKey: `${this.$store.getters.order.referralCorrelationId}-${this.sourceSystem}`, + idempotencyKey: this.idempotencyKey, }; }, @@ -373,6 +383,10 @@ export default { }; }, + idempotencyKey() { + return `${this.$store.getters.order.referralCorrelationId}-${this.sourceSystem}`; + }, + sourceSystem() { return "FMG-2.0"; }, diff --git a/src/layouts/payment-method/payment-method.vue b/src/layouts/payment-method/payment-method.vue index 955d106b5..0fa02e80a 100644 --- a/src/layouts/payment-method/payment-method.vue +++ b/src/layouts/payment-method/payment-method.vue @@ -170,6 +170,7 @@ import { consumeQueryFromStash } from "@/router/methods/helpers/querystring-stas import { debugLog } from "@/helpers/debug-log-helper"; import { ErrorMessage } from "vee-validate"; import { Field } from "vee-validate"; +import experimentMixin from "../../mixins/experiment-mixin"; defineRule("payment-method-required", required(errorMessages.OPTION_REQUIRED)); defineRule("recal-ack-required", required(errorMessages.RECAL_ACK_REQUIRED)); @@ -609,10 +610,17 @@ export default { } this.dispatchStoreAction(storeActions.RESET_SAVE_SESSION_PROMISE); - this.$router.navigateWithoutSaving( - this.navigationScenarios.CLICKED_PAY_NOW, - this.pageName + + const shouldUseAdyen = experimentMixin.methods.hasSettingEqualTo( + experimentSettings.USE_ADYEN_PAYMENT, + "true" ); + + const scenarioName = shouldUseAdyen + ? this.navigationScenarios.CLICKED_PAY_NOW_ADYEN + : this.navigationScenarios.CLICKED_PAY_NOW; + + this.$router.navigateWithoutSaving(scenarioName, this.pageName); }, async evaluatePromosAndTaxItemsOnOrder() { //Revalidate promos if there are any inactive, or active promos diff --git a/src/router/constants/navigation-scenarios.js b/src/router/constants/navigation-scenarios.js index b660afca3..c2247d59b 100644 --- a/src/router/constants/navigation-scenarios.js +++ b/src/router/constants/navigation-scenarios.js @@ -61,6 +61,7 @@ const navigationScenarios = { // Payment CLICKED_INSURANCE: "CLICKED_INSURANCE", CLICKED_PAY_NOW: "CLICKED_PAY_NOW", + CLICKED_PAY_NOW_ADYEN: "CLICKED_PAY_NOW_ADYEN", CLICKED_PAY_LATER: "CLICKED_PAY_LATER", PIA_ERROR: "PIA_ERROR", PIA_CC_ERROR: "PIA_CC_ERROR", diff --git a/src/router/constants/routing-table.js b/src/router/constants/routing-table.js index cd41e8fcf..192e1572e 100644 --- a/src/router/constants/routing-table.js +++ b/src/router/constants/routing-table.js @@ -535,6 +535,10 @@ const routingTable = function () { }, { scenario: navigationScenarios.CLICKED_PAY_NOW, + destinationPageData: routeData.PAYMENT, + }, + { + scenario: navigationScenarios.CLICKED_PAY_NOW_ADYEN, destinationPageData: routeData.PAYMENT_ADYEN, }, { diff --git a/src/router/methods/route-logic/adyen-return.js b/src/router/methods/route-logic/adyen-return.js index 9bf1940ba..a516518ac 100644 --- a/src/router/methods/route-logic/adyen-return.js +++ b/src/router/methods/route-logic/adyen-return.js @@ -1,5 +1,5 @@ import { AdyenCheckout } from "@adyen/adyen-web"; -import { routeData } from "@router/constants/routes"; +import { routeData } from "@/router/constants/routes"; import { createAdyenCheckout, getSessionInfo } from "@/helpers/adyen-helper"; export async function adyenReturnBeforeEnter(to, from) {