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) => {
|
next(async (vm) => {
|
||||||
vm.setCmsContent(resultMap.cmsContent);
|
vm.setCmsContent(resultMap.cmsContent);
|
||||||
|
|
||||||
if(hasExistingPiaError) {
|
if (hasExistingPiaError) {
|
||||||
vm.hasPaymentFailureError = true;
|
vm.hasPaymentFailureError = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -405,18 +405,32 @@ export default {
|
||||||
console.log(`Result =`);
|
console.log(`Result =`);
|
||||||
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();
|
this.dropinComponent?.update();
|
||||||
},
|
},
|
||||||
handleError(error) {
|
async handleError(error) {
|
||||||
const stringToLog = `ADYEN ERROR. Name = ${error.name}. Details = ${error.message}.`;
|
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() {
|
async saveAndSubmitWorkOrder() {
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,16 @@ export async function adyenReturnBeforeEnter(to, from) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
result = await finalizeAdyenPayment(sessionId, redirectResult);
|
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.
|
// Payment fails, so return user to payment-adyen screen to try again or pay later.
|
||||||
return {
|
return {
|
||||||
name: routeData.PAYMENT_ADYEN.name,
|
name: routeData.PAYMENT_ADYEN.name,
|
||||||
|
|
@ -108,7 +117,7 @@ function finalizeAdyenPayment(sessionId, redirectResult) {
|
||||||
console.log(`Payment failed`);
|
console.log(`Payment failed`);
|
||||||
console.log(result);
|
console.log(result);
|
||||||
reject({
|
reject({
|
||||||
paymentFailure: true,
|
code: result?.resultCode,
|
||||||
message: "Payment failed from Adyen",
|
message: "Payment failed from Adyen",
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
@ -116,7 +125,7 @@ function finalizeAdyenPayment(sessionId, redirectResult) {
|
||||||
console.log(`Error occured`);
|
console.log(`Error occured`);
|
||||||
console.log(error);
|
console.log(error);
|
||||||
reject({
|
reject({
|
||||||
paymentFailure: false,
|
code: "Error",
|
||||||
message: "Error from Adyen",
|
message: "Error from Adyen",
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue