CSR-1391 moved signature api call to beforeRouteEnter and other fixes
This commit is contained in:
parent
dd83c34b98
commit
62ef3faefd
2 changed files with 41 additions and 32 deletions
|
|
@ -291,13 +291,13 @@ export default {
|
||||||
|
|
||||||
switch (this.paymentMethod) {
|
switch (this.paymentMethod) {
|
||||||
case paymentMethods.CREDIT_CARD:
|
case paymentMethods.CREDIT_CARD:
|
||||||
this.piaSetup(this.paymentMethod);
|
this.setupPia(this.paymentMethod);
|
||||||
break;
|
break;
|
||||||
case paymentMethods.PAYPAL:
|
case paymentMethods.PAYPAL:
|
||||||
this.piaSetup(this.paymentMethod);
|
this.setupPia(this.paymentMethod);
|
||||||
break;
|
break;
|
||||||
case paymentMethods.AFTERPAY:
|
case paymentMethods.AFTERPAY:
|
||||||
this.piaSetup(this.paymentMethod);
|
this.setupPia(this.paymentMethod);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
this.dispatchStoreAction(storeActions.SAVE_PIA_ERROR_CODE, null, false);
|
this.dispatchStoreAction(storeActions.SAVE_PIA_ERROR_CODE, null, false);
|
||||||
|
|
@ -309,7 +309,7 @@ export default {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async piaSetup(payNowType) {
|
async setupPia(payNowType) {
|
||||||
this.$refs.loadingModal.showModal();
|
this.$refs.loadingModal.showModal();
|
||||||
|
|
||||||
// since we're leaving the site for pia, clear any save session promises that we will not be able to resolve when we return
|
// since we're leaving the site for pia, clear any save session promises that we will not be able to resolve when we return
|
||||||
|
|
|
||||||
|
|
@ -61,9 +61,9 @@
|
||||||
<input type="hidden" name="sgDeclineResponseURL" :value="piaResponseUrl" />
|
<input type="hidden" name="sgDeclineResponseURL" :value="piaResponseUrl" />
|
||||||
<input type="hidden" name="sgErrorResponseURL" :value="piaResponseUrl" />
|
<input type="hidden" name="sgErrorResponseURL" :value="piaResponseUrl" />
|
||||||
|
|
||||||
<input type="hidden" name="sgheaderline1" :value="sgHeaderline1" />
|
<input type="hidden" name="sgheaderline1" :value="getHeaderLine1" />
|
||||||
<input type="hidden" name="sgHeader1subtitle" value="" />
|
<input type="hidden" name="sgHeader1subtitle" value="" />
|
||||||
<input type="hidden" name="sgheaderline2" :value="sgHeaderline2" />
|
<input type="hidden" name="sgheaderline2" :value="getHeaderLine2" />
|
||||||
<input type="hidden" name="sgheaderline3" value="" />
|
<input type="hidden" name="sgheaderline3" value="" />
|
||||||
<input type="hidden" name="sgheaderline4" value="" />
|
<input type="hidden" name="sgheaderline4" value="" />
|
||||||
<input type="hidden" name="sgheaderline5" value="*Required information" />
|
<input type="hidden" name="sgheaderline5" value="*Required information" />
|
||||||
|
|
@ -200,14 +200,19 @@ export default {
|
||||||
totalAmount: this.getAmountDue(),
|
totalAmount: this.getAmountDue(),
|
||||||
displayAmount: this.getDisplayAmountDue(),
|
displayAmount: this.getDisplayAmountDue(),
|
||||||
piaLineItems: this.getPiaLineItems(),
|
piaLineItems: this.getPiaLineItems(),
|
||||||
sgHeaderline1: this.getHeaderLine1(),
|
|
||||||
sgHeaderline2: this.getHeaderLine2(),
|
|
||||||
paypalPayment: this.isPaypal(),
|
paypalPayment: this.isPaypal(),
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
async beforeRouteEnter(to, from, next) {
|
async beforeRouteEnter(to, from, next) {
|
||||||
// Call APIs
|
// Call APIs
|
||||||
const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage);
|
const cmsContentPromise = fetchCmsContentForPage(to.query.fmgPage);
|
||||||
|
|
||||||
|
const signaturePromise = baseMixin.methods.dispatchStoreActionWithLogging(
|
||||||
|
storeActions.GET_SIGNATURE,
|
||||||
|
null,
|
||||||
|
"payment"
|
||||||
|
);
|
||||||
|
|
||||||
// TODO: Data fetching Promise declarations
|
// TODO: Data fetching Promise declarations
|
||||||
|
|
||||||
const promiseResultMap = [
|
const promiseResultMap = [
|
||||||
|
|
@ -215,6 +220,10 @@ export default {
|
||||||
resultKey: "cmsContent",
|
resultKey: "cmsContent",
|
||||||
promise: cmsContentPromise,
|
promise: cmsContentPromise,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
resultKey: "signature",
|
||||||
|
promise: signaturePromise,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const resultMap = await settleAllPromises(promiseResultMap);
|
const resultMap = await settleAllPromises(promiseResultMap);
|
||||||
|
|
@ -222,7 +231,7 @@ export default {
|
||||||
// Call the "next" function to complete the transition to this page.
|
// Call the "next" function to complete the transition to this page.
|
||||||
next(async (vm) => {
|
next(async (vm) => {
|
||||||
vm.setCmsContent(resultMap.cmsContent);
|
vm.setCmsContent(resultMap.cmsContent);
|
||||||
vm.fetchSignatureInfo();
|
vm.fetchSignatureInfo(resultMap.signature);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
@ -234,6 +243,18 @@ export default {
|
||||||
const { protocol, hostname, port } = window.location;
|
const { protocol, hostname, port } = window.location;
|
||||||
return `${protocol}//${hostname}:${port}/fmg/css/hop-styling.css`;
|
return `${protocol}//${hostname}:${port}/fmg/css/hop-styling.css`;
|
||||||
},
|
},
|
||||||
|
getHeaderLine1() {
|
||||||
|
if (!this.isPaypal()) {
|
||||||
|
return this.getCmsContent("PIAHeaderLine1", "Text");
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
},
|
||||||
|
getHeaderLine2() {
|
||||||
|
if (!this.isPaypal()) {
|
||||||
|
return this.getCmsContent("PIAHeaderLine2", "Text");
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
arePagePrerequisitesValid() {
|
arePagePrerequisitesValid() {
|
||||||
|
|
@ -242,7 +263,7 @@ export default {
|
||||||
},
|
},
|
||||||
getWOrkOrderNumber() {
|
getWOrkOrderNumber() {
|
||||||
if (store.getters.order.workOrderNumber) {
|
if (store.getters.order.workOrderNumber) {
|
||||||
var items = store.getters.order.workOrderNumber.split("-");
|
const items = store.getters.order.workOrderNumber.split("-");
|
||||||
return items[1];
|
return items[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -296,27 +317,15 @@ export default {
|
||||||
return store.getters.payment.piaType;
|
return store.getters.payment.piaType;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getHeaderLine1() {
|
|
||||||
if (!this.isPaypal()) {
|
|
||||||
return "Submit payment information";
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
},
|
|
||||||
getHeaderLine2() {
|
|
||||||
if (!this.isPaypal()) {
|
|
||||||
return "Save time when you pay for your service today! Please select a payment option.";
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
},
|
|
||||||
getPiaLineItems() {
|
getPiaLineItems() {
|
||||||
var itemsForPia = "";
|
let itemsForPia = "";
|
||||||
var glassParts = store.getters.order.lineItems.glassParts;
|
const glassParts = store.getters.order.lineItems.glassParts;
|
||||||
var supportingItems = store.getters.order.lineItems.supportingItems;
|
const supportingItems = store.getters.order.lineItems.supportingItems;
|
||||||
var vaps = store.getters.order.lineItems.vaps;
|
const vaps = store.getters.order.lineItems.vaps;
|
||||||
const items = [...(glassParts ?? []), ...(supportingItems ?? []), ...(vaps ?? [])];
|
const items = [...(glassParts ?? []), ...(supportingItems ?? []), ...(vaps ?? [])];
|
||||||
|
|
||||||
for (var i = 0; i < items.length; i++) {
|
for (let i = 0; i < items.length; i++) {
|
||||||
var amount = items[i].laborAmount + items[i].sellingPrice;
|
const amount = items[i].laborAmount + items[i].sellingPrice;
|
||||||
itemsForPia += items[i].partType + "|" + amount + "|1|";
|
itemsForPia += items[i].partType + "|" + amount + "|1|";
|
||||||
}
|
}
|
||||||
return itemsForPia;
|
return itemsForPia;
|
||||||
|
|
@ -351,10 +360,10 @@ export default {
|
||||||
if (this.isPaypal()) {
|
if (this.isPaypal()) {
|
||||||
this.$refs.loadingModal.showModal();
|
this.$refs.loadingModal.showModal();
|
||||||
}
|
}
|
||||||
const signatureInfo = await this.dispatchStoreAction(storeActions.GET_SIGNATURE);
|
|
||||||
this.authToken = signatureInfo.data.token;
|
this.authToken = signatureInfo.token;
|
||||||
this.authSignature = signatureInfo.data.signature;
|
this.authSignature = signatureInfo.signature;
|
||||||
this.authSignatureStart = signatureInfo.data.startDate;
|
this.authSignatureStart = signatureInfo.startDate;
|
||||||
|
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.myForm.submit();
|
this.$refs.myForm.submit();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue