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
percent: 0
},
'payment-adyen': {
'payment-page-adyen': {
// No progress bar on this page
percent: 0
},
'payment-return-adyen': {
// No progress bar on this page
percent: 0
},

View file

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

View file

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

View file

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

View file

@ -2917,15 +2917,6 @@ export const useMainStore = defineStore({
});
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() {
return window.sessionStorage.getItem(webStorageConstants.SUBMITTED_ORDER) !== null;