diff --git a/src/constants/store-actions.js b/src/constants/store-actions.js index 288ceb67b..b37f0c249 100644 --- a/src/constants/store-actions.js +++ b/src/constants/store-actions.js @@ -77,7 +77,7 @@ const storeActions = { SAVE_MOLDING_QUESTION_ANSWERS: "saveMoldingQuestionAnswers", SAVE_CAPABILITY_QUESTION_ANSWERS: "saveCapabilityQuestionAnswers", SAVE_PAYMENT_TYPE: "savePaymentType", - SAVE_PAY_NOW_TYPE: "savePayNowType", + SAVE_PAYMENT_METHOD_CHOICE: "savePaymentMethodChoice", SAVE_PARENT_ACCOUNT_NUMBER: "saveParentAccountNumber", SAVE_SUPPORTING_ITEMS: "saveSupportingItems", SAVE_SUPPORTING_ITEMS_SUPPRESSING_STATE_RESETTING: diff --git a/src/constants/store-mutations.js b/src/constants/store-mutations.js index 632379de3..0ace57a7e 100644 --- a/src/constants/store-mutations.js +++ b/src/constants/store-mutations.js @@ -48,7 +48,8 @@ const storeMutations = { UPDATE_IS_INSURANCE: "updateIsInsurance", UPDATE_SAVED_SESSION_ID: "updateSavedSessionId", UPDATE_CRM_CUSTOMER_ID: "updateCrmCustomerId", - UPDATE_PAY_NOW_TYPE: "updatePayNowType", + UPDATE_IS_PIA: "updateIsPia", + UPDATE_PIA_TYPE: "updatePiaType", WORK_ORDER_NUMBER: "updateWorkOrderNumber", // EVENT BUS MUTATIONS diff --git a/src/layouts/payment-method/payment-method.vue b/src/layouts/payment-method/payment-method.vue index eac00fe15..26e8c52a5 100644 --- a/src/layouts/payment-method/payment-method.vue +++ b/src/layouts/payment-method/payment-method.vue @@ -161,7 +161,7 @@ export default { supportingItems: null, pricedGlassParts: null, displayPaypalAlert: this.getPaypalAlert(), - paymentMethodInternalModel: null, + paymentMethodInternalModel: this.getPaymentMethodFromStore(), }; }, methods: { @@ -220,6 +220,15 @@ export default { getPaypalAlert() { return store.getters.order.payment.piaErrorCode ? true : false; }, + getPaymentMethodFromStore() { + const isPia = store.getters.order.payment.isPia; + + if (isPia) { + return store.getters.order.payment.piaType; + } else { + return paymentMethods.LATER; + } + }, vapsItemsSelectedAction(vapsItemsSelected) { this.cartItems = vapsItemsSelected; }, @@ -246,6 +255,11 @@ export default { async forwardButtonAction() { this.dispatchStoreAction(storeActions.SAVE_PIA_ERROR_CODE, null, false); this.dispatchStoreAction(this.storeActions.SAVE_WORK_ORDER_FLAG, true, false); + this.dispatchStoreAction( + this.storeActions.SAVE_PAYMENT_METHODS_CHOICE, + this.paymentMethod, + false + ); await submitWorkOrder({ pageNameToLog: "payment-method" }); this.$router.navigateWithoutSaving( this.navigationScenarios.CLICKED_FORWARD, diff --git a/src/store/index.js b/src/store/index.js index 2c2eb8492..d15c89209 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -21,6 +21,7 @@ import { militaryToTwelveHourTime, getDisplayTextForDurationLength, } from "@/layouts/schedule/helpers/schedule-helper"; +import { paymentMethods } from "@/constants/payment-method-constants"; import { getDateDifferenceInDays } from "@/helpers/date-helper"; // Export State @@ -92,7 +93,8 @@ const getDefaultState = () => { coverageStatus: null, }, parentAccountNumber: 0, - payNowType: "cc", + isPia: null, + piaType: null, piaErrorCode: null, }, schedule: { @@ -218,8 +220,11 @@ export const mutations = { updateIsInsurance(state, isInsurance) { state.order.payment.isInsurance = isInsurance; }, - updatePayNowType(state, payNowType) { - state.order.payment.payNowType = payNowType; + updateIsPia(state, isPia) { + state.order.payment.isPia = isPia; + }, + updatePiaType(state, piaType) { + state.order.payment.piaType = piaType; }, updatePiaErrorCode(state, piaErrorCode) { state.order.payment.piaErrorCode = piaErrorCode; @@ -1994,8 +1999,12 @@ export const actions = { context.commit(storeMutations.UPDATE_IS_INSURANCE, isInsurance); }, - savePayNowType(context, payNowType) { - context.commit(storeMutations.UPDATE_PAY_NOW_TYPE, payNowType); + savePaymentMethodChoice(context, paymentMethod) { + const isPia = paymentMethod !== paymentMethods.LATER; + + context.commit(storeMutations.UPDATE_IS_PIA, isPia); + + context.commit(storeMutations.UPDATE_PIA_TYPE, isPia ? paymentMethod : null); }, saveParentAccountNumber(context, parentAccountNumber) {