Handle cancellation and payment errors.
This commit is contained in:
parent
cc4f65c5ac
commit
fa5ff6b58b
2 changed files with 37 additions and 14 deletions
|
|
@ -111,7 +111,7 @@ export default {
|
|||
next(async (vm) => {
|
||||
vm.setCmsContent(resultMap.cmsContent);
|
||||
|
||||
if(hasExistingPiaError) {
|
||||
if (hasExistingPiaError) {
|
||||
vm.hasPaymentFailureError = true;
|
||||
}
|
||||
});
|
||||
|
|
@ -203,9 +203,9 @@ export default {
|
|||
debugLog("providerLocation.city:", providerLocation.city, !preReqResult);
|
||||
debugLog("providerLocation.state:", providerLocation.state, !preReqResult);
|
||||
debugLog("providerLocation.zipCode:", providerLocation.zipCode, !preReqResult);
|
||||
|
||||
|
||||
debugLog("", null, !preReqResult);
|
||||
|
||||
|
||||
debugLog("isInsuranceSet:", isInsuranceSet, !preReqResult);
|
||||
|
||||
debugLog("", null, !preReqResult);
|
||||
|
|
@ -216,7 +216,7 @@ export default {
|
|||
debugLog("schedule.endTime:", schedule.endTime, !preReqResult);
|
||||
debugLog("schedule.jobMaxMinutes:", schedule.jobMaxMinutes, !preReqResult);
|
||||
debugLog("schedule.jobMinMinutes:", schedule.jobMinMinutes, !preReqResult);
|
||||
|
||||
|
||||
debugLog("", null, !preReqResult);
|
||||
|
||||
debugLog("customerReqs:", customerReqs, !preReqResult);
|
||||
|
|
@ -224,7 +224,7 @@ export default {
|
|||
debugLog("customer.lastName:", customer.lastName, !preReqResult);
|
||||
debugLog("customer.phoneNumber:", customer.phoneNumber, !preReqResult);
|
||||
debugLog("customer.emailAddress:", customer.emailAddress, !preReqResult);
|
||||
|
||||
|
||||
debugLog("", null, !preReqResult);
|
||||
|
||||
debugLog("paymentMethodReqs:", paymentMethodReqs, !preReqResult);
|
||||
|
|
@ -405,18 +405,32 @@ export default {
|
|||
console.log(`Result =`);
|
||||
console.log(result);
|
||||
|
||||
const stringToLog = `ADYEN PAYMENT NOT AUTHORIZED. Code = ${result?.resultCode}. Id = ${this.sessionId}`;
|
||||
const wasPaymentCancelled = result?.resultCode === "Cancelled";
|
||||
|
||||
await global.$logger.logError(stringToLog);
|
||||
if (!wasPaymentCancelled) {
|
||||
const stringToLog = `ADYEN PAYMENT NOT AUTHORIZED. Code = ${result?.resultCode}. Id = ${this.sessionId}`;
|
||||
|
||||
this.hasPaymentFailureError = true;
|
||||
await global.$logger.logError(stringToLog);
|
||||
|
||||
this.hasPaymentFailureError = true;
|
||||
}
|
||||
|
||||
this.dropinComponent?.update();
|
||||
},
|
||||
handleError(error) {
|
||||
const stringToLog = `ADYEN ERROR. Name = ${error.name}. Details = ${error.message}.`;
|
||||
async handleError(error) {
|
||||
console.log(error);
|
||||
|
||||
global.$logger.logError(stringToLog);
|
||||
const wasPaymentCancelled = error?.name === "CANCEL";
|
||||
|
||||
if (!wasPaymentCancelled) {
|
||||
const stringToLog = `ADYEN ERROR. Name = ${error.name}. Details = ${error.message}.`;
|
||||
|
||||
await global.$logger.logError(stringToLog);
|
||||
|
||||
this.hasPaymentFailureError = true;
|
||||
}
|
||||
|
||||
this.dropinComponent?.update();
|
||||
},
|
||||
|
||||
async saveAndSubmitWorkOrder() {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,16 @@ export async function adyenReturnBeforeEnter(to, from) {
|
|||
|
||||
try {
|
||||
result = await finalizeAdyenPayment(sessionId, redirectResult);
|
||||
} catch (error) {
|
||||
} catch (unexpectedResult) {
|
||||
// If user cancelled payment, handle without error message
|
||||
if (unexpectedResult.code === "Cancelled") {
|
||||
return {
|
||||
name: routeData.PAYMENT_ADYEN.name,
|
||||
replace: true,
|
||||
};
|
||||
}
|
||||
|
||||
// Otherwise, failure scenario.
|
||||
// Payment fails, so return user to payment-adyen screen to try again or pay later.
|
||||
return {
|
||||
name: routeData.PAYMENT_ADYEN.name,
|
||||
|
|
@ -108,7 +117,7 @@ function finalizeAdyenPayment(sessionId, redirectResult) {
|
|||
console.log(`Payment failed`);
|
||||
console.log(result);
|
||||
reject({
|
||||
paymentFailure: true,
|
||||
code: result?.resultCode,
|
||||
message: "Payment failed from Adyen",
|
||||
});
|
||||
},
|
||||
|
|
@ -116,7 +125,7 @@ function finalizeAdyenPayment(sessionId, redirectResult) {
|
|||
console.log(`Error occured`);
|
||||
console.log(error);
|
||||
reject({
|
||||
paymentFailure: false,
|
||||
code: "Error",
|
||||
message: "Error from Adyen",
|
||||
});
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue