Merge pull request #3153 from Safelite/nation/CASH-2399
CASH-2399 Handle error scenario where Adyen fails to load
This commit is contained in:
commit
94edeaef76
3 changed files with 45 additions and 4 deletions
|
|
@ -103,7 +103,7 @@ export function getSideDoorGlassString(glassLocation, glassName) {
|
||||||
export function getDamageInfoWordingText(damageInfo) {
|
export function getDamageInfoWordingText(damageInfo) {
|
||||||
const glassTextArray = [];
|
const glassTextArray = [];
|
||||||
|
|
||||||
damageInfo.glassToReplace.forEach((item) => {
|
damageInfo.glassToReplace?.forEach((item) => {
|
||||||
let string = "";
|
let string = "";
|
||||||
if (item.glassLocation === glassLocations.WINDSHIELD) {
|
if (item.glassLocation === glassLocations.WINDSHIELD) {
|
||||||
string = item.glassLocation;
|
string = item.glassLocation;
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,7 @@ import { createAdyenCheckout } from "@/helpers/adyen-helper";
|
||||||
import { Dropin } from "@adyen/adyen-web/auto";
|
import { Dropin } from "@adyen/adyen-web/auto";
|
||||||
import { applicationConfig } from "@/constants/application-config";
|
import { applicationConfig } from "@/constants/application-config";
|
||||||
import { paymentMethods } from "@/constants/payment-method-constants";
|
import { paymentMethods } from "@/constants/payment-method-constants";
|
||||||
|
import analyticsMixin from "@/mixins/analytics-mixin";
|
||||||
|
|
||||||
import "@adyen/adyen-web/styles/adyen.css";
|
import "@adyen/adyen-web/styles/adyen.css";
|
||||||
import { mapAdyenToFmgPaymentMethod, mapFmgToAdyenPaymentMethod } from "../../helpers/adyen-helper";
|
import { mapAdyenToFmgPaymentMethod, mapFmgToAdyenPaymentMethod } from "../../helpers/adyen-helper";
|
||||||
|
|
@ -133,6 +134,25 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
async initializeAdyenWithErrorHandling() {
|
||||||
|
try {
|
||||||
|
await this.initializeAdyen();
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to initialize Adyen payment:", error);
|
||||||
|
|
||||||
|
const errorJson = JSON.stringify(error, Object.getOwnPropertyNames(Object(error)));
|
||||||
|
analyticsMixin.methods.pushFmgSessionData(errorJson);
|
||||||
|
await global.$logger.logError(errorJson);
|
||||||
|
|
||||||
|
this.$router.navigateWithoutSaving(
|
||||||
|
this.navigationScenarios.PIA_ERROR,
|
||||||
|
this.pageName
|
||||||
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
async backButtonAction() {
|
async backButtonAction() {
|
||||||
// Stub, for navigating back via nav-bar.
|
// Stub, for navigating back via nav-bar.
|
||||||
this.$router.navigateWithoutSaving(
|
this.$router.navigateWithoutSaving(
|
||||||
|
|
@ -203,6 +223,12 @@ export default {
|
||||||
},
|
},
|
||||||
onError: (error, component) => {
|
onError: (error, component) => {
|
||||||
console.log(`Error from Adyen`);
|
console.log(`Error from Adyen`);
|
||||||
|
const errorJson = JSON.stringify(
|
||||||
|
error,
|
||||||
|
Object.getOwnPropertyNames(Object(error))
|
||||||
|
);
|
||||||
|
analyticsMixin.methods.pushFmgSessionData(errorJson);
|
||||||
|
|
||||||
this.handleError(error);
|
this.handleError(error);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -371,7 +397,12 @@ export default {
|
||||||
|
|
||||||
await global.$logger.logError(stringToLog);
|
await global.$logger.logError(stringToLog);
|
||||||
|
|
||||||
this.hasPaymentFailureError = true;
|
this.$router.navigateWithoutSaving(
|
||||||
|
this.navigationScenarios.PIA_ERROR,
|
||||||
|
this.pageName
|
||||||
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.dropinComponent?.update();
|
this.dropinComponent?.update();
|
||||||
|
|
@ -566,7 +597,7 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
this.initializeAdyen();
|
this.initializeAdyenWithErrorHandling();
|
||||||
},
|
},
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
|
|
|
||||||
|
|
@ -160,12 +160,16 @@ export default {
|
||||||
// and aws FireHose stream, DigitalConsumer-Session-Firehose, to push data to an
|
// and aws FireHose stream, DigitalConsumer-Session-Firehose, to push data to an
|
||||||
// S3 bucket, safelite-dev-digitalconsumer-session-data-us-east-2/1.
|
// S3 bucket, safelite-dev-digitalconsumer-session-data-us-east-2/1.
|
||||||
// This bucket data is then picked up by snowflake for analytics use.
|
// This bucket data is then picked up by snowflake for analytics use.
|
||||||
async pushFmgSessionData() {
|
async pushFmgSessionData(errorJson = null) {
|
||||||
var currentPageName = getPageNameFromRouter(true);
|
var currentPageName = getPageNameFromRouter(true);
|
||||||
if (!currentPageName) {
|
if (!currentPageName) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (errorJson) {
|
||||||
|
currentPageName += ` ERROR: ${errorJson}`;
|
||||||
|
}
|
||||||
|
|
||||||
const hasSubmittedOrder = baseMixin.methods.hasSubmittedOrder();
|
const hasSubmittedOrder = baseMixin.methods.hasSubmittedOrder();
|
||||||
const submittedOrder = baseMixin.methods.getSubmittedOrder();
|
const submittedOrder = baseMixin.methods.getSubmittedOrder();
|
||||||
const order = hasSubmittedOrder ? submittedOrder : store.getters.order;
|
const order = hasSubmittedOrder ? submittedOrder : store.getters.order;
|
||||||
|
|
@ -209,6 +213,7 @@ export default {
|
||||||
var appointment = `${order?.schedule?.date ?? ""} ${order?.schedule?.startTime ?? ""}`;
|
var appointment = `${order?.schedule?.date ?? ""} ${order?.schedule?.startTime ?? ""}`;
|
||||||
|
|
||||||
var sessionData = {};
|
var sessionData = {};
|
||||||
|
|
||||||
sessionData.currentPage = currentPageName;
|
sessionData.currentPage = currentPageName;
|
||||||
sessionData.sid = getSessionIdValue();
|
sessionData.sid = getSessionIdValue();
|
||||||
sessionData.deviceId = getDeviceIdValue();
|
sessionData.deviceId = getDeviceIdValue();
|
||||||
|
|
@ -931,6 +936,11 @@ function getPageNameFromRouter(useDefaultUrl = false) {
|
||||||
router.currentRoute.value &&
|
router.currentRoute.value &&
|
||||||
router.currentRoute.value.name
|
router.currentRoute.value.name
|
||||||
) {
|
) {
|
||||||
|
const query = router.currentRoute.value.query;
|
||||||
|
if (query && Object.keys(query).length > 0 && useDefaultUrl === true) {
|
||||||
|
const queryString = new URLSearchParams(query).toString();
|
||||||
|
return `${router.currentRoute.value.name}?${queryString}`;
|
||||||
|
}
|
||||||
return router.currentRoute.value.name;
|
return router.currentRoute.value.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue