INSR-7995: Address copilot comments

This commit is contained in:
Alex Humphries 2026-03-17 10:00:13 -04:00
parent 3bd15f9054
commit aac6cd1dea
5 changed files with 19 additions and 90 deletions

View file

@ -66,7 +66,11 @@ export const pageProgressMapper = {
// No progress bar on this page // No progress bar on this page
percent: 0 percent: 0
}, },
'payment-adyen': { 'payment-page-adyen': {
// No progress bar on this page
percent: 0
},
'payment-return-adyen': {
// No progress bar on this page // No progress bar on this page
percent: 0 percent: 0
}, },

View file

@ -6,9 +6,7 @@ import { AppointmentTypeStrings } from "@/constants/schedule-constants";
import { paymentMethods } from "@/constants/payment-method-constants"; import { paymentMethods } from "@/constants/payment-method-constants";
import applicationConfig from "@/constants/application-config"; import applicationConfig from "@/constants/application-config";
export async function getNewSession(sessionConfig) {} export async function getSessionInfo(sessionId, encryptedSessionResult) {
export async function getSessionInfo(sessionId, encryptedSessionResult, pageNameToLog = "") {
const order = useMainStore().order; const order = useMainStore().order;
const location = getLocationInfo(order); const location = getLocationInfo(order);
const workOrder = getWorkOrderLastSixDigits(order); const workOrder = getWorkOrderLastSixDigits(order);
@ -26,8 +24,7 @@ export async function getSessionInfo(sessionId, encryptedSessionResult, pageName
method: endpoints.GetAdyenSessionResult.method, method: endpoints.GetAdyenSessionResult.method,
endpoint: endpoints.GetAdyenSessionResult.url, endpoint: endpoints.GetAdyenSessionResult.url,
payload: request, payload: request,
logApiCall: true, logApiCall: true
pageNameToLog: pageNameToLog,
}); });
return response?.data; return response?.data;
@ -65,9 +62,6 @@ export async function createAdyenCheckout({
}; };
} }
console.log(`Creating checkout with configuration:`);
console.log(config);
return await AdyenCheckout(config); return await AdyenCheckout(config);
} }
@ -102,8 +96,6 @@ export function mapIssToAdyenPaymentMethod(issMethod) {
export function generateCcToken(adyenSessionInfo) { export function generateCcToken(adyenSessionInfo) {
const order = useMainStore().order; const order = useMainStore().order;
const locationInfo = getLocationInfo(order); const locationInfo = getLocationInfo(order);
console.log("Generating CC Token with the following Adyen Session Info:");
console.log(JSON.parse(JSON.stringify(adyenSessionInfo)));
const ccToken = { const ccToken = {
subscriptionId: adyenSessionInfo?.storedToken, subscriptionId: adyenSessionInfo?.storedToken,

View file

@ -50,7 +50,6 @@
// Components // Components
import siteHeader from '@/iss-components/site-header/site-header.vue'; import siteHeader from '@/iss-components/site-header/site-header.vue';
import siteFooter from '@/iss-components/site-footer/site-footer.vue'; import siteFooter from '@/iss-components/site-footer/site-footer.vue';
import buttonMain from '@/ux-components/button-main/button-main.vue';
import alert from '@/ux-components/alert/alert.vue'; import alert from '@/ux-components/alert/alert.vue';
import cartDropdown from '@/iss-components/cart-dropdown/cart-dropdown.vue'; import cartDropdown from '@/iss-components/cart-dropdown/cart-dropdown.vue';
@ -146,8 +145,14 @@ export default {
dropinComponent: null, dropinComponent: null,
sourceSystem: 'ISS-NextGen', sourceSystem: 'ISS-NextGen',
hasPaymentFailureError: false, hasPaymentFailureError: false,
adyenTimeout: null
}; };
}, },
unmounted() {
if (this.adyenTimeout) {
clearTimeout(this.adyenTimeout);
}
},
computed: { computed: {
piaType() { piaType() {
return this.mainStore.payment.paymentMethod; return this.mainStore.payment.paymentMethod;
@ -196,7 +201,7 @@ export default {
const tokens = address.split(" ") ?? [""]; const tokens = address.split(" ") ?? [""];
const number = tokens[0]; const number = tokens[0];
const street = tokens.slice(1).reduce((prev, next) => `${prev} ${next}`); const street = tokens.slice(1).join(" ") ?? "";
return { return {
number: number ?? "", number: number ?? "",
@ -366,19 +371,10 @@ export default {
); );
}, },
async initializeAdyen() { async initializeAdyen() {
console.log(`Price = ${this.totalAmount}`);
console.log(`Adyen Price = ${this.adyenPriceTotal}`);
const requestBody = this.getAdyenInitRequestInfo(); const requestBody = this.getAdyenInitRequestInfo();
console.log(`Calling with:`);
console.log(requestBody);
const adyenResponse = await this.mainStore.initializeAdyenPayment(requestBody); const adyenResponse = await this.mainStore.initializeAdyenPayment(requestBody);
console.log(`Got data:`);
console.log(adyenResponse);
const session = { const session = {
id: adyenResponse.sessionId, id: adyenResponse.sessionId,
sessionData: adyenResponse.sessionData, sessionData: adyenResponse.sessionData,
@ -390,15 +386,12 @@ export default {
session: session, session: session,
handlers: { handlers: {
onPaymentCompleted: (result, component) => { onPaymentCompleted: (result, component) => {
console.log(`Payment completed from Adyen.`);
this.handleCompletedPayment(result); this.handleCompletedPayment(result);
}, },
onPaymentFailed: (result, component) => { onPaymentFailed: (result, component) => {
console.log(`Payment failed from Adyen`);
this.handleFailedPayment(result); this.handleFailedPayment(result);
}, },
onError: (error, component) => { onError: (error, component) => {
console.log(`Error from Adyen`);
this.handleError(error); this.handleError(error);
}, },
}, },
@ -407,8 +400,6 @@ export default {
}, },
}); });
console.log(checkout);
const expiryTime = new Date(checkout.options.expiresAt); const expiryTime = new Date(checkout.options.expiresAt);
const expiryInterval = expiryTime.getTime() - new Date().getTime(); const expiryInterval = expiryTime.getTime() - new Date().getTime();
@ -416,7 +407,10 @@ export default {
this.resetAdyenDropin(); this.resetAdyenDropin();
}; };
const timeout = setTimeout(handleTimeout, expiryInterval); if (this.adyenTimeout) {
clearTimeout(this.adyenTimeout);
}
this.adyenTimeout = setTimeout(handleTimeout, expiryInterval);
const configuration = { const configuration = {
paymentMethodsConfiguration: { paymentMethodsConfiguration: {
@ -449,9 +443,7 @@ export default {
}, },
}; };
console.log(`PIA Type: ${this.piaType}`);
const adyenPaymentType = mapIssToAdyenPaymentMethod(this.piaType); const adyenPaymentType = mapIssToAdyenPaymentMethod(this.piaType);
console.log(`Adyen payment type: ${adyenPaymentType}`);
if (adyenPaymentType) { if (adyenPaymentType) {
configuration.openPaymentMethod = { configuration.openPaymentMethod = {
@ -461,9 +453,6 @@ export default {
const dropin = new Dropin(checkout, configuration); const dropin = new Dropin(checkout, configuration);
console.log(`Mounting Adyen dropin`);
console.log(dropin);
this.dropinComponent = dropin; this.dropinComponent = dropin;
dropin.mount("#adyen-container"); dropin.mount("#adyen-container");
@ -487,8 +476,6 @@ export default {
lastName: this.mainStore.contactInfo.lastName, lastName: this.mainStore.contactInfo.lastName,
idempotencyKey: this.getIdempotencyKey(), idempotencyKey: this.getIdempotencyKey(),
}; };
console.log(`Adyen init request info:`);
console.log(request);
return request; return request;
}, },
async resetAdyenDropin() { async resetAdyenDropin() {
@ -506,8 +493,6 @@ export default {
return `${id}-${system}-${currentDate}-${currentHour}-${total}`; return `${id}-${system}-${currentDate}-${currentHour}-${total}`;
}, },
async handleCompletedPayment(result) { async handleCompletedPayment(result) {
console.log(`Result =`);
console.log(result);
// Fetch session info // Fetch session info
const paymentSessionRequest = { const paymentSessionRequest = {
zipCodeCtu: this.ctu, zipCodeCtu: this.ctu,
@ -517,16 +502,10 @@ export default {
sessionResult: result?.sessionResult, sessionResult: result?.sessionResult,
}; };
console.log(`Get session payload =`);
console.log(paymentSessionRequest);
showIssLoadingModal(true); showIssLoadingModal(true);
const adyenResponse = await this.mainStore.getAdyenSessionResult(paymentSessionRequest); const adyenResponse = await this.mainStore.getAdyenSessionResult(paymentSessionRequest);
console.log(`Session response =`);
console.log(adyenResponse);
const ccToken = { const ccToken = {
subscriptionId: adyenResponse?.storedToken, subscriptionId: adyenResponse?.storedToken,
expMonth: adyenResponse?.cardExpiryMonth, expMonth: adyenResponse?.cardExpiryMonth,
@ -542,9 +521,6 @@ export default {
lastFour: adyenResponse?.last4DigitsOfCard, lastFour: adyenResponse?.last4DigitsOfCard,
}; };
console.log(`CC Token generated =`);
console.log(ccToken);
const paymentMethodFromSession = adyenResponse?.paymentMethod; const paymentMethodFromSession = adyenResponse?.paymentMethod;
const paymentMethod = mapAdyenToIssPaymentMethod(paymentMethodFromSession); const paymentMethod = mapAdyenToIssPaymentMethod(paymentMethodFromSession);
@ -562,9 +538,6 @@ export default {
await this.saveAndSubmitWorkOrder(); await this.saveAndSubmitWorkOrder();
}, },
async handleFailedPayment(result) { async handleFailedPayment(result) {
console.log(`Result =`);
console.log(result);
const wasPaymentCancelled = result?.resultCode === "Cancelled"; const wasPaymentCancelled = result?.resultCode === "Cancelled";
if (!wasPaymentCancelled) { if (!wasPaymentCancelled) {
@ -578,8 +551,6 @@ export default {
this.dropinComponent?.update(); this.dropinComponent?.update();
}, },
async handleError(error) { async handleError(error) {
console.log(error);
const wasPaymentCancelled = error?.name === "CANCEL"; const wasPaymentCancelled = error?.name === "CANCEL";
if (!wasPaymentCancelled) { if (!wasPaymentCancelled) {

View file

@ -27,7 +27,6 @@ export default {
async mounted() { async mounted() {
showIssLoadingModal(true); showIssLoadingModal(true);
const store = useMainStore(); const store = useMainStore();
console.log(`In adyen return.`);
const sessionId = this.$route?.query?.sessionId; const sessionId = this.$route?.query?.sessionId;
const redirectResult = this.$route?.query?.redirectResult; const redirectResult = this.$route?.query?.redirectResult;
@ -36,20 +35,16 @@ export default {
let result = null; let result = null;
try { try {
console.log(`Finalizing Adyen payment with sessionId ${sessionId} and redirectResult ${redirectResult}`);
result = await this.finalizeAdyenPayment(sessionId, redirectResult); result = await this.finalizeAdyenPayment(sessionId, redirectResult);
} catch (unexpectedResult) { } catch (unexpectedResult) {
console.log(`Payment finalization failed with result:`);
console.log(unexpectedResult);
// If user cancelled payment, handle without error message // If user cancelled payment, handle without error message
if (unexpectedResult.code === "Cancelled" || unexpectedResult.code === "CANCEL") { if (unexpectedResult.code === "Cancelled" || unexpectedResult.code === "CANCEL") {
console.log(`Payment was cancelled by user.`);
this.$router.navigate(navigationScenarios.PAY_IN_ADVANCE_CANCEL, this.$route); this.$router.navigate(navigationScenarios.PAY_IN_ADVANCE_CANCEL, this.$route);
return; return;
} }
// Otherwise, failure scenario. // Otherwise, failure scenario.
// Payment fails, so return user to payment-adyen screen to try again or pay later. // Payment fails, so return user to payment-page-adyen screen to try again or pay later.
this.$router.navigate( this.$router.navigate(
navigationScenarios.PAY_IN_ADVANCE_ERROR, navigationScenarios.PAY_IN_ADVANCE_ERROR,
this.$route, this.$route,
@ -59,26 +54,13 @@ export default {
); );
return; return;
} }
console.log(`Out of promise`);
console.log(result);
const sessionInfo = await getSessionInfo(sessionId, result.sessionResult); const sessionInfo = await getSessionInfo(sessionId, result.sessionResult);
console.log(`Got session info:`);
console.log(sessionInfo);
// TODO once afterpay info is returned, create cc token and submit order. // TODO once afterpay info is returned, create cc token and submit order.
const paymentMethod = mapAdyenToIssPaymentMethod(sessionInfo?.paymentMethod); const paymentMethod = mapAdyenToIssPaymentMethod(sessionInfo?.paymentMethod);
const amountDue = getCartTotal(store.order); const amountDue = getCartTotal(store.order);
const ccToken = generateCcToken(sessionInfo); const ccToken = generateCcToken(sessionInfo);
ccToken.authCode = "831001";
ccToken.cardType = "VS";
ccToken.lastFour = "1111";
ccToken.expMonth = "03";
ccToken.expYear = "2030";
store.savePaymentMethodChoice(paymentMethod); store.savePaymentMethodChoice(paymentMethod);
store.updateCreditCardToken(ccToken); store.updateCreditCardToken(ccToken);
store.updateNextGenSettledAmount(amountDue); store.updateNextGenSettledAmount(amountDue);
@ -88,7 +70,6 @@ export default {
await this.saveAndSubmitWorkOrder(); await this.saveAndSubmitWorkOrder();
return; return;
} catch (error) { } catch (error) {
console.log(error);
this.$router.navigate( this.$router.navigate(
navigationScenarios.PAY_IN_ADVANCE_ERROR, navigationScenarios.PAY_IN_ADVANCE_ERROR,
this.$route, this.$route,
@ -116,14 +97,9 @@ export default {
}, },
handlers: { handlers: {
onPaymentCompleted: (result, component) => { onPaymentCompleted: (result, component) => {
console.log(`Payment successful`);
console.log(result);
resolve(result); resolve(result);
}, },
onPaymentFailed: (result, component) => { onPaymentFailed: (result, component) => {
console.log(`Payment failed`);
console.log(result);
if (result?.resultCode !== "Cancelled") { if (result?.resultCode !== "Cancelled") {
const stringToLog = `ADYEN PAYMENT NOT AUTHORIZED. Code = ${result?.resultCode}. Id = ${sessionId}`; const stringToLog = `ADYEN PAYMENT NOT AUTHORIZED. Code = ${result?.resultCode}. Id = ${sessionId}`;
@ -136,9 +112,6 @@ export default {
}); });
}, },
onError: (error, component) => { onError: (error, component) => {
console.log(`Error occured`);
console.log(error);
if (error?.name !== "CANCEL") { if (error?.name !== "CANCEL") {
const stringToLog = `ADYEN ERROR. Name = ${error?.name}. Details = ${error?.message}.`; const stringToLog = `ADYEN ERROR. Name = ${error?.name}. Details = ${error?.message}.`;
@ -154,7 +127,6 @@ export default {
options: {}, options: {},
}).then( }).then(
(checkout) => { (checkout) => {
console.log(`Submitting details to Adyen checkout`);
checkout.submitDetails({ checkout.submitDetails({
details: { details: {
redirectResult: redirectResult, redirectResult: redirectResult,
@ -162,7 +134,6 @@ export default {
}); });
}, },
(error) => { (error) => {
console.log(`Failed to create Adyen checkout`);
reject(error); reject(error);
} }
); );

View file

@ -2917,15 +2917,6 @@ export const useMainStore = defineStore({
}); });
return response.data; return response.data;
}, },
async getAdyenSessionResult(paymentSessionRequest) {
const response = await globalMethods.callHttpClient({
method: endpoints.GetAdyenSessionResult.method,
endpoint: endpoints.GetAdyenSessionResult.url,
payload: paymentSessionRequest,
logApiCall: true
});
return response.data;
},
hasSubmittedOrder() { hasSubmittedOrder() {
return window.sessionStorage.getItem(webStorageConstants.SUBMITTED_ORDER) !== null; return window.sessionStorage.getItem(webStorageConstants.SUBMITTED_ORDER) !== null;